Linux command
env 命令
文本
复制后可按需替换文件名、目录或参数。
常用示例
Show
env
Run
env VAR=value [command]
Clear
env -i [command]
Unset
env -u [VAR] [command]
说明
env runs a program in a modified environment. It can display current environment variables, set new ones, unset existing ones, or run commands with a clean environment. The command is useful for setting variables temporarily or debugging environment issues.
参数
- -i, --ignore-environment
- Start with empty environment
- -u _var_, --unset=_var_
- Remove variable from environment
- -0, --null
- End lines with NUL, not newline
- -C _dir_, --chdir=_dir_
- Change directory before running command
- -S _string_
- Process and split string into arguments (useful in shebang lines)
- -v, --verbose
- Print verbose information for each processing step
FAQ
What is the env command used for?
env runs a program in a modified environment. It can display current environment variables, set new ones, unset existing ones, or run commands with a clean environment. The command is useful for setting variables temporarily or debugging environment issues.
How do I run a basic env example?
Run `env` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does -i, --ignore-environment do in env?
Start with empty environment