Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am used to the bash set command listing only a list of the environment settings, eg. PATH and such.

However, on an Ubuntu system I just set up, executing set dumps 2000 lines of text, including lots of functions like this:

dequote () 
    eval printf %s "$1" 2> /dev/null

How do I print only the environment variables?

share|improve this question
Note that your Ubuntu system almost certainly is using bash as well - it's the default on new installs. – Andrew Ferrier Feb 27 '13 at 10:24
up vote 2 down vote accepted

By default set shows the shell variables, not just the environment variables. In bash functions are considered part of the variables. See .

If you use env or printenv they will show the environment exported to child processes, which is not necessarily the same as your bash environment:

$ foo=1
$ printenv foo
$ export foo
$ printenv foo

The bash declare and typeset builtins can list all types of variables, to omit functions:

declare -F

The output of these is in a form suitable for recreating the state in a shell script, so it's a little verbose, though you can distinguish between arrays, integers and other types (depending on version). See also the output of export -p.

And from you can tell bash to use POSIX mode, and set behaves "properly":

( set -o posix ; set ) 

That's run in a subshell so it doesn't alter your running shell, and it correctly picks up variables not yet exported into the inherited environment.

share|improve this answer

If you want to list all the environment variables, simply enter env.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.