Friday, July 2, 2010

Creating and Editing Symbolic Links

Creating a Symbolic Link
To create a symbolic link, you can use the ln command. Usage is as follows:

ln -s targetFile symbolicLinkName

For example, to create a symbolic link named "mylink" in the current folder that targets the executable file "/usr/java/default/bin/java", execute the following command in your terminal:

ln -s /usr/java/default/bin/java mylink

Changing the target of a Symbolic Link without deleting the file

You can also use the ln command to change the target of an existing symbolic link by using ln's -f option. Usage is as follows:

ln -f -s newTargetFile symbolicLinkName

For example if you want to change the target of the symbolic link "/home/user/mylink" to "/usr/bin/gedit", execute the following command in your terminal:

ln -f -s /usr/bin/gedit /home/user/mylink

1 comment: