Set environment for command invocation (POSIX)
env [-i] [name=value]... [command [arguments]]
env - [name=value]... [command [arguments]]
- Ignore the environment that's otherwise inherited from the current shell. This restricts the environment for command to that specified by any name = value pairs.
- (Deprecated) same as -i
- name = value
- Set the environment variable name to value and add it to the environment.
- A command to be invoked.
The env utility obtains the current environment, modifies it according to its arguments, and executes command with the modified environment. If no command is specified, the resulting environment is displayed.
If you have removed the PATH environment variable from the environment, you must include the path to the command.
Start a shell with only the SHELL and PATH environment variables:
env -i SHELL=/bin/sh PATH=/bin:/usr/bin sh
Start a daemon process with no environment:
env -i /bin/cron
When a command is specified on the command line, the env utility attempts to exec() into that command. If the command is successfully launched, the exit status from env is that of the program it exec()ed into. Otherwise, env returns an exit status as follows:
- (Assuming no command was specified) the resulting environment was successfully displayed.
- An error was present in the command-line parameters supplied or env was unable to launch the command specified on the command line.
Last modified: 2013-12-21