Advertisement
Advertisement



Question

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?

2019/11/16
1
1968
11/16/2019 11:34:42 PM

Accepted Answer

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
2020/07/30
3724
7/30/2020 10:49:56 AM

ln -s TARGET LINK_NAME

Where the -s makes it symbolic.

2015/05/11

ln -s EXISTING_FILE_OR_DIRECTORY SYMLINK_NAME
2017/09/20

ln -s target linkName

You can have a look at the man page here:

http://linux.die.net/man/1/ln

2009/12/23

(Because an ASCII picture is worth a thousand characters.)

An arrow may be a helpful mnemonic, especially since that's almost exactly how it looks in Emacs' dired.

And big picture so you don't get it confused with the Windows' version

Linux:

ln -s target <- linkName

Windows:

mklink linkName -> target

You could also look at these as

ln -s "to-here" <- "from-here"
mklink "from-here" -> "to-here"

The from-here should not exist yet, it is to be created, while the to-here should already exist (IIRC).

(I always get mixed up on whether various commands and arguments should involve a pre-existing location, or one to be made.)

EDIT: It's still sinking in slowly for me; I have another way I've written in my notes.

ln -s (target exists) (link is made)
mklink (link is made) (target exists)
2017/12/15

ln -s source_file target_file

http://unixhelp.ed.ac.uk/CGI/man-cgi?ln

2014/03/26

Source: https://stackoverflow.com/questions/1951742
Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Email: [email protected]