Site icon LinuxCommands.site

env command tutorial in linux/unix with examples and use cases

linux env command – run a program in a modified environment

The env command executes another program after modifying the environment as specified on the command line. When the env command is used without parameters, it prints a list of current environment variables.

Syntax

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

Options

Examples

Print a list of the current environment variables

➜  ~ env

Removes the specified variable from the current environment

➜  ~ env -u MAIL

Use the env command to temporarily change the environment

➜  ~ env SHELL=/bin/bash

Used to pass multiple arguments on shebang lines

Running a script named script.pl containing the following first line:

#!/usr/bin/env -S perl -w -T

Will execute perl -w -T script.pl .

Exit mobile version