How do I see a list of all exported variables and functions under Unix bash shell?
The export command makes your local variables global. The syntax is as follows:
export PATH=$PATH:/usr/local/bin:~/bin export EDITOR=/usr/local/bin/vim export SHELL=/bin/ksh export LANG=En_US export PAGER=/usr/local/bin/most
To make your local shell variables global automatically, export them in your ~/.profile or ~/.bash_profile file under Unix like operating systems. To see a list of all exported variables and functions pass the -p option to the export command:
export -p export -p | grep something export -p | less export -p | more
Sample outputs:
DISPLAY=unix:0 EDITOR=vim HISTFILE=/home/vivek/.bash_history HISTSIZE=1000 HOME=/home/vivek LANG=En_IN LOGNAME=vivek MAIL=/usr/mail/vivek MAILCHECK=0 PWD=/home/vivek SHELL=/bin/bash
You should follow me on twitter here or grab rss feed to keep track of new changes.
Featured Articles:
- 30 Handy Bash Shell Aliases For Linux / Unix / Mac OS X
- Top 30 Nmap Command Examples For Sys/Network Admins
- 25 PHP Security Best Practices For Sys Admins
- 20 Linux System Monitoring Tools Every SysAdmin Should Know
- 20 Linux Server Hardening Security Tips
- Linux: 20 Iptables Examples For New SysAdmins
- Top 20 OpenSSH Server Best Security Practices
- Top 20 Nginx WebServer Best Security Practices
- 20 Examples: Make Sure Unix / Linux Configuration Files Are Free From Syntax Errors
- 15 Greatest Open Source Terminal Applications Of 2012

- My 10 UNIX Command Line Mistakes
- Top 10 Open Source Web-Based Project Management Software
- Top 5 Email Client For Linux, Mac OS X, and Windows Users
- The Novice Guide To Buying A Linux Laptop














{ 4 comments… read them below or add one }
‘set’ will display all defined variables and functions in your current session.
Can i use that for setting JAVA_HOME at bash profile ? How to make it permanent ?
There’s also `env`, or `env | sort` if one desires sorted output as per export -p.
@Antonius: Yes, of course you can. Add the following lines:
export JAVA_HOME=/path/to/your/java/installation
export PATH=JAVA_HOME/bin:$PATH
to ~/.bash_profile (or ~/.bashrc) and you’re done! :)