Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to view environment variables in linux

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article is about how to view environment variables in linux. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

Methods: 1, use the echo command to display known environment variables, syntax "$echo variable"; 2, use env command to display all environment variables, syntax "$env"; 3, use set command to display all locally defined Shell variables, syntax "$set".

The operating environment of this tutorial: centos7 system, thinkpad T480 computer.

Show known environment variables

Such as:

$echo $HELLO echo $JAVA_HOME

Display all environment variables with the env command

$env

Display all locally defined Shell variables with the set command

$set

Clear environment variables with the unset command

Set can set the value of an environment variable. Clear the value of the environment variable with the unset command. If no value is specified, the variable value is set to NULL. Examples are as follows:

$export TEST= "Test..." # add an environment variable TEST $env | grep TEST # this command is entered to prove that the environment variable TEST already exists TEST=Test... $unset $TEST # Delete the environment variable TEST $env | grep TEST # this command has no output, which proves that the environment variable TEST already exists

Set read-only variables with the readonly command

Variables cannot be modified or cleared if the readonly command is used. Examples are as follows:

$export TEST= "Test..." # add an environment variable TEST $readonly TEST # set the environment variable TEST to read-only $unset TEST # and you will find that this variable cannot be deleted-bash: unset: TEST: cannot unset: readonly variable $TEST= "New" # will find that this variable cannot be modified-bash: TEST: readonly variable What is a Linux system Linux is a free-to-use and free-spread UNIX-like operating system Is a POSIX-based multi-user, multi-tasking, multi-threaded and multi-CPU operating system, using Linux to run major Unix tools, applications and network protocols.

Thank you for reading! This is the end of the article on "how to view environmental variables in linux". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report