I am trying to setup a symbolic link on my CentOS 5.6 machine to point dev_crmpicco/ to ~/vhosts/dev/dev_crmpicco/web/

I am using the following command:

[crmpicco@devel dev]$ ln -s ~/vhosts/dev/dev_crmpicco/web/ dev_crmpicco/

However, I get this error:

ln: creating symbolic link `dev_crmpicco/web' to `/home/crmpicco/vhosts/dev/dev_crmpicco/web/': File exists

I'm aware the file exists as I want dev_crmpicco/ to point to it.

Basically, my DOCROOT used to be in dev_crmpicco/ but now it is all moved into a web/ directory and I don't want to have to go round changing all my Apache config and i'd rather do it through a symlink if at all possible.

2 Answers 2


You should check if dev_crmpicco/web exists from a previous attempt to link (or from copying instead of moving). You would have to remove that if it exists (whether file, link or directory) as that is what you command tries to create.

After checking that try:

ln -s ~/vhosts/dev/dev_crmpicco/web/ dev_crmpicco

without the trailing / as @Johan suggested.


If you specify a directory explicitly as the target (eg by supplying the trailing / after dev_crmpicco/, as you do in your example, then the link will be created with the same name (web in this case) inside that directory (and a missing directory is an error in this situation)

ln -s path/target link/

will create

link/target -> path/target

Do not supply the trailing slash if you want dev_crmpicco to be the link to the original. In this case the link will be named dev_crmpicco and if a file or directory with that name exists, it is an error.

Either ways you will have to rename or delete the existing files/directories before creating the link.

ln -s path/target link

will create

link > path/target

You must log in to answer this question.

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