简体   繁体   中英

How can I remove symbolic link (mac)?

I'm trying to remove these symbolic links :

lrwxr-xr-x  1 root           wheel        66 Feb  1 18:53 2to3 -> ../../../Library/Frameworks/Python.framework/Versions/3.5/bin/2to3
lrwxr-xr-x  1 root           wheel        70 Feb  1 18:53 2to3-3.5 -> ../../../Library/Frameworks/Python.framework/Versions/3.5/bin/2to3-3.5
lrwxrwxr-x  1 root           admin        78 Feb  1 18:54 easy_install-3.5 -> ../../../Library/Frameworks/Python.framework/Versions/3.5/bin/easy_install-3.5
lrwxr-xr-x  1 root           wheel        67 Feb  1 18:53 idle3 -> ../../../Library/Frameworks/Python.framework/Versions/3.5/bin/idle3

and so on. For example, I'm commanding like

rm -r /Library/Frameworks/Python.framework/Versions/3.5/bin/2to3

I think this command is wrong since it doesn't work. However I can't figure out how I can make it.

It would be greatly appreciated if you could explain the details.

To delete the links, you need to delete 2to3 , 2to3-3.5 and friends. What you appear to be trying to do is deleting the destination files.

It might help to understand the difference between a hard link and a symbolic link.

A hard link is a directory entry for a filename that has the same inode as as the original file. Both names are treated as the same file by the OS and if one of the files is deleted, the OS maintains a count and so does not delete the actual file until all the last hard link is deleted. Hard links can only be made to a file in the same file system as the original file.

A symbolic link can be thought of as a tiny special file that contains the path to the file it is symbolically linked to. The OS treats that name as a link to the original file, similarly to a hard link, but there is no count maintained and the destination file can reside anywhere in the file system.

Also, the -r is a dangerous option, as it tells the rm command to remove the file all files in it and, recursively, all of its subdirectories if it is a directory itself. This can have surprisingly bad results if you are not careful.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM