Linux – Export

I think if you are a frequent Linux or Mac user, you probably have seen or used the command export a lot. My impression of export is very simple, generate a variable to contain certain value. For example, in the big data world, you constantly have applications need HADOOP_HOME variable to be defined pointing to the Hadoop directory, another very frequently used one is JAVA_HOME. After reading an article from linuxcareer, I think I have a much better understanding of what it does.

That article briefly describe the concept of child vs parent process. They mentioned that any process can be a parent/child process at the same time with exception of “init” process, which is always marked with PID. init in that way turned out to be the parent of all processes on your linux system.

The ultimate definition of export:

“In general, the export command marks an environment variable to be exported with any newly forked child processes and thus it allows a child process to inherit all marked variables.”

A few take-aways from the article:

(1) $$ will get you the current bash process id

(2) export -n will remove the variable from the export list.

(3) export -f will export a function

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s