Environment variables can be shown with env; but, some are not shown. For example...

echo $EUID might produce as result of 1000 yet env | grep EUID produces no result.

What is this type of variable? A read-only environment variable?

Do all shells set the same variables by some convention?

How does one go about listing these hidden variables?


The set command shows all variables (and functions), not just the exported ones, so

set | grep EUID

will show you the desired value. This command should show all the non-exported variables:

comm -23 <(set | grep '^[^=[:space:]]\+=' | sort) <(env | sort)
  • Unfortunately 'set' can add quotes while 'env' does not as such this will list some variables (often very long ones), which are actually exported environment variables.
    – anthony
    Jun 8 '16 at 0:41

There are no hidden environment variables.
All are printed with either env or printenv.

What you did was print the value of a variable EUID, but that variable is not exported.

$ bash -c 'declare -p EUID'
declare -ir EUID="1000"

That is: (i) for integer and (r) for readonly. No (x) for exported, though.

$ zsh -c 'typeset -p EUID'
typeset -i10 EUID=1000

That is (i) for integer, (10) for base 10 (decimal).


$ bash -c 'declare -p PATH'
declare -x PATH="…"

$ zsh -c 'typeset -p PATH'
export PATH=…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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