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 delete directory soft connection under Linux

2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This article mainly introduces "how to delete directory soft connection under Linux". In daily operation, I believe many people have doubts about how to delete directory soft connection under Linux. Xiaobian consulted all kinds of information and sorted out a simple and easy-to-use method of operation. I hope it will be helpful to answer the doubt of "how to delete directory soft connection under Linux". Next, please follow the editor to study!

Experimental environment:

Create a directory 1 under the root directory, and create a file for 2.txt under that directory, and write the contents 1.txt:

[root@server ~] # mkdir 1 [root@server ~] # echo 1.txt > 1/2.txt [root@server ~] # tree 11 └── 2.txt

SECTION 1: if there is no "/" after the directory, only the directory with soft links will be deleted, and the structure of the source directory will remain unchanged.

1. Make a directory soft link, and link the created test directory 1 to the / tmp directory:

[root@server ~] # ln-s / root/1 / tmp/ [root@server ~] # ls-l / tmp/1lrwxrwxrwx 1 root root 7 Jan 26 15:53 / tmp/1-> / root/1

2. Perform the deletion operation:

[root@server ~] # rm-rf / tmp/1 [root@localhost ~] # ll / tmp/ total dosage 0

3. View the source directory structure:

[root@server ~] # tree 11 └── 2.txt

SECTION 2: if the directory is followed by "/", all files in the original directory will be deleted, but the soft connection directory will not be deleted.

1. Make the directory soft link again, and link the test directory 1 you created to the / tmp directory:

[root@server ~] # ln-s / root/1 / tmp/ [root@server ~] # ls-l / tmp/1lrwxrwxrwx 1 root root 7 Jan 26 15:56 / tmp/1-> / root/1

2. Perform the deletion operation:

[root@server ~] # rm-rf / tmp/1/ [root@server ~] # ls / tmp/1 systemd-private-ba67187ff35444d0bf13da73ea656d0e-httpd.service-0ea0u7

3. View the source directory structure:

[root@server ~] # tree 11 at this point, the study on "how to delete directory soft connections under Linux" is over. I hope I can solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

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

Development

Wechat

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

12
Report