Re: Strange behaviour of ln

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 24Aug2015 13:55, Paolo Galtieri <pgaltieri@xxxxxxxxx> wrote:
I've tried this on 2 different systems, and on both systems ln -s fails in the same way.

Here's the steps

mkdir Test
cd Test
afile
cd ..
ln -s Test/afile Test/afile2
ls -l Test

This is the output:
/bin/ls: cannot access Test/afile2: No such file or directory
total 0
-rw-rw-r--. 1 pgaltieri pgaltieri 0 Aug 24 13:46 afile
l?????????? ? ?         ?         ?            ? afile2
[...]

Firstly, run "/bin/ls", not "ls". Many system ship with an alias called "ls" with presupplied various options, which is misleading. IMO this is a terrible idea - the alias should at least use another name. (I have ones called "l" and "L" for these conveniences, myself.)

To your problem:

Symlinks are strings resolved with respect to the directory in which the symlink exists.

So the example above "Test/afile" => "Test/afile2" makes a symlink _in_ the directory "Test" named "afile2" pointing at "Test/afile". Therefore it tries to access the path "Test/Test/afile", which fails as one might expect.

When making a symbolic link it needs to either be (a) an absolute path or (b) relative WRT to the directory hodling the link. For the latter, the reliable way is to cd to the directory and make in from inside. That way command line filename completion prodcues working results.

Cheers,
Cameron Simpson <cs@xxxxxxxxxx>

Unix is user-friendly. It's just picky about who its friends are.
--
users mailing list
users@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Fedora Code of Conduct: http://fedoraproject.org/code-of-conduct
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines
Have a question? Ask away: http://ask.fedoraproject.org



[Index of Archives]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [EPEL Devel]     [Fedora Magazine]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Desktop]     [Fedora Fonts]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Fedora Sparc]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux