Linux env command

Updated: 04/26/2017 by Computer Hope

About env

env is a shell command for Linux, Unix, and Unix-like operating systems. It can be used to print a list of the current environment variables, or to run another program in a custom environment without modifying the current one.

Description

If env is run without any options, it prints the variables of the current environment. Otherwise, env sets each NAME to VALUE and executes COMMAND.

env syntax

env [OPTION]... [-] [NAME=VALUE]... [COMMAND [ARG]...]

Options

-i, --ignore-environment Start with an empty environment.
-0, --null End each output line with a 0 (null) byte rather than a newline.
-u, --unset=NAME Remove variable NAME from the environment.
--help Display a help message and exit.
--version Display version information and exit.
- Same as -i.

env examples

env

Executing env with no options displays the current environment variables and their values. Output will look similar to the following:

HOME=/computerhope/public_html
PATH=/usr/local/bin:
LOGNAME=admin
HZ=100
TERM=vt100
TZ=MST7MDT
SHELL=/bin/csh
MAIL=/var/mail/computerhope
_INIT_UTS_PLATFORM=SUNW,SPARCstation-10
_INIT_UTS_RELEASE=5.7
_INIT_UTS_SYSNAME=SunOS
_INIT_UTS_VERSION=Generic_106541-08
EDITOR=pico -t
OPENWINHOME=/usr/openwin
MANPATH=/usr/man:/usr/local/man:/usr/openwin/man
LD_LIBRARY_PATH=/usr/local/lib:/usr/openwin/lib
PAGER=more

Below is brief description of some commonly-used environment variables:

EDITOR The default file editor to be used.
HOME The current user's home directory.
SHELL The location of the current user's shell program.
TERM The current terminal emulation.
PATH Pathnames to be searched when executing commands.
MAIL Location of where mail is to be stored.
MANPATH Location of your Manuals. See man command.
LOGNAME The name of the current user.
TZ The time zone used by the system clock.

csh — The C shell command interpreter.
ksh — The Korn shell command interpreter.
logname — Return a user's login name.
printenv — Print all or part of the environment.
sh — The Bourne shell command interpreter.