Operating systems · Shells and scripting

Env (command)

In Spanish: Env
See in the galaxyCopy link
Updated: 12/11/2026Reading: 2 min

Description

The 'env' command is a command-line tool used in Unix and Linux operating systems that allows running a program in a modified environment. Its main function is to display or modify the environment variables that affect the behavior of processes in the system. By using 'env', users can set new environment variables or modify existing ones before executing a specific command. This is especially useful for software testing, where a program is required to run with specific configurations without altering the global system environment. 'env' is commonly used in shell scripts and development environments, where the manipulation of environment variables is essential for the correct execution of applications. Additionally, its use is fundamental in various operating system distributions and programming environments, where environment customization and optimization are common practices among advanced users.

History

The 'env' command was introduced in the Unix operating system in the 1970s as part of the command-line tools that allowed users to interact with the system more flexibly. As Unix evolved and diversified into different distributions, 'env' remained an essential tool for managing environment variables. Its use has expanded over the years, especially with the popularity of programming languages and development environments that require specific configurations for application execution.

Uses

The 'env' command is primarily used to run programs with a specific set of environment variables. This is useful in situations where software needs to be tested in different configurations without affecting the global environment. It is also used in shell scripts to set temporary variables that are only relevant during the execution of a script. Additionally, 'env' is commonly employed in the creation of virtual environments for programming languages where precise control over environment dependencies and configurations is required.

Examples

A practical example of using 'env' is running a Python script with a specific environment variable: 'env MY_VAR=value python my_script.py'. This sets 'MY_VAR' only for the execution of 'my_script.py'. Another example is using 'env' to run a command with a clean environment: 'env -i bash', which starts a new bash session without any predefined environment variables.

Glosarix on your device

Install
×
Enable Notifications Ok No