Questions and suggestions are always welcome.Ln creates a link to file TARGET with the name LINKNAME. I do hope you learned to use the ln command effectively in this tutorial. I highly recommend reading the following articles that relate to links concept in Linux: Just look in the /lib directory and you'll see plenty of soft links. You'll find them used at many places in your systems. This way, the program can be run from anywhere on the system and the executable of the program remains in its original program folder. This is where you can create a link to this executable file in the /usr/bin directory. If you move the executable to this directory, it may not work as it needs to access some of the code and it won't find the path to these files from the /usr/bin directory. But to run the program from anywhere, you need to put its executable in the /usr/bin directory. You keep the entire thing in the /opt directory. Let's say you downloaded a software that comes with its code and an executable file. Now that you know how to create links, let's briefly why do we need links? What practical purpose do they serve? This image explains the example better: Why do we need links? The -f options stands for 'follow' as in 'follow the chain'. To find the original file from a chain of links, you can use the readlink -f in the following fashion: readlink -f soft_link In the long listing, the second link will point to first link. For example, you create a link to a file and then create another link to the first link. Normally, when you use the ls command with the -loption, it shows the file it points to.īut if there is chain of links, it won't show the original file. Bonus Tip: Getting the original file following a chain of links Mind to add the s for soft link otherwise you'll convert the soft link to hard link. Here's what you can do: ln -sf new_file existing_soft_link Suppose, you want to force update a symbolic link.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |