/ factorpad.com / tech / linux-essentials / unset-command.html
An ad-free and cookie-free website.
Intermediate
Learn to remove variables and functions at the Linux command line.
Videos can also be accessed from the Linux Essentials Playlist on YouTube.
Linux unset Command Summary with Examples (3:22)
Our forty-ninth word, or command to memorize is
unset
from our category
System.
unset
allows you to remove variables
or functions.
-options | description |
---|---|
-v |
Unset a variable |
-f |
Unset a function |
Recall from printenv
,
export
and
set
, we've been working with
variables? Well, unset
will provide
for us an easy way to remove them.
Before we start, it helps to think of commands as mini programs and
most follow this structure:
command -option(s) argument(s)
.
The unset
command has
2 options and the argument is the variable name.
Unlike most commands, help is not available with double-dash
--help
because it's a shell built-in,
just like export
and
set
, so on most systems
documentation hides in the manual page for
bash
(man bash
).
The -v
option, the default, removes
variables and -f
is for functions.
So why is unset
an important command?
Well, unset
offers a simple way to
remove shell and environment variables, plus functions as well.
And now you know how to do that.
Okay, the best way to embed this in your memory is by typing in your own terminal window.
Find this on your Mac using a program called Terminal. On Linux use Terminal or Konsole, and currently Microsoft is adding this functionality to Windows.
Here we go. Let's keep it simple and resurrect what we did for
printenv
and
export
, except this time do it in one
step. Recall, we made a variable called BBTEAM, for
baseball team, and set the value to my favorite, the San Francisco
Giants, and here's how we'll do it in one step.
And then now, test it with
printenv BBTEAM
. All set.
Then we'll remove it using
unset BBTEAM
And last, test it with another
printenv BBTEAM
.
Very good.
Okay now you know how to use unset
.
And you know the syntax for commands, options and arguments.
One last tip about the unset
command.
So this ends a mini-set of videos on variables, next we'll shift
gears and talk about resources. That sounds fun, doesn't it?
Okay, thanks for visiting today. I hope this was a helpful
introduction to the unset
command.
For an overview of the 100 videos, the 8 quizzes, a cheat sheet, the categories and a Q&A section, visit:
We have fun with Linux on our YouTube Channel, please join us by subscribing there and following @factorpad on Twitter for introductions to new content.
set
command,
hit Back.stat
command, click Next./ factorpad.com / tech / linux-essentials / unset-command.html
A newly-updated free resource. Connect and refer a friend today.