FORMAT:
ln -s path/to/directory link_name

The links you created in the prvious post, listed the actual inodes for a file in two direcoties. Links created in this way are called hard links because the inode is hard-coded into the various direcotries that list the file. As will be examined later, hard links do not work for some files, and only the supersuer can create har dlinks for directories.

A method for linking an existing file to another directory does not list the linked files' inode in the decond directory.

ok, to lets say i want to link directory: /var/www/html/web1 to /var/www/html/web2 so when you visit web2, the actual content of web1 will be shown, this is how you do it:

1. make sure you are in the html directory, if you are not sure send this command:
CODE:
cd /var/www/html


2. Once you are in the html directory, send this command to double check:
CODE:
pwd
You should see somthing like this:
CODE:
[[email protected] html]# pwd
/var/www/html



3. Now that you are defenetly certain that you are in the correct directory, send this command to do display the current files in the html directory to make sure that web1 directory exists:
CODE:
ls
Then you should see something like this:
CODE:
[[email protected] host]# ls
web1


4. Now send the command to link web1 and create the web link with this command:
CODE:
ln -s /var/www/html/web1 /var/www/html/web2


5. After you have executed the ln command, confirm that the web2 symbolic link has been created with this command:
CODE:
ls -l
You shold see semething like this:


. Now confirm that you have created the link by listing the files, send this command:
CODE:
ls -l

You should see something like this:
CODE:
[[email protected] html]# ls -la
total 20
drwxr-xr-x  3 root root 4096 Nov 17 15:48 .
drwxr-xr-x 72 root root 4096 Oct 26 17:38 ..
drwxr-xr-x  2 root root 4096 Nov 17 15:41 web1
lrwxrwxrwx  1 root root   18 Nov 17 15:48 web2 -> /var/www/html/web1
The important thing to notice here is on the web2, you will see a -> (arrow) indication to where the web2 is actually linking, in this case its linking to /var/www/html/web1, which is exactly what we want. So from now on, any visitor going to web2, will actually be seeing the content on web1.

If you want more information, you can send this command for the ln manual:
CODE:
man ln
Then you should see something like this:


ln - make links between files

SYNOPSIS
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)

DESCRIPTION
In the 1st form, create a link to TARGET with the name LINK_NAME. In the 2nd form, create a link to TARGET in
the current directory. In the 3rd and 4th forms, create links to each TARGET in DIRECTORY. Create hard links
by default, symbolic links with --symbolic. When creating hard links, each TARGET must exist.

Mandatory arguments to long options are mandatory for short options too.

--backup[=CONTROL]
make a backup of each existing destination file

-b like --backup but does not accept an argument

-d, -F, --directory
allow the superuser to attempt to hard link directories (note: will probably fail due to system restric-
tions, even for the superuser)

-f, --force
remove existing destination files

-n, --no-dereference
treat destination that is a symlink to a directory as if it were a normal file

-i, --interactive
prompt whether to remove destinations

-s, --symbolic
make symbolic links instead of hard links

-S, --suffix=SUFFIX
override the usual backup suffix

-t, --target-directory=DIRECTORY
specify the DIRECTORY in which to create the links

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

-v, --verbose
print name of each file before linking

--help display this help and exit

--version
output version information and exit

The backup suffix is â~â, unless set with --suffix or SIMPLE_BACKUP_SUFFIX. The version control method may be
selected via the --backup option or through the VERSION_CONTROL environment variable. Here are the values:

none, off