/ factorpad.com / tech / linux-essentials / set-command.html
An ad-free and cookie-free website.
Intermediate
Videos can also be accessed from the Linux Essentials Playlist on YouTube.
Linux set Command Summary with Examples (3:34)
Our forty-eighth word, or command to memorize is
set
from our category
System.
set
allows you to display or set
shell and environment variables.
-options | description |
---|---|
--help |
Print help screen |
Recall from the printenv
and
export
videos, we saw environment
variables? Well, set
tacks on
variables unique to a shell program, like
bash
.
Before we start, it helps to think of commands as mini programs and
most follow this structure:
command -option(s) argument(s)
.
This fairly advanced set
command has
over 20 options which we won't cover here and the
argument is the variable and value.
Unlike most commands, help is not available with double-dash
--help
because as a shell built-in,
documentation sits in the bash
manual page (man bash
).
So why is set
an important command?
Well, in some situations you may need to
set
and
unset
shell variables and functions.
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. So I mainly wanted to introduce you to
set
as a way to understand that there
are environment variables, shell variables and a new concept called
functions. So instead of our regular demonstration, this will be
homework. So follow these steps.
First, enter printenv
optionless,
like you did in video 46. Then type
set
optionless and compare.
Output from set
will be long, so use
Shift-PgUp
and
Shift-PgDn
right here in the
terminal, or write it to a file using the redirection symbol
>
and then just take 5 minutes to
zip through it with less
.
And last, functions on the output can be identified by curly braces
{ }
and
if then
.
Okay now you know how to use set
.
And you know the syntax for commands, options and arguments.
One last tip about the set
command.
So here I simply wanted you to see what's passed around behind the
innocent-looking terminal window. Don't worry, the next few videos will
be easier.
Okay, thanks for visiting today. I hope this was a helpful
introduction to the set
command.
For an overview of the 100 videos, the 8 quizzes, a cheat sheet, the categories and a Q&A section, visit:
Not only will you find homework on our YouTube Channel, but also quizzes! Subscribe and follow to be a part of our smart group.
export
command,
hit Back.unset
command, click Next./ factorpad.com / tech / linux-essentials / set-command.html
A newly-updated free resource. Connect and refer a friend today.