To be more precise: I know what the -s options stands for - I use it daily. But I saw someone in a tutorial, who was moving the document root of his website from /var/www/html/project to ~/www/project to increase security (he later on changed the rights and so on, but's that not significant in this context). Then he created the following symlink:

ln -sT ~/www/project /var/www/html/project

I was wondering what the -T is for, because normally I would have just used -s. From the man page I get the following sparse information regarding the -T option:

-T, --no-target-directory
     treat LINK_NAME as a normal file always

I don't really understand what this is for. Why should I use -T in conjunction with -s when creating a symlink? Is there any great benefit from doing so?

2 Answers 2


ln’s synopsis is as follows:

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)

Without -T, if LINK_NAME already exists and is a directory (or symlink verified to eventually resolve to a directory), the first and third forms are ambiguous, and ln chooses the third form: it creates the link inside the directory. Thus

ln -s ~/www/project /var/www/html/project

will create a link named project inside /var/www/html/project if the latter already exists.

-T removes the ambiguity, and forces ln to consider the first form only: if the link doesn’t exist, the link is created as named; if there is already a file or directory with the given LINK_NAME, ln fails with an error (unless -f is specified too).


ln -sT ~/www/project /var/www/html/project

guarantees that you end up either with a link /var/www/html/project pointing to ~/www/project, or with an error message (and non-zero exit code).


It makes sure your path (in your example /var/www/html/project) is the final path, so the link will 100% be /var/www/html/project and not /var/www/html/project/**project** if /var/www/html/project exists...

Because this might be confusing, showing the example of difference

Setup: cd /tmp; mkdir /tmp/aa; mkdir /tmp/bb;

ln -s /tmp/aa /tmp/bb will result in new symlink /tmp/bb/aa -> /tmp/aa


ln -sT /tmp/aa /tmp/bb will result in ln: failed to create symbolic link '/tmp/bb': File exists

the -s parameter has nothing to do with it. It is (as usual) explained in thedocs: https://www.gnu.org/software/coreutils/manual/html_node/Target-directory.html

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .