Learn to view and set environment variables at the Linux command line.
Linux printenv command summary with examples (3:37)
Videos can also be accessed from the YouTube Playlist.
Our forty-sixth word, or command to memorize is
printenv from our category
printenv allows you to print
Recall from video 19, we used
print the PATH, and said we'd come back and talk
about environment variables, well it's time.
Before we start, it helps to think of commands as mini programs and
most follow this structure:
command -option(s) argument(s).
printenv command has
only 3 options and the arguments are the variables
you'd like to print, or enter none to see all of them.
Like most commands, help is available with double-dash
So why is
printenv an important command?
Well, we need to understand the environment.
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. Recall we used the
echo to view variables
= to set them. To refresh
"I'm here to learn dollar sign
Next, try printing the location of your current working directory,
which is an environment variable,
Nah, that won't work like that,
just took us literally, so we'll tell it to look for the variable with
printenv let's look at the
$PS1 variable which is our command
printenv doesn't work like
that, so let's try
PS1, and while
we're at it, let's add our language
LANG and working directory
And last, let's customize our prompt, and give me couple seconds here to do this.
Very good, and as always
the terminal window.
Okay now you know how to use
And you know the syntax for commands, options and arguments.
One last tip about the
So why don't you try a
without options or arguments on your end and see how many variables you
can decipher. Treat it like a progress check for your knowledge.
Okay, thanks for visiting today. I hope this was a helpful
introduction to the
For an overview of the 100 videos, the 8 quizzes, a cheat sheet, the categories and a Q&A section, visit:
Click here to join our growing YouTube Channel.
pscommand, hit Back.
exportand click Next.