Should I include a routing lower/ in a symlink to a directory?

Symlinking to a directory provides to various outcomes with ls -l relying on whether I ln -s dir or ln -s dir/. Yet what is the real distinction, and also which one should I favor why?

0
2019-05-18 22:18:39
Source Share

Interesing inquiry. I've made tiny examination:

$mkdir dir$ ln -s dir/ test_slash
$ln -s dir test_noslash$ ls -l
total 4
drwxr-xr-x 2 vrusinov vrusinov 4096 Feb 21 16:41 dir
lrwxrwxrwx 1 vrusinov vrusinov    3 Feb 21 16:41 test_noslash -> dir
lrwxrwxrwx 1 vrusinov vrusinov    4 Feb 21 16:41 test_slash -> dir/
$strace ls test_slash 2> trace_slash$ strace ls test_noslash 2> trace_noslash
$wc -l trace_* 79 trace_noslash 79 trace_slash$ diff -u trace_* | less


As you can see, there is no distinction in variety of system calls (at the very least for ls) and also traces looks really comparable. Howewer, this is simply unload examination and also I'm not exactly sure - there could be some distinctions.

0
2019-05-21 07:16:17
Source

The only point I can consider is that it "shields" you from a person removing the directory and also developing a documents.

[[email protected] linktest]$mkdir test [[email protected] linktest]$ ln -s test/ slash
[[email protected] linktest]$ln -s test noslash [[email protected] linktest]$ ls -l
total 4
lrwxrwxrwx 1 paul paul    4 Feb 21 21:00 noslash -> test
lrwxrwxrwx 1 paul paul    5 Feb 21 21:00 slash -> test/
drwxrwxr-x 2 paul paul 4096 Feb 21 20:59 test
[[email protected] linktest]$file *slash noslash: symbolic link to test' slash: symbolic link to test/' [[email protected] linktest]$ rmdir test
[[email protected] linktest]$file *slash noslash: broken symbolic link to test' slash: broken symbolic link to test/' [[email protected] linktest]$ touch test
[[email protected] linktest]$file *slash noslash: symbolic link to test' slash: broken symbolic link to test/' [[email protected] linktest]$


The variation with the lower breaks when the target is changed with a documents.

0
2019-05-21 07:01:43
Source

There's no difference. (There would certainly be a distinction if the target was not an existing directory.)

The last lower could have wound up there as a result of covering conclusion: with some arrangement, ln -s tarTabSpacelink finishes to ln -s target/ link.

0
2019-05-21 05:45:02
Source