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 linux deletes environment variables

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

Share

Shulou(Shulou.com)05/31 Report--

This article mainly explains "how to delete environment variables by linux". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn "linux how to delete environment variables"!

In linux, you can use the unset command to delete the environment variable, which is used to delete the variable or function with the syntax "unset variable name"; when you delete the environment variable in the unset child process, it will only affect the visibility of the current child process, not the parent shell process.

The operating environment of this tutorial: linux7.3 system, Dell G3 computer.

How to delete environment variables by linux

1. Delete global environment variables

The test_val=my_test_dog variable added in the / etc/profile file is a global environment variable, which can be deleted using the unset command, as follows:

Echo $test_valunset test_valecho $test_val

The execution result is as follows:

Tips: because the value of the test_val variable is in the file / etc/profile, after it is deleted by the unset command, you can re-use the source / etc/profile command to update the permission and get the value of the test_val variable again.

two。 Delete environment variables in the shell child process

In the shell child process, you can use the unset command to delete the specified environment variable name, as follows:

New_val= "5axxw" export new_valbashecho $new_valunset new_valecho $new_valexitecho $new_val

The execution result is as follows:

At this point, I believe you have a deeper understanding of "how to delete environment variables in linux". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

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