Вопрос: Как символизировать файл в Linux?


Я хочу сделать символическую ссылку в Linux. Я написал эту команду bash, где первый путь - это папка, в которую я хочу включить ссылку, а второй путь - скомпилированный источник.

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

Это верно?


1432


источник


Ответы:


Чтобы создать новую символическую ссылку (не удастся, если уже существует символическая ссылка):

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

Чтобы создать или обновить символическую ссылку:

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

2875



ln -s TARGET LINK_NAME

Где -sделает его символическим.


239



ln -s EXISTING_FILE_OR_DIRECTORY SYMLINK_NAME

226



ln -s target linkName

You can have a look at the man page here:

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


75



(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)

65



ln -s source_file target_file

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


21



To the original question:


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

This will indeed create a symbolic link (-s) from the file/directory:

<basebuild>/IpDome-kernel/kernel

to your new link

/home/build/sandbox/gen2/basebuild/IpDome-kernel/kernal

Here's a few ways to help you remember:

First, there's the man page for ln. You can access this via searching "man ln" in google, or just open a terminal window and type man ln and you'll get the same information. The man page clearly states:

ln [OPTION]... [-T] TARGET LINK_NAME (1st form)


If having to search or read through a man page every time isn't for you, maybe you'll have an easier time remembering that all nix commands work the same way


17



ln [-Ffhinsv] source_file [target_file]

    link, ln -- make links

        -s    Create a symbolic link.

    A symbolic link contains the name of the file to which it is linked. 

    An ln command appeared in Version 1 AT&T UNIX.

14



ln -s sourcepath linkpathname

Note:

-s makes symbolic links instead of hard links


10



If you are in the directory where you want to create symlink, then ignore second path.

cd myfolder
ln -s target

It will create symlink of target inside myfolder.

General syntax

ln -s TARGET LINK_NAME

9