0

I know there is $USER, $HOME, $PATH, etc.

8 Answers 8

8

There are plenty: DBUS_SESSION_BUS_ADDRESS, XAUTHORITY, GDM_LANG, etc. You can view all your environment variables with the env command - type it in inside a terminal.

As far as I know, there's no limitations on environment variables, they can be of any length, and anything can create them and add them to the environment (using export, as you may have seen). Conceptually, environment variables act as "global variables" that are shared among all programs running in a terminal.

7

Err... lots?

$ env | cut -d = -f 1 | sort | uniq 
_
COLORFGBG
DBUS_SESSION_BUS_ADDRESS
DESKTOP_SESSION
DISPLAY
DM_CONTROL
EDITOR
GPG_AGENT_INFO
GS_LIB
GTK2_RC_FILES
GTK_RC_FILES
HISTCONTROL
HOME
KDE_FULL_SESSION
KDE_MULTIHEAD
KDE_SESSION_UID
KDE_SESSION_VERSION
KONSOLE_DBUS_SERVICE
KONSOLE_DBUS_SESSION
LANG
LANGUAGE
LESSCLOSE
LESSOPEN
LIBGL_DRIVERS_PATH
LOGNAME
LS_COLORS
OLDPWD
PATH
PROFILEHOME
PWD
QT_PLUGIN_PATH
SESSION_MANAGER
SHELL
SHLVL
SSH_AGENT_PID
SSH_AUTH_SOCK
TERM
USER
WINDOWID
WINDOWPATH
XCURSOR_THEME
XDG_DATA_DIRS
XDG_SESSION_COOKIE
XDM_MANAGED
2
  • There's no need for the uniq(ue) because you can't have 2 the same. Oct 24, 2013 at 19:35
  • Yeah, fair point. I tend to uniq after sorting to keep down the noise in a general text pipeline, but it is unnecessary in this situation. Dec 12, 2013 at 20:32
3

Yep, $SHELL is one of them that I know of.

Edit: see this page for more of them.

1

How about $DISPLAY and $LD_LIBRARY_PATH.

1

Every system is configured differently so rather than listing them all here, just enter the following command to list them all on your own system:

set | sed 's/=.*//' | grep -v "^[A-Z_]\{4\}$"

I'd use set instead of env as it has greater scope. Most system environment variables are in upper case so to add that restriction add an extra grep to the pipe line.

set | sed 's/=.*//' | grep "[A-Z_]" | grep -v "^[A-Z_]\{4\}$"
1

env | cut -d = -f 1 | grep -E "([A-Z_]{4,})"

Use this command

0

$LD_LIBRARY_PATH and $LD_PRELOAD both exist for linking.

0

User defined environment variables don't have to four characters long (ex. CLASSPATH)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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