Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This 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!


  Search this Thread
Old 07-24-2005, 12:37 PM   #1
Registered: May 2004
Location: Spain
Distribution: SuSE9x
Posts: 40

Rep: Reputation: 15
set or env?


The commands set and env both deliver the environment variables and their values, however
set | wc -l
env | wc -l
What ist the difference between them?
Could somebody name a good tutorial with examples?

Regards, Carsten
Old 07-24-2005, 12:55 PM   #2
Registered: Apr 2004
Location: Oxford, UK
Distribution: Ubuntu, Debian, various
Posts: 230
Blog Entries: 5

Rep: Reputation: 33
Hi Carsten,

The difference is that 'set' is also reporting shell-local variables. These look the same from the point of view of the shell user, but are not passed on to the new process if you run a command. When you use the 'export' command you promote a shell variable to be an environment variable.

Environment variables are a fundametal feature of Linux, while shell variables are just a feature of the shell. To fully understand how environment variables work you really need to appreciate the fork/exec process model. I would direct you to the mighty Rute for some explanation:

Old 07-24-2005, 01:56 PM   #3
Registered: May 2004
Location: Spain
Distribution: SuSE9x
Posts: 40

Original Poster
Rep: Reputation: 15

Thank you very much for the excellent explanation. And thank you also for the Rute link. I read the Rute book more than 4 years ago, and I completely forgot about it. Great book.

Regards, Carsten


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
set Versus env Echo Kilo Linux - General 2 06-09-2009 03:56 AM
Cannot set LD_LIBRARY_PATH in .cshrc (able to set other env variables) senthilpr_in Linux - Newbie 4 02-26-2007 01:46 PM
How to test if an env variable is set King of Men Linux - Newbie 5 11-03-2005 05:39 AM
how do you set an env variable from within a csh script? BrianK Linux - General 3 05-26-2004 03:16 PM
where are the env variables set on boot? Pete Dogg Linux - Software 1 09-10-2003 03:37 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:08 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration