Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Linux: The command ls -la shows a file pointing to another file. What does that mean?

Tags:

bash

symlink

ls

When I type ls -la to list all the files, I see this:

11 Jul  9 12:04 libcrypto.so -> libcrypto.so.0

I tried to change the name of libcrypto:

mv libcryto.so libpmcrypto.so

And now it shows:

11 Jul  9 12:04 libpmcrypto.so -> libcrypto.so.0

Does that affect anything? And what does the arrow mean?

like image 372
Dao Lam Avatar asked Jul 09 '13 20:07

Dao Lam


Video Answer


1 Answers

The file in question is a symbolic link. This is conceptually similar to the idea of a shortcut, but it appears to be the real file if you use it (Open it, copy it, etc.). The symbolic link is another name that "points to" the real file. When you do ls -l it also shows you which file is pointed to by the link. Renaming the link has no effect on the original file, but may break things that rely on the link name, just as with any other file name. Deleting the link just removes the pointer, and has no effect on the original file. Deleting the original file will leave the link in a "broken state" where the link points to nothing.

Edit You can't really edit what symbolic links point to. You can delete them with rm and then recreate them with the ln -s command. Take a look at the man pages for more information.

like image 154
Ian McLaird Avatar answered Oct 24 '22 19:10

Ian McLaird