linux symlink

How can I symlink a file in Linux? [closed]


I want to make a symbolic link in Linux. I have written this Bash command where the first path is the folder I want link into and the second path is the compiled source.

ln -s '+basebuild+'/IpDome-kernel/kernel /home/build/sandbox/gen2/basebuild/IpDome-kernel/kernal 

Is this correct?



To create a new symlink (will fail if symlink exists already):

ln -s /path/to/file /path/to/symlink

To create or update a symlink:

ln -sf /path/to/file /path/to/symlink


  • 413

    @micapam The ln syntax is similar to the cp syntax, e.g. source destination.

    – Andrey

    Apr 6, 2014 at 16:26

  • 170

    Here’s a mnemonic for you: l(i)n(k) -s(ymbolic) <target> <optional name> (the fact that the last parameter is optional helps you figure out that it’s not the target) (btw leaving out the path to the symlink creates a link in the current directory with the same basename as the target)

    – UncleZeiv

    May 22, 2014 at 14:55

  • 39

    @micapam Just as cp is CoPy, ln is LiNk. First and third letters.

    Aug 15, 2014 at 20:48

  • 75

    I spent several minutes trying to figure out why this did not work for me. It created a self-looped link. It seems that the /path/to/file should be absolute and not relative to the “current folder”. Perhaps point this out in the answer?

    May 24, 2015 at 3:56

  • 61

    @AbhishekAnand it’s been a couple years, but I just wanted to leave the note that it does work with relative paths; it just needs to be relative to the resulting symbolic link’s directory and not the current directory. What you write as the first path argument is actually, verbatim, the text that’s going to be inside the symbolic link; that’s why, when it’s relative, it must be relative to the link.

    – JoL

    Mar 27, 2017 at 15:34



Where the -s makes it symbolic.


  • 4

    TARGET & LINKNAME are better way to remember. btw for delete the symlink use: unlink LINK_NAME

    – Silvan

    Jul 6, 2017 at 12:52

  • 41

    I like to phrase it this way: ln -s where-the-symlink-should-point where-to-place-the-symlink-itself.

    – totymedli

    Mar 14, 2018 at 15:00

  • @Silvan you can delete a symlink via rm, but most people don’t know to remove the trailing /.

    Nov 6, 2018 at 11:27




  • 7

    Better than the accepted answer and covered with unambiguous brevity.

    – vhs

    Aug 7, 2018 at 11:09

  • 4

    Except it isn’t the new symlink name. It is the name or a full path (relative to cur dir or absolute) for the new symlink including the name.

    Sep 15, 2018 at 16:47

  • 1

    ln -s EXISTING_FILE_OR_DIRECTORY {optional path to/}SYMLINK_NAME and don’t put a trailing slash on the symlink, as it’s not a directory

    Jul 11, 2019 at 4:49

  • Better, understandable than @cyborg ‘s answer

    – Y Y

    Aug 27, 2021 at 8:01