Forrest logo
tool overview
On this page you find all important commands for the CLI tool env. If the command you are looking for is missing please ask our AI.

env

The "env" command line tool is used to display or set environment variables in a Unix-like operating system. It can also run a command with modified environment variables.

Here are some key features and usage examples of the "env" command:

  1. Display current environment variables: Running the "env" command without any arguments will display the current environment variables with their respective values.

  2. Set environment variables: The command can be used to set new environment variables or modify existing ones in the current shell environment. For example:

    • To set the variable "MY_VAR" with the value "hello": env MY_VAR=hello
    • To modify the existing variable "PATH" by adding a new directory: env PATH=$PATH:/new/directory
  3. Run a command with modified environment variables: By prefixing a command with the "env" command, you can run it with modified environment variables. For example:

    • To run a command with a specific environment variable: env VAR_NAME=value command
    • To unset an environment variable before running a command: env -u VAR_NAME command
  4. Invoke scripts with desired environment variables: The "env" command is often used to invoke scripts with specific environment variables required for their execution.

  5. Portability and compatibility: The "env" command ensures portability by allowing scripts or commands to run with consistent environment variable settings across different systems.

  6. Searching for executables in different locations: The "env" command can be used to search for executables in different directories by manipulating the "PATH" variable.

Overall, the "env" command provides a flexible way to manage and manipulate environment variables, which are essential for configuring the behavior of various applications and scripts in a Unix-like environment.

List of commands for env:

  • env:tldr:07124 env: Remove variable from the environment and run a program.
    $ env -u ${variable} ${program}
    try on your machine
    explain this command
  • env:tldr:20350 env: Run a program. Often used in scripts after the shebang (#!) for looking up the path to the program.
    $ env ${program}
    try on your machine
    explain this command
  • env:tldr:5c45c env: Set a variable and run a program.
    $ env ${variable}=${value} ${program}
    try on your machine
    explain this command
  • env:tldr:7bdea env: Clear the environment and run a program.
    $ env -i ${program}
    try on your machine
    explain this command
  • env:tldr:8f404 env: Set multiple variables and run a program.
    $ env ${variable1}=${value} ${variable2}=${value} ${variable3}=${value} ${program}
    try on your machine
    explain this command
  • env:tldr:ff035 env: Show the environment.
    $ env
    try on your machine
    explain this command
tool overview