Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
I am following Visual Quickstart Unit and Linux. I see how I can set an environmental variable. I didn't think it should be available until I exported it, but when I tried, I was able to echo it before exporting it. I've read the man file on export, but am still not certain. Can anyone help provide clarification on setting variables and export? Thank you
The supplied names are marked for automatic export to the envi-
ronment of subsequently executed commands. If the -f option is
given, the names refer to functions. If no names are given, or
if the -p option is supplied, a list of all names that are
exported in this shell is printed. The -n option causes the
export property to be removed from each name. If a variable
name is followed by =word, the value of the variable is set to
word. export returns an exit status of 0 unless an invalid
option is encountered, one of the names is not a valid shell
variable name, or -f is supplied with a name that is not a func-
Without export, you've set a regular shell variable rather than an environment variable.
In your shell there is very little difference (as you can see with your echo), but as soon as you start calling other programs you'll see a difference. Environment variables are available from within any programs you call, regular shell variables are not.
When a variable is assigned, its value is stored in memory and you can readily access it in the current shell (this is called a local scope). Problems arise when a sub-process is started from the current (parent) shell, e.g. when you launch a shell script. The sub-process is not aware of the variables stored in memory from the parent shell, unless they've been exported. Exporting a variable means to make it available to every sub-process (global scope), exactly as a resource available from the surrounding environment.
Shell variables are placed in an array of variables. When an export of a shell variable is done it is moved to a list that will be COPIED to the new process (actually, only a pointer is involved).
When a child process is started, the "export" list is copied to the new process (as an exported list which is copied to its child processes). Thus no changes to an exported variable can be seen by the parent process.
PS. Bragging right now. Just skied 28K feet at Whistler today. My legs are dead, and typing while sipping a beer and looking at the mountain.