Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
TARGET = the real file you want the symbolic link to point to
DIRECTORY = the path (and optionally the name) of the symbolic link itself
As an example: ln -s /home/someuser/docs/something_important.txt /home/user2
That would create a symbolic link in /home/user2. The real file is /home/someuser/docs/something_important.txt. In this case, the symbolic link's name will also be something_important.txt
One more example: ln -s /home/someuser/docs/something_important.txt /home/user2/something_stupid.txt
The real file remains the same, the directory the symbolic link is in remains the same, but the symbolic link's name is now something_stupid.txt.
Also, I'm using absolute paths to the real file. That's generally considered bad (because it's not very portable). They will work though. You could use relative paths instead, like: ln -s ../someuser/docs/something.txt /home/user2/something_stupid.txt
In that command, the target is relative to the location of the link itself. In other words, it's saying, start in /home/user2, create a link named something_stupid.txt, have it point to a file one directory up (/home) & in subdirectory someuser/docs named something_important.txt. Using this method, you can move directories and the symbolic links won't break. If I confused you with that last one, just ignore it. You'll catch on soon enough.
Last edited by Dark_Helmet; 01-14-2005 at 09:15 PM.
I do want to clarify something though. Using relative links, you have limited ability in moving directories around. As long as the relative path remains unchanged, it will work. For instance, you could move the directories in /home to /home/backup, and it will still work. In other words, going from this:
/home/someuser
/home/user2
to this:
/home/backup/someuser
/home/backup/user2
After re-reading my original post, I was afraid I gave the impression that directories could be moved in any manner. That is not the case. There are limitations, but it's more flexible than using absolute paths.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.