Ubuntu – How to list all variables names and their current values

bashcommand lineenvironment-variables

How to list all variables names and their current values?

Including not only $HOME, $PWD etc but any other you have defined.

Best Answer

For bash: (the standard shell in Ubuntu)

Enter the following command in a terminal to print all the environment variables:

printenv

For further information about this command, read the printenv man page.


To show a list including the "shell variables" you can enter the next command:

( set -o posix ; set ) | less

This will show you not only the shell variables, but the environment variables too.

For more information related with this topic read:


For zsh: (an advanced shell)

Use the following command:

( setopt posixbuiltin; set; ) | less

For more information about ZSH options, see zshoptions man page.