Create Symbolic Link In Ubuntu Linux
Introduction
Symbolic link is a way to make a reference from a file, this method is used to simplify a linux user to open a file from a very long and specific path, and open it from a short path.
Example
For example, i have a file that i opened very often that is locate in : "/home/user/Documents/test/super/long/path/location /file/secret.txt". Following is an example for showing the file location :
cd ~/Documents/test/super/long/path/location/file/ && pwd
here is the result:
/home/user/Documents/test/super/long/path/location/file
then check if file "secret.txt" is exist:
ls
here is the result:
user@asus:~/Documents/test/super/long/path/location/file$ ls
secret.txt
By default, the linux terminal will open user directory "/home/user" for the default directory , and i want to open "secret.txt" file from this directory "/home/user". So all i need to do is creating the symbolic link a.k.a Symlink file. to create a new symbolic link you can use "LN" command, following is the command format to create the symbolic link:
sudo ln -s souce_file target_symlink_file
here is the command to create symlink
sudo ln -s /home/user/Documents/test/super/long/path/location/file/secret.txt /home/user/secret.txt
now lets check it out does the symlink file "secret.txt" exist, first, lets get back to the default directory by typing:
cd ~
and run this command to check files existing:
ls secret.txt
here the result:
user@asus:~$ ls secret.txt
secret.txt
now lets open the file "secret.txt" by typing:
nano secret.txt
and here is the result:
Komentar
Posting Komentar