Question about the symlink of the ln command
Let say you have a file named /home/george/Images/ubuntu.jpg
and you want it to be available too in the /var/tmp
directory, you can run:
ln -s /home/george/Images/ubuntu.jpg /var/tmp
Then, you can equally view the file using the /var/tmp/ubuntu.jpg
path.
Beware not to miss to provide a correct relative or absolute path for the first parameter passed to the link command. This path is relative to the directory where the symbolic link resides. This is a common source of mistakes, like Nitin reply demonstrates.
Related videos on Youtube
George Luong
Updated on September 18, 2022Comments
-
George Luong over 1 year
Can anybody give me an example why should we use the symlink kind of the "ln" command between files? I know that when you create symlink file, that file size is very small and it redirect to the main file.
The problem is when I created the symlink from a specific file (text file) from another directory, but I can't cat, less or any kind of print and view that file. Pls help me understand more about this type.
Thanks.
-
jlliagre almost 11 yearsIt would help if you post the precise command(s) you typed. I suspect a path error.
-
-
jlliagre almost 11 yearsYour command created a wrong symbolic link, i.e. you linked
/pool0/manager/orig.txt
to/pool0/manager/link.txt
. The first file doesn't exist. This has nothing to do with the same file-system limitation that doesn't affect symbolic links anyway. -
Nitin almost 11 yearsfile orig.txt lies in / while symlink lies in other partition /pool0/manager/link.txt which i tested.
-
jlliagre almost 11 yearsAs you wrote the command,
orig.txt
is in the same partition, but doesn't exist. -
jlliagre almost 11 yearsYou should have typed:
ln -s /orig.txt /pool0/manager/link.txt
(notice the absolute path for/orig.txt
. -
George Luong almost 11 yearsThat's great. Now I understand it. That's just my typing problem haha. Thanks dude!
-
George Luong almost 11 yearsThanks for your test Nitin! That's just my typing problem... Haha.