Thursday, June 2

Quick Linux Question: Which file is the real file?


Question:

How can I tell which executable is the real binary file?





Answer:    use "ls -l"

The Linux file system has the possibility to create symbolic link files. Symbolic link files are a lot like Microsoft Window's shortcut files. That they create a file at a specific location which is actually located in a different location. The most common reason for creating a symbolic linked file is so you can have a binary file accessible from multiple locations without having to actually duplicate the binary file.

If you come across a time when you notice you have the same file located in multiple locations, it can be very handy to tell which of the files is the actual binary file, and which is the symbolic link file.

example:

which -a nano

This command shows that the file "nano" appears to be located in two separate locations. One of these is the actual binary file, and the other one is only a link to that file.




ls -l /usr/bin/nano

Using the "-l" option of ls we are able to display the link between the files. Notice that it shows that the file "/usr/bin/nano" is linked to the file actually located at "/bin/nano"




ls -l /bin/nano

Now if you use the same option on a file that is not a symbolic link file, ls is smart enough to just show you the file details, as displayed in the image bellow.


0 comments :

Post a Comment