Creating Symbolic Links

For convenience, you can create a symbolic link in your account which points to a file in a different location. This
would be useful if you wanted view or edit a file in a different location, but didn’t want to specify the full path.

For example, let’s say you had the following two directory structures in your account:

1994 1995
April April
15 15
total total

 

If you were viewing the file called total under the 1994
directory, and decided you wanted to view the file called total under 1995, you would have to type:

more ../../../1995/April/15/total

Or, you could create a link called total95 in the 1994
directory which points to the file called total under the 1995 directory.

To create a symbolic link, type:

ln -s &ltexisting_file> &ltlink_name>

Using the above example, from your home directory, you would type:

ln -s 1995/April/15/total 1994/April/15/total95

This example will create a link called total95 under the 1994 directory stucture which points to the file called

total under the
1995 directory structure. You could then easily edit and view the total file in the 1995 directory from

the 1994 directory by typing:

more total95

Directory Links

You can create a symbolic link in your account which points to a directory in a different location. This would be
useful if you wanted to change to a directory in a different location but didn’t want to specify the full path.

For example, let’s say you constantly change to the following directory by typing:

cd ~itp101/assignments/homeworks/programs/prog1

Instead of typing in the full path everytime you wanted to change to this directory, you could create a link in your
account called itpprog1 which points to the above directory.

To create a symbolic link, type:

ln -s &ltexisting_directory> &ltlink_name>

Using the above example, from your home directory, you would type:

ln -s ~itp101/assignments/homeworks/programs/prog1 itpprog1

This example will create a link called itpprog1 in your home directory which points to
the prog1 subdirectory in the <itp101> account. You could then easily change to the
prog1 subdirectory in the <itp101> account from your home directory by typing:

cd itpprog1

For more information on links, type man ln at the UNIX prompt.