You may sometimes need to create or delete symbolic links in Linux. If so, do you know what to do? Have you done this before? Have you fallen into any trap? If you've made mistakes, that's fine. If you haven’t, don’t worry, we’re here to help you. The operation of removing (deleting) symbolic links can be accomplished using the rm and unlink commands. What is a symbolic link? A symbolic link (symlink), also known as a soft link, is a special file type that points to another file or directory in Linux. It is similar to a shortcut in Windows. It can refer to a file or directory in the same or a different file system or partition. Symbolic links are usually used to link library files. It can also be used to link log files to folders on mounted NFS (Network File System). What is rm Command? The rm command is used to remove files and directories. It is very dangerous and you should be very careful every time you use the rm command. What is unlink command? The unlink command is used to remove specific files. It is installed as part of GNU Gorutils. 1) How to remove symbolic link files using rm command The rm command is the most frequently used command in Linux, which allows us to remove symbolic links as described below. Always use the rm command with -i to understand what is being done. # rm -i symlinkfile1 rm:remove symbolic link 'symlinkfile1'?y It allows us to remove multiple symbolic links at once: # rm -i symlinkfile2 symlinkfile3 rm:remove symbolic link 'symlinkfile2'?y rm:remove symbolic link 'symlinkfile3'?y 1a) How to remove a symbolic link directory using rm command This is like removing a symbolic link file. Use the following command to remove the symbolic link directory. # rm -i symlinkdir rm:remove symbolic link 'symlinkdir'?y Use the following command to remove multiple symbolic link directories. # rm -i symlinkdir1 symlinkdir2 rm:remove symbolic link 'symlinkdir1'?y rm:remove symbolic link 'symlinkdir2'?y If you add a / at the end, the symbolic link directory will not be deleted. If you add it, you will get an error. # rm -i symlinkdir/ rm: cannot remove 'symlinkdir/': Is a directory You can add -r to deal with the above problems. But if you add this parameter, it will delete the contents of the target directory and it will not delete the symbolic link file. (LCTT translation note: This may not be your original intention.) # rm -ri symlinkdir/ rm:descend into directory'symlinkdir/'?y rm:remove regular file 'symlinkdir/file4.txt'?y rm:remove directory'symlinkdir/'?y rm: cannot remove 'symlinkdir/': Not a directory 2) How to remove symbolic links using unlink command The unlink command deletes the specified file. It accepts only one file at a time. Delete the symbolic link file: Delete the symbolic link directory: If you add / at the end, you cannot remove the symbolic link directory using the unlink command. # unlink symlinkdir3/ unlink: cannot unlink 'symlinkdir3/': Not a directory Summarize The above is the command for removing (deleting) symbolic links in Linux introduced by the editor. I hope it will be helpful to everyone. If you have any questions, please leave me a message and the editor will reply to you in time. I would also like to thank everyone for their support of the 123WORDPRESS.COM website! You may also be interested in:
|
<<: vue-cli4.5.x quickly builds a project
>>: The latest MySQL 5.7.23 installation and configuration graphic tutorial
HTML5 and jQuery implement the preview of local i...
Enter ssh and enter the following command to rese...
Table of contents 1. Introduction 2. About vue-si...
Author | Editor Awen | Produced by Tu Min | CSDN ...
What products do you want to mention? Recently, t...
Tencent QQ’s homepage has been redesigned, and Web...
This article shares the specific code of JavaScri...
System environment: Windows 7 1. Install Docker D...
This article records the installation and configu...
1》Be good at web design 2》Know how to design web p...
Use scenarios: The project's pages need to lo...
In this article, we sorted out the startup proces...
method: By desc: Neither can be achieved: Method ...
View the installation information of mysql: #ps -...
SQL statement /* Some methods of eliminating dupl...