Easy Tutorial
❮ Linux Comm Losetup Linux Comm Mtype ❯

Linux unset Command

Linux Command Manual

The Linux unset command is used to delete variables or functions.

unset is a shell built-in command that can delete variables or functions.

Syntax

unset [-fv][variable or function name]

Parameters:

Example

Delete environment variable

[[email protected] ~]# lx="ls -lh" //Set environment variable
[[email protected] ~]# $lx //Use environment variable
total 116K
-rw-r--r-- 1 root root 2.1K 2008-03-30 anaconda-ks.cfg
drwx------ 3 root root 4.0K Mar 30 21:22 Desktop
-rw-r--r-- 1 root root 50K 2008-03-30 install.log
-rw-r--r-- 1 root root 32K 2008-03-30 install.log.syslog
lrwxrwxrwx 1 root root  9 2008-03-30 qte -> /opt/qte/
[[email protected] ~]# set //View current environment variables
BASH=/bin/bash
BASH_ARGC=()
BASH_ARGV=()
……Omitted part of the content
PROMPT_COMMAND='echo -ne "33]0;${USER}@${HOSTNAME%%.*}:${PWD/#$HOME/~}07"'
PS1='[\u@\h \W]$ '
PS2='> '
PS4='+ '
PWD=/root
QTDIR=/usr/lib/qt-3.3
SHELL=/bin/bash
SSH_TTY=/dev/pts/4
SUPPORTED=zh_CN.UTF-8:zh_CN:zh:en_US.UTF-8:en_US:en
SYSFONT=latarcyrheb-sun16
TERM=xterm
UID=0
USER=root
_=-lh
lx='ls -lh'
[[email protected] ~]# unset lx //Delete environment variable
[[email protected] ~]# set //Display current environment variables
BASH=/bin/bash
BASH_ARGC=()
BASH_ARGV=()
……Omitted part of the content
PROMPT_COMMAND='echo -ne "33]0;${USER}@${HOSTNAME%%.*}:${PWD/#$HOME/~}07"'
PS1='[\u@\h \W]$ '
PS2='> '
PS4='+ '
PWD=/root
QTDIR=/usr/lib/qt-3.3
SHELL=/bin/bash
SSH_TTY=/dev/pts/4
SUPPORTED=zh_CN.UTF-8:zh_CN:zh:en_US.UTF-8:en_US:en
SYSFONT=latarcyrheb-sun16
TERM=xterm
UID=0
USER=root
_=-lh

Linux Command Manual

❮ Linux Comm Losetup Linux Comm Mtype ❯