0

I just copied my ~/.config directory to another and symlinked it back to $HOME.

When I run ls -l this shows up like this with the double slash at the end:

lrwxrwxrwx  1 lud  lud     22 Jul 23 20:25 .config -> /home/lud/dots/config//

I cannot remember if I have seen this before. I looked at another symlinked directory to see if the same thing is happening everywhere, but the other symlinked directory only has one backslash at the end.

The symlink works. Doesn't seem like anything is broken. I'm just wondering if the extra slash means anything, or if it's even supposed to be there.

1

If you have an alias that maps ls to ls -F, it will suffix all file names according to their type.

When this option is enabled, all paths to directories are suffixed with a /. So if the symlink's target path already has one trailing backslash stored, you'll see two.

  • To see if it's the case, list your aliases with alias -p. – Kamil Maciorowski Jul 23 '18 at 19:54
2

POSIX defines:

3.271 Pathname

[…] A pathname can optionally contain one or more trailing <slash> characters. Multiple successive <slash> characters are considered to be the same as one <slash>, except for the case of exactly two leading <slash> characters.

Each one of these symlinks should work:

.config -> /home/lud/dots/config//
.config -> /home/lud/dots/config/
.config -> /home/lud/dots/config

(Although if /home/lud/dots/config was a file, only the last path would make a valid symlink).

Your symlink is what it is because it was created this way (unless this other answer applies). You apparently gave the target path with two trailing slashes and it happens to be a valid path. Note you can link to almost anything; this command

ln -s path/that//may///not/exist/foo//// baz

will create a symlink

baz -> path/that//may///not/exist/foo////

The symlink itself will most likely be broken because you don't have a directory foo/ at this path. The target's existence matters when you try to use the symlink, it doesn't matter for ln -s though. If path/that/may/not/exist/foo/ exists, the symlink will work.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.