YouTip LogoYouTip

Linux Comm Unset

Linux unset command

Linux unset command

-- Learning is not just about technology, but also about dreams!

Linux Tutorial

Linux Tutorial Linux Introduction Linux Installation Linux Cloud Server Install Linux via WSL Linux System Boot Process Linux System Directory Structure Linux Forgot Password Solution Linux Remote Login Linux File Basic Attributes Linux File and Directory Management Linux User and User Group Management Linux Disk Management Linux vi/vim Linux yum command Linux apt command

Shell Tutorial

Shell Tutorial Shell Variables Shell Passing Arguments Shell Arrays Shell Operators Shell echo command Shell printf command Shell test command Shell Process Control Shell Functions Shell Input/Output Redirection Shell File Inclusion

Linux Reference Manual

Linux Command Manual Nginx Installation and Configuration MySQL Installation and Configuration Linux Quiz

Linux unset command

Linux Command Manual 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 

Parameters:

  • -f Delete functions only.
  • -v Delete variables only.

Examples

Delete an environment variable

[root@.com ~]# lx="ls -lh" //Set an environment variable
[root@.com ~]# $lx //Use the 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/
[root@.com ~]# set //View current environment variables
BASH=/bin/bash
BASH_ARGC=()
BASH_ARGV=()
...content omitted...
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'
[root@.com ~]# unset lx //Delete the environment variable
[root@.com ~]# set //Display current environment variables
BASH=/bin/bash
BASH_ARGC=()
BASH_ARGV=()
...content omitted...
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
← Os DupOs Closerange β†’