15

I'm doing this:

sudo ln –s /etc/apache2/sites-available/LoginProject /etc/apache2/sites-enabled/LoginProject

And I get:

ln: target `/etc/apache2/sites-enabled/LoginProject' is not a directory

/etc/apache2/sites-available/LoginProject it's a file

edit:

this command:

ls -l /etc/apache2/sites-enabled/LoginProject /etc/apache2/sites-available/LoginProject

outputs:

ls: cannot access /etc/apache2/sites-enabled/LoginProject: No such file or directory
-rw-r--r-- 1 root root 526 2011-09-27 18:40 /etc/apache2/sites-available/LoginProject

edit 2:

$ls /etc/apache2/sites-available/
default  default-ssl  LoginProject
$

$ls /etc/apache2/sites-enabled/
$
fceruti
  • 225
  • 1
  • 4
  • 12
  • 1
    Can you add the `ls -l /etc/apache2/sites-enabled/LoginProject /etc/apache2/sites-available/LoginProject` output? – Belmin Fernandez Sep 27 '11 at 23:08
  • sure, there I added it – fceruti Sep 27 '11 at 23:11
  • 2
    For anyone who arrives here looking for this error, but the above solutions don't work... if you're symlinking a directory, make sure it does NOT have a trailing slash on either the target or the name. – Sherri May 30 '19 at 23:00

7 Answers7

38

You probably copied and pasted the ln -s command from another source and the system inserted the wrong type of -. Try deleting the - and typing it again manually.

chutz
  • 7,888
  • 1
  • 29
  • 59
Dr. Julie
  • 381
  • 3
  • 2
  • 2
    You saved my day with this answer! Well, half of the day. I've spent the other half pulling out the remnants of my hair trying to figure out what I was doing wrong and what directory it wants from me. It turned out that I indeed had a wrong dash in the line. – Alexander Amelkin Oct 14 '16 at 14:56
  • 1
    Great, best answer which should be accepted – The Godfather Apr 07 '17 at 13:20
8

The problem is the difference between this...

sudo ln –s path1 path2

and this...

sudo ln -s path1 path2

Don't see the difference? Short dash vs. long dash.

The long dash is not interpreted as an option and so ln sees three paths on the command line and expects the last to be a directory.

5

Try: sudo a2ensite LoginProject

You could also do sudo ln –s /etc/apache2/sites-available/LoginProject /etc/apache2/sites-enabled/

xofer
  • 3,072
  • 12
  • 19
  • The file is: __/etc/apache2/sites-available/LoginProject__ Anyway, I tried changing the order, and didn't worked – fceruti Sep 27 '11 at 23:22
  • Sorry that was wrong, see edit – xofer Sep 27 '11 at 23:23
  • Thanks! the a2ensite LoginProject worked! didn't tried the other command. It's still very weird... I really don't get it – fceruti Sep 27 '11 at 23:27
  • Normally, ln accepts 2 file paths and if it is more than two, the target must be a directory. I still wonder why it counts your parameters like this way!!! – SparX Sep 27 '11 at 23:33
3

Try ln with single argument like below and see whether it helps,

cd /etc/apache2/sites-enabled/ ; sudo ln -s /etc/apache2/sites-available/LoginProject
SparX
  • 1,924
  • 12
  • 10
2

Try quoting the directories and terminating the sudo command arguments like so:

sudo -- \ln –s "/etc/apache2/sites-available/LoginProject" "/etc/apache2/sites-enabled/LoginProject"
Belmin Fernandez
  • 10,799
  • 27
  • 84
  • 148
1

In my case I got this, confusingly, when the path of the destination (i.e. the directory to be linked to) had a space in it!

Quoting the path solved the problem.

mike rodent
  • 111
  • 3
0

In my case, I used $PWD. However, when you run the command

ln -s $PWD/myscript /usr/local/bin/myscript

then you receive the error message "error: target is not a directory" if your current path contains a space.

The solution is to use quotes:

ln -s "$PWD/myscript" /usr/local/bin/myscript