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

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • 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. lrzuntar Command Examples in Linux
  2. DNS configuration file /etc/named.conf explained
  3. How to Tune Btrfs Filesystem for Better Performance
  4. nmon Command Examples in Linux
  5. How to use perf tool for tracing similar to dtrace
  6. cp: command not found
  7. How to recover GRUB (Corrupted boot partition) in CentOS/RHEL 5,6
  8. dnsmap Command Examples in Linux
  9. numactl Command Examples in Linux
  10. mkfs Command Examples in Linux

You May Also Like

Primary Sidebar

Recent Posts

  • aws ec2: CLI for AWS EC2 (Command Examples)
  • aws cur – Create, query, and delete AWS usage report definitions (Command Examples)
  • aws configure – Manage configuration for the AWS CLI (Command Examples)
  • aws cognito-idp: Manage Amazon Cognito user pool and its users and groups using the CLI

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright