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!
Notices
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.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I'm kinda of hazy on the difference between running the following three commands:
#: JAVA_HOME=/usr/java
and
#: export JAVA_HOME=/usr/java
and
#:
PATH=/usr/java/:$PATH
What you are doing in the three commands is setting environment variables for the shell (the command interpreter) you are working with. With the BASH shell "JAVA_HOME=/usr/java" and "export JAVA_HOME=/usr/java" are equivalent. "PATH=/usr/java/:$PATH" ads the path "/usr/java/" at the beginning of the PATH variable. It is as simple as that.
Actually, they are not quite the same. When a script assigns a variable it is generally considered a local variable. If you export that variable it allows sub shells access to that variable.
For instance if you create 2 scripts, the first one assigns 2 variables (say v1 and v2) but only exports v2, you then call the second script from the first, the second script will know nothing about v1 but will know about v2.
Output would look like this:
cjones@chris:~$ sh test1
Test 1 Program Environment Variables
------------------------------------
e1 = non-exported variable
e2 = exported variable
Test 2 Program Environment Variables
----------------------------
e1 =
e2 = exported variable
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.