/ factorpad.com / tech / linux-essentials / export-command.html
An ad-free and cookie-free website.
Intermediate
Learn to pass environment variables to processes at the Linux command line.
Videos can also be accessed from the YouTube Linux Essentials Playlist on YouTube.
Linux export Command Summary with Examples (3:37)
Our forty-seventh word, or command to memorize is
export
from our category
System.
export
allows you to pass
environment variables to other processes.
-options | description |
---|---|
-p |
List exported environment variables |
Recall from the last video, we viewed and edited an environment variable. Now we'll learn how to set and share one.
Before we start, it helps to think of commands as mini programs and
most follow this structure:
command -option(s) argument(s)
.
The export
command has
only 3 options and the argument is the variable
to set for use in other processes, run outside the shell.
Unlike most commands, help is not available with double-dash
--help
and the
-p
option is helpful to list all
variables exported.
So why is export
an important command?
Well, especially as we advance, we may collect and pass variables to
be used outside the local bash
session.
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 from video 46, we used
printenv
but stopped short of
actually establishing environment variables. Let's work on that and
create an environment variable called BBTEAM for
baseball team and input my favorite team, the San Francisco Giants.
Next, I can use echo
to see if it
worked by using $BBTEAM
, and the
dollar sign $
is required because
it's a variable.
So far so good.
Then try printenv BBTEAM
. Did the
BBTEAM environment variable stick?
No.
Now for the whole reason for this video, type
export BBTEAM
.
And then last, verify by trying the
printenv BBTEAM
again.
And very good.
Okay now you know how to use export
.
And you know the syntax for commands, options and arguments.
One last tip about the export
command.
So if you can't find a manual page for
export
you're not alone. It's a
shell builtin for bash
, so you'll find
information in the very long manual page for
bash
. If you're curious.
Okay, thanks for visiting today. I hope this was a helpful
introduction to the export
command.
For an overview of the 100 videos, the 8 quizzes, a cheat sheet, the categories and a Q&A section, visit:
Besides joining us at YouTube and @factorpad on Twitter, perhaps the best way to support ad-free education online is by adding a link to this website on your website.
printenv
command,
hit Back.set
, click Next./ factorpad.com / tech / linux-essentials / export-command.html
A newly-updated free resource. Connect and refer a friend today.