[SOLVED] Why can't I access any symbolic links that I create to what they're pointing?
Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
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.
There is less than 12 hours left to vote in the 2015 LinuxQuestions.org Members Choice Awards. Click here to go to the polls. Vote now and make sure your voice is heard!
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
Why can't I access any symbolic links that I create to what they're pointing?
Hi, this is a bit noob, but everytime I try to create softlinks to some files/dirs, I can't access them, I either get "Too many symlinks" (or something) or "No such file/dir". I'm pretty sure that I typed the addresses correctly.
I just have some songs, in my ext4 data drive, that I want to link to my ~/music dir.
Note that when I create the links in that dir, and go to that dir with midnight commander, they're colored in red. (broken?)
Yes... that was it. But why? I mean, in mc, you know there are 2 panels, in the right panel, I was sitting in my songs dir, which is
'/mnt/d/SNG' and on the left, I was in '~/temp'. From the right panel, I did the linking (the way I wrote above), and in temp, I see that they are red...
The link will be created in the destination using the exact name and path you specify. This means that the path you specify to the source must be the path when viewed from the destination. Relative paths are fine, but they must be relative from the destination dir, not from where your pwd is. See this thread for more info:
HAHA! I just fixed my problem, wrote a script for that linking, hope somebody will find it useful:
3 # What's this?
4 # This will let you link, more than one file/dir from your current working dir to dest, without having to specify the whole path
5 # which is relative to the destination.
6 # Example:
7 # /mnt/drive/music $> ls
8 # /mnt/drive/music $> song1 song2 song3 some album.1 some album.2
9 # /mnt/drive/music $> slink ~/music song* some\ album.1 some\ album.2
10 # This will link all the 3 songs and the other 2 files, to ~/music, that was fast, huh?
12 # $# is the number of args passed to the script.
13 let args=$#;
14 usage="Usage: slink <destination> file(s)/directory(ies)\nThe file(s)/dir(s) in the 2rd arg, should be in your current working directory.
15 if the 2nd arg isn't specified, current working directory will be linked to destination."
16 if [ "$args" -lt 1 ]
18 echo -e $usage; #using -e will let echo process the escaping character, otherwise, it'll just print them.
19 exit 1;
24 if [ "$args" == 1 ]
26 ln -s $source $dest;
28 for file in "$@"
30 if [ "$file" == "$dest" ];then
33 ln -s $source/"$file" $dest; # DON'T YOU FORGET ABOUT THE QUOTES!!! Otherwise, spaces will be ignored.
@grail: Mmm, mostly because, if anything will have spaces, it will be $file. Most of my directories doesn't have spaces.
So yes, to make it bullet-proof, surround $source and $dest with quotes as well, it's better, it won't hurt.
Thanks for pointing it out :-)
@chrism01: I agree, underscores saves you a lot of headaches, maybe I'll make some script, that replaces the spaces, you have in your files in some dir...