Creating a symlink from one folder to another with different names?

From man ln:

By default, each destination (name of new link) should not already exist.

As you already have a directory named html, the link will be created inside /var/www/html having the name of the target i.e. project.

If you want to have a symlink /var/www/html pointing to /home/user/project then you should not have the directory html present beforehand. So, you should only have /var/www and then running the following will create the desired symlink (don't do this unless you are sure):

ln -s /home/user/project /var/www/html

Here is an example:

$ pwd
/home/user/test/askubuntu

$ ls -l
total 4
drwxrwxr-x 2 user user 4096 Mar 25 00:16 foo

$ ln -s /home/user/test/bar /home/user/test/askubuntu/foo

$ ls -l
total 4
drwxrwxr-x 2 user user 4096 Mar 25 00:17 foo

$ cd foo/
$ ls -l
total 0
lrwxrwxrwx 1 user user 25 Mar 25 00:17 bar -> /home/user/test/bar

$ cd ..
$ rm -r foo/

$ ls -l
total 0

$ ln -s /home/user/test/bar /home/user/test/askubuntu/foo

$ ls -l
total 0
lrwxrwxrwx 1 user user 25 Mar 25 00:18 foo -> /home/user/test/bar

And yes, you can create symlinks of hidden files.


Make sure html directory is not created under /var/www/.

The command then is: ln -s -T /home/user/project /var/www/html