Question about the symlink of the ln command

12,092

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.

Share:
12,092

Related videos on Youtube

George Luong
Author by

George Luong

Updated on September 18, 2022

Comments

  • George Luong
    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
      jlliagre almost 11 years
      It would help if you post the precise command(s) you typed. I suspect a path error.
  • jlliagre
    jlliagre almost 11 years
    Your 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
    Nitin almost 11 years
    file orig.txt lies in / while symlink lies in other partition /pool0/manager/link.txt which i tested.
  • jlliagre
    jlliagre almost 11 years
    As you wrote the command, orig.txt is in the same partition, but doesn't exist.
  • jlliagre
    jlliagre almost 11 years
    You should have typed: ln -s /orig.txt /pool0/manager/link.txt (notice the absolute path for /orig.txt.
  • George Luong
    George Luong almost 11 years
    That's great. Now I understand it. That's just my typing problem haha. Thanks dude!
  • George Luong
    George Luong almost 11 years
    Thanks for your test Nitin! That's just my typing problem... Haha.