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

4

12

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?

Barringer answered 9/7, 2013 at 20:24 Comment(1)
The arrow indicates that libcrypto.so is (was) a symbolic link. Renaming it will break any binary (or other shared library, or build program, or ...) that looks for that shared library by the name libcrypto.so.Averroism
P
16

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.

Plebiscite answered 9/7, 2013 at 20:31 Comment(1)
Thank you for the answer. All these files are linked together. How do I edit this link? For example, it's like this: A->B. B->C. C. But now I change the name of C to D and that broke all the links. A & B become empty. How do I make it so that B->D?Barringer
C
12

-> means libpmcrypto.so is a Symbolic link and the information stored in libcrypto.so.0 is accessible through the libpmcrypto.so file.

How to create a symbolic link:

ln -s [TARGET DIRECTORY OR FILE] ./[SHORTCUT]

for example:

ln -s /usr/local/apache/logs /home/el/logs

If you delete the soft link itself (/home/el/logs), the file (/usr/local/apache/logs) would still be there.

How to find symbolic links:

find ./ -type l

read man ln for more information on links.

Codycoe answered 9/7, 2013 at 20:31 Comment(0)
C
1

ls -la will display files pointing to module using symbolic links

For example in your library directory you have file pointing to the .so files (shared object).

This means it does not need to be recompiled. You have no easy way of telling how files are linked.

Cravens answered 9/7, 2013 at 20:25 Comment(0)
H
1

Yes that does changes something, in fact you shouldn't change a shared library because when a 3rd-party program tries to call libcryto.so its not going to be there any more.

But if you're sure you want to change the name, I would recommend you to call nautilus in superuser mode:

sudo nautilus /THE/FOLDER/WHERE/YOUR/FILE/IS

And edit it manually, by adding .0 to the end of the symlink name. You're changing part of its name so whenever a program tries to call it, its not going to be able to locate it.

Huntsville answered 9/7, 2013 at 20:33 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.