Emacs provides access to variables in the operating system environment through various functions. These variables include the name of the system, the user's UID, and so on.
This variable holds the standard GNU configuration name for the hardware/software configuration of your system, as a string. For example, a typical value for a 64-bit GNU/Linux system is ‘"x86_64-unknown-linux-gnu"’.
The value of this variable is a symbol indicating the type of operating system Emacs is running on. The possible values are:
- IBM's AIX.
- Berkeley BSD and its variants.
- Cygwin, a Posix layer on top of MS-Windows.
- Darwin (Mac OS X).
- The GNU system (using the GNU kernel, which consists of the HURD and Mach).
- A GNU/Linux system—that is, a variant GNU system, using the Linux kernel. (These systems are the ones people often call “Linux”, but actually Linux is just the kernel, not the whole system.)
- A GNU (glibc-based) system with a FreeBSD kernel.
- Hewlett-Packard HPUX operating system.
- Silicon Graphics Irix system.
- Microsoft's DOS. Emacs compiled with DJGPP for MS-DOS binds
ms-doseven when you run it on MS-Windows.
- AT&T Unix System V.
- Microsoft Windows NT, 9X and later. The value of
windows-nt, e.g., even on Windows 7.
We do not wish to add new symbols to make finer distinctions unless it is absolutely necessary! In fact, we hope to eliminate some of these alternatives in the future. If you need to make a finer distinction than
system-typeallows for, you can test
system-configuration, e.g., against a regexp.
This function returns the name of the machine you are running on, as a string.
system-name is a variable as well as a function. In
fact, the function returns whatever value the variable
system-name currently holds. Thus, you can set the variable
system-name in case Emacs is confused about the name of your
system. The variable is also useful for constructing frame titles
(see Frame Titles).
If this variable is non-
nil, it is used instead of
system-namefor purposes of generating email addresses. For example, it is used when constructing the default value of
user-mail-address. See User Identification. (Since this is done when Emacs starts up, the value actually used is the one saved when Emacs was dumped. See Building Emacs.)
This function returns the value of the environment variable var, as a string. var should be a string. If var is undefined in the environment,
nil. It returns ‘""’ if var is set but null. Within Emacs, a list of environment variables and their values is kept in the variable
process-environment.(getenv "USER") ⇒ "lewis"
The shell command
printenvprints all or part of the environment:bash$ printenv PATH=/usr/local/bin:/usr/bin:/bin USER=lewis TERM=xterm SHELL=/bin/bash HOME=/home/lewis ...
This command sets the value of the environment variable named variable to value. variable should be a string. Internally, Emacs Lisp can handle any string. However, normally variable should be a valid shell identifier, that is, a sequence of letters, digits and underscores, starting with a letter or underscore. Otherwise, errors may occur if subprocesses of Emacs try to access the value of variable. If value is omitted or
nil(or, interactively, with a prefix argument),
setenvremoves variable from the environment. Otherwise, value should be a string.
If the optional argument substitute is non-
nil, Emacs calls the function
substitute-env-varsto expand any environment variables in value.
setenvworks by modifying
process-environment; binding that variable with
letis also reasonable practice.
setenvreturns the new value of variable, or
nilif it removed variable from the environment.
This variable is a list of strings, each describing one environment variable. The functions
setenvwork by means of this variable.process-environment ⇒ ("PATH=/usr/local/bin:/usr/bin:/bin" "USER=lewis" "TERM=xterm" "SHELL=/bin/bash" "HOME=/home/lewis" ...)
process-environmentcontains “duplicate” elements that specify the same environment variable, the first of these elements specifies the variable, and the other “duplicates” are ignored.
This variable holds the list of environment variables Emacs inherited from its parent process when Emacs started.
This variable holds a string that says which character separates directories in a search path (as found in an environment variable). Its value is
":"for Unix and GNU systems, and
";"for MS systems.
This function takes a search path string such as the value of the PATH environment variable, and splits it at the separators, returning a list of directory names.
nilin this list means the current directory. Although the function's name says “colon”, it actually uses the value of
path-separator.(parse-colon-path ":/foo:/bar") ⇒ (nil "/foo/" "/bar/")
This variable holds the program name under which Emacs was invoked. The value is a string, and does not include a directory name.
This variable holds the directory from which the Emacs executable was invoked, or
nilif that directory cannot be determined.
nil, this is a directory within which to look for the lib-src and etc subdirectories. In an installed Emacs, it is normally
nil. It is non-
nilwhen Emacs can't find those directories in their standard installed locations, but can find them in a directory related somehow to the one containing the Emacs executable (i.e.,
This function returns the current 1-minute, 5-minute, and 15-minute system load averages, in a list. The load average indicates the number of processes trying to run on the system.
By default, the values are integers that are 100 times the system load averages, but if use-float is non-
nil, then they are returned as floating point numbers without multiplying by 100.
If it is impossible to obtain the load average, this function signals an error. On some platforms, access to load averages requires installing Emacs as setuid or setgid so that it can read kernel information, and that usually isn't advisable.
If the 1-minute load average is available, but the 5- or 15-minute averages are not, this function returns a shortened list containing the available averages.(load-average) ⇒ (169 48 36) (load-average t) ⇒ (1.69 0.48 0.36)
The shell command
uptimereturns similar information.