Linux: List All Environment Variables Command

81 篇文章 0 订阅
24 篇文章 0 订阅
How do I display all my environment variables using bash shell on RHEL / Debian / Ubuntu / CentOS / Fedora / Mint Linux operating systems?

You can use any one of the following command to display the environment variables and their values.
 
 
 
 
a) printenv command - Print all or part of environment.

b) env command - Print all exported environment or run a program in a modified environment.

c) set command - Print the name and value of each shell variable.

Examples

I recommend that you use the printenv command:

printenv

OR

printenv | less

OR

printenv | more

Sample outputs:

Fig.01: Command to see a list of all currently defined environment variables in a Linux bash terminal

Fig.01: Command to see a list of all currently defined environment variables in a Linux bash terminal

A list of the commonly used variables in Linux

System VariableMeaningTo View Variable Value Type
BASH_VERSIONHolds the version of this instance of bash.echo $BASH_VERSION
HOSTNAMEThe name of the your computer.echo $HOSTNAME
CDPATHThe search path for the cd command.echo $CDPATH
HISTFILEThe name of the file in which command history is saved.echo $HISTFILE
HISTFILESIZEThe maximum number of lines contained in the history file.echo $HISTFILESIZE
HISTSIZEThe number of commands to remember in the command history. The default value is 500.echo $HISTSIZE
HOMEThe home directory of the current user.echo $HOME
IFSThe Internal Field Separator that is used for word splitting after expansion and to split lines into words with
the read builtin command. The default value is <space><tab><newline>.
echo $IFS
LANGUsed to determine the locale category for any category not specifically selected with a variable starting with LC_.echo $LANG
PATHThe search path for commands. It is a colon-separated list of directories in which the shell looks for commands.echo $PATH
PS1Your prompt settings.echo $PS1
TMOUTThe default timeout for the read builtin command. Also in an interactive shell, the value is interpreted as
the number of seconds to wait for input after issuing the command. If not input provided it will logout user.
echo $TMOUT
TERMYour login terminal type.echo $TERM
export TERM=vt100
SHELLSet path to login shell.echo $SHELL
DISPLAYSet X display nameecho $DISPLAY
export DISPLAY=:0.1
EDITORSet name of default text editor.export EDITOR=/usr/bin/vim

set and env command

You can use the env / set command too:

 
env
env | more
set
set | more
 

Sample outputs:

HOME=/home/vivek
vivek@nas01:~$ env
TERM=xterm-256color
SHELL=/bin/bash
XDG_SESSION_COOKIE=9ee90112ba2cb349f07bfe2f00002e46-1381581541.324726-906214463
SSH_CLIENT=192.168.1.6 60190 22
SSH_TTY=/dev/pts/1
USER=vivek
MAIL=/var/mail/vivek
PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
PWD=/home/vivek
LANG=en_IN
SHLVL=1
HOME=/home/vivek
LANGUAGE=en_IN:en
LOGNAME=vivek
SSH_CONNECTION=192.168.1.6 60190 192.168.1.10 22
_=/usr/bin/env
A note about env/set command

The env will only display a list of environment variables that have been exported and it will not show all bash variables. The set command allows you to change the values of shell options and set the positional parameters, or to display the names and values of shell variables. If no options or arguments are supplied, set displays the names and values of all shell variables and functions, sorted according to the current locale, in a format that may be reused as input for setting or resetting the currently-set variables. Hence, I recommend that you use printenv command to dump the list of all shell variables on screen. To save the list of all shell environment variables to a file, enter:

 
printenv > env.txt
cat env.txt
 

Use the grep command to search for particular variable:

 
printenv | grep foo
printenv | grep HOME
 


http://www.cyberciti.biz/faq/linux-list-all-environment-variables-env-command/


As an AI language model, I do not have access to the system environment to check the installation of specific packages or software. However, the error message "allure: command not found" usually indicates that the Allure command-line tool is not installed or not added to the system PATH variable. To fix this issue, you need to install Allure and add it to the system PATH. Here are the general steps to install Allure and add it to the system PATH: 1. Install Allure: Follow the instructions provided in the Allure documentation to download and install Allure on your operating system. 2. Add Allure to the system PATH: Once Allure is installed, you need to add the Allure binary directory to the PATH environment variable. The steps to do this depend on the operating system you are using. Here are the general instructions: - Windows: Open the Start menu and search for "Environment Variables." Click on "Edit the system environment variables" and then click on the "Environment Variables" button. In the "System Variables" section, scroll down and find the "Path" variable. Click on "Edit" and add the path to the Allure binary directory (e.g., C:\allure\bin) to the list of paths. Click "OK" to save the changes. - macOS/Linux: Open the terminal and edit the ~/.bashrc or ~/.bash_profile file (depending on your system configuration). Add the following line to the end of the file: export PATH=$PATH:/path/to/allure/bin Replace "/path/to/allure/bin" with the path to the Allure binary directory. 3. Verify the installation: Open a new terminal window and type "allure --version" to verify that Allure is installed and added to the system PATH. If you still encounter the same error message after following the above steps, please provide more information about your operating system, the installation process you followed, and the exact error message you see.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值