What causes ln: //: Is a directory?
14,746
In pathname resolution, having a trailing /
is equivalent to a trailing /.
— in other words, ~/inbox/
is equivalent to ~/inbox/.
in this context. So the ln
command is trying to create a link called .
in the root directory (and, unsurprisingly, failing).
Zsh removes the trailing /
when you press Space after completing a directory (unless configured not to do so). I don't know if bash can be made to do this.
Related videos on Youtube
Author by
iamgato
Updated on September 18, 2022Comments
-
iamgato almost 2 years
When linking a directory to root, I get this error:
$ ln -s ~/inbox/ / $ ln: //: Is a directory
Bash autocompletes the directory path by adding a /. I've tried escaping without success.
$ ln -s ~/inbox /
works though. Why is this?
-
jsbillings about 12 yearsWhat OS is this? Is it GNU Coreutils, or the BSD utils?
-
Mikel about 12 yearsI don't think it's coreutils. My version puts the file name in quotes, e.g.
ln: 'foo': hard link not allowed for directory
.
-
-
jippie about 12 yearsI think it is good to explain what
cd $(mktemp -d)
does. Not everybody is familiar with this construction. -
Mikel about 12 yearsIt creates a new directory somewhere under
/tmp
. It makes sure that the files I'm using in my examples don't already exist so that everyone can get try running the commands and get the same results. -
Mikel about 12 yearsVery interesting.
Pathname resolution
also says that symlinks should be resolved. But when you doln symlink blah
,blah
should point tosymlink
, not whatsymlink
points at.