Linux: List All Environment Variables Command

How do I display all my environment variables using bash shell on RHEL / Debian / Ubuntu / CentOS / Fedora / Mint Linux operating systems?

You can use any one of the following command to display the environment variables and their values.


Tutorial details
DifficultyEasy (rss)
Root privilegesNo
a) printenv command – Print all or part of environment.

b) env command – Print all exported environment or run a program in a modified environment.

c) set command – Print the name and value of each shell variable.


I recommend that you use the printenv command:



printenv | less


printenv | more

Sample outputs:

Fig.01: Command to see a list of all currently defined environment variables in a Linux bash terminal

Fig.01: Command to see a list of all currently defined environment variables in a Linux bash terminal

A list of the commonly used variables in Linux

System VariableMeaningTo View Variable Value Type
BASH_VERSIONHolds the version of this instance of bash.echo $BASH_VERSION
HOSTNAMEThe name of the your computer.echo $HOSTNAME
CDPATHThe search path for the cd command.echo $CDPATH
HISTFILEThe name of the file in which command history is saved.echo $HISTFILE
HISTFILESIZEThe maximum number of lines contained in the history file.echo $HISTFILESIZE
HISTSIZEThe number of commands to remember in the command history. The default value is 500.echo $HISTSIZE
HOMEThe home directory of the current user.echo $HOME
IFSThe Internal Field Separator that is used for word splitting after expansion and to split lines into words with
the read builtin command. The default value is <space><tab><newline>.
echo $IFS
LANGUsed to determine the locale category for any category not specifically selected with a variable starting with LC_.echo $LANG
PATHThe search path for commands. It is a colon-separated list of directories in which the shell looks for commands.echo $PATH
PS1Your prompt settings.echo $PS1
TMOUTThe default timeout for the read builtin command. Also in an interactive shell, the value is interpreted as
the number of seconds to wait for input after issuing the command. If not input provided it will logout user.
echo $TMOUT
TERMYour login terminal type.echo $TERM
export TERM=vt100
SHELLSet path to login shell.echo $SHELL
DISPLAYSet X display nameecho $DISPLAY
export DISPLAY=:0.1
EDITORSet name of default text editor.export EDITOR=/usr/bin/vim

set and env command

You can use the env / set command too:

env | more
set | more

Sample outputs:

vivek@nas01:~$ env
SSH_CLIENT= 60190 22

A note about env/set command

The env will only display a list of environment variables that have been exported and it will not show all bash variables. The set command allows you to change the values of shell options and set the positional parameters, or to display the names and values of shell variables. If no options or arguments are supplied, set displays the names and values of all shell variables and functions, sorted according to the current locale, in a format that may be reused as input for setting or resetting the currently-set variables. Hence, I recommend that you use printenv command to dump the list of all shell variables on screen. To save the list of all shell environment variables to a file, enter:

printenv > env.txt
cat env.txt

Use the grep command to search for particular variable:

printenv | grep foo
printenv | grep HOME
Recommend readings
🐧 Get the latest tutorials on SysAdmin, Linux/Unix, Open Source/DevOps topics:
CategoryList of Unix and Linux commands
File Managementcat
FirewallCentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network Utilitiesdig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNCentOS 8 Debian 10 Firewall Ubuntu 20.04

5 comments… add one
  • stellar_geisha Jul 19, 2015 @ 19:57

    Thank you <3

  • aref ghobadi Aug 18, 2015 @ 8:33

    thank you :)

  • Harish Feb 21, 2016 @ 18:03

    Thank you for this useful information.

  • Akshata N Jun 7, 2016 @ 12:03

    Thank you.It’s really helpful.

  • 13E Dec 12, 2017 @ 3:34

    Thank you. This is a very informative.

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre>, <code>...</code> and <kbd>...</kbd> for code samples.