Linux / Unix: Bash Shell See All Exported Variables and Functions

Posted on in Categories last updated June 19, 2012

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

Posted by: Vivek Gite

The author is the creator of nixCraft and a seasoned sysadmin and a trainer for the Linux operating system/Unix shell scripting. He has worked with global clients and in various industries, including IT, education, defense and space research, and the nonprofit sector. Follow him on Twitter, Facebook, Google+.

6 comment

  1. @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! :)

  2. undo an export
    a parameter was exported to the current shell.

    I use a few different scripts that follow using that exported parameter
    Now I want to remove that exported variable.

    Aside from logging out, is the only way to remove it to set it to a null string?

Comments are closed.