What does the 'export' command do?

Chathura Kulasinghe picture Chathura Kulasinghe · Dec 10, 2012 · Viewed 100.7k times · Source

I am a little new to Linux, and I happen to run some commands blindly, in order to get things done. I thought that it will not be a waste of asking these type of questions, since more new people would have a regular knowledge about those.

I started to work with Jenkins recently, and then I had to use this export command to run the Jenkins war archive. So I needed to know what export command does in general, and why we need to run this command, while running Jenkins (after the Jenkins home is set).

Thanks!

Answer

Yann Ramin picture Yann Ramin · Dec 10, 2012

export in sh and related shells (such as bash), marks an environment variable to be exported to child-processes, so that the child inherits them.

export is defined in POSIX:

The shell shall give the export attribute to the variables corresponding to the specified names, which shall cause them to be in the environment of subsequently executed commands. If the name of a variable is followed by = word, then the value of that variable shall be set to word.