• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • VCS
  • Interview Questions
  • Database
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

env Command Examples in Linux

by admin

The env command is used to run a command with modified environment variables. By supplying the name of a variable and a value in the key-value pair format, as well as supplying a command to run, you can change the value of the specified variable for that particular command session. If the variable does not exist, it will be added to the environment. Likewise, you can use the -u option to remove the specified variable from the environment in which the specified command runs. Consider using env if you want to override values in child processes or add new ones.

Issuing the command without any arguments will display all variables in the environment as well as their corresponding values.

Syntax

The syntax of the env command is:

# env [options] [NAME=value] [command]

Listing environment variables and their values:

env command examples in Linux

env Command Examples

1. To run a program to ignore environment:

# env -i myprog.sh
# env --ignore-environment myprog.sh 

2. To end each output line with 0 byte rather than newline:

# env -0 myprog.sh
# env --null myprog.sh 

3. To remove a variable from the environment:

# env -u NAME
# env --unset=NAME 

4. To display the help:

# env --help 

5. To display the version:

# env --version

Filed Under: Linux

Some more articles you might also be interested in …

  1. SSH Authentication Files in Linux
  2. “go fmt” Command Examples
  3. i3 Command Examples in Linux
  4. CentOS / RHEL : How to set chroot jail for vsftp for all the users
  5. ionic Command Examples
  6. vshadowmount: command not found
  7. How to use “yum downloadonly” to download a package without installing it
  8. “git reauthor” Command Examples
  9. imgp Command Examples in Linux
  10. dmesg Command Examples in Linux

You May Also Like

Primary Sidebar

Recent Posts

  • Vanilla OS 2 Released: A New Era for Linux Enthusiasts
  • mk Command Examples
  • mixxx Command Examples
  • mix Command Examples

© 2025 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright