How to create a folder symlink that has a different name?
You already have a directory at ~/.pm2/logs
. Since that directory exists, the symbolic link is put inside it.
Would you want that ~/.pm2/logs
is a symbolic link rather than a directory, then you will have to remove or rename that existing directory first.
As other answers say, there is already a directory there.
To avoid this and instead get an error-message, use the -T
option, unfortunately I don't think this is Posix (it is GNU).
From the Gnu ln
manual (same for cp and mv).
ln [OPTION]... [-T] TARGET LINK_NAME (1st form)
ln [OPTION]... TARGET (2nd form)
ln [OPTION]... TARGET... DIRECTORY (3rd form)
ln [OPTION]... -t DIRECTORY TARGET... (4th form)
Note form 1 without the -T
is ambiguous with form 3 (both have two arguments).
In Posix you can force this non-ambiguity by putting a /
at the end of a directory name, in form 3, but I don't think there is any thing you can do the other way around. This is why Gnu added the -T
option.
Remove the ~/.pm2/logs directory first, because your target is an existing directory, the link is created inside it.