Linux comman line: how to create a symbolic link

March 16, 2010

A symbolic link it is a kind of shorcut to a file.If you are working in a /XXXXX/ directory and you want to execute a file which is in /YYYY/ directory, instead of write…./YYYYY/file_name you can just create a symbolic link of file_name to /XXXXX/ directory so you can execute the file as if it is in /XXXXX/ directory.

Let’s take a look from wikipedia:

In computing, a symbolic link (also symlink or soft link) is a special type of file that contains a reference to another file or directory in the form of an absolute or relative path and that affects pathname resolution. Symbolic links were already present by 1978 in mini-computer operating systems from DEC and Data General’s RDOS. Today they are supported by the POSIXUnix-like operating systems, Windows Vista, Windows 7 and to some degree in Windows 2000 and Windows XP. operating-system standard, most

Symbolic links operate transparently for most operations: programs which read or write to files named by a symbolic link will behave as if operating directly on the target file. However, programs that need to handle symbolic links specially (e.g., backup utilities) may identify and manipulate them directly.

A symbolic link merely contains a text string that is interpreted and followed by the operating system as a path to another file or directory. It is a file on its own and can exist independently of its target. If a symbolic link is deleted, its target remains unaffected. If the target is moved, renamed or deleted, any symbolic link that used to point to it continues to exist but now points to a non-existing file. Symbolic links pointing to non-existing files are sometimes called broken, orphaned or dangling.”

Sintaxis:

…$ ln -sf path_to_real_file_location   path_to_symbolic_linx

Example:

I want to execute the file startup.sh which is in ….Documents from my Desktop:

.…$ ln -sf  /…./Documents/startup.sh  /…../Desktop

Now in Desktop you will see startup.sh like if the file is there but is not, it is just a link to the file.

Good luck!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: