Questions tagged [ln]

Use this tag for questions related to the `ln` (link) command. The `ln` command is available in *nix OS to create links, allowing more than one filename to refer to the same file. Two types of links can be created using `ln`: symbolic links and hard links. Do not use this tag to refer to the natural base-e logarithm (furthermore base-e log is written "log" in most programming languages): use the [natural-logarithm] for that.

The ln (link) command is used in *nix OS to create links, allowing more than one filename to refer to the same file. Two types of links can be created using ln:

  1. Symbolic links: refer to a symbolic path indicating the abstract location of another file. The two file names need not be on the same file system. System call: symlink().
  2. Hard links: refer to the specific location of a physical file. The two file names must both be on the same file system. System call: link().

Note: For questions related to ln function which is used to calculate logarithms, please use the tag.

162 questions
184
votes
5 answers

Cannot create a symlink inside of /usr/bin even as sudo

When I try to symlink a binary in my /usr/bin folder, I get an Operation not permitted error: sudo ln -s /usr/bin/python2.7 /usr/bin/python2 ln: /usr/bin/python2: Operation not permitted Even as sudo, I get this error.
egidra
  • 8,537
  • 19
  • 62
  • 89
143
votes
4 answers

How do I symlink all files from one directory to another in bash?

I want to link ( ln -s ) all files that are in /mnt/usr/lib/ into /usr/lib/ There are lots of files, how can it be done quickly? :)
KooT
72
votes
10 answers

How to use MAMP's version of PHP instead of the default on OSX

I would like to use MAMP's version of PHP instead of the default installed on my mac. I tried using ln -s /Applications/MAMP/bin/php5.3/bin/php php but I get a "File exists" error. What's the best way to work around this so I can just type php…
Josh Fraser
  • 863
  • 1
  • 9
  • 10
62
votes
14 answers

What is the Unix command to create a hardlink to a directory in OS X?

How do you create a hardlink (as opposed to a symlink or a Mac OS alias) in OS X that points to a directory? I already know the command "ln target destination" but that only works when the target is a file. I know that Mac OS, unlike other Unix…
username
  • 18,800
  • 11
  • 41
  • 45
56
votes
5 answers

Enable native NTFS symbolic links for Cygwin

Recent NTFS and Windows implement symlinks: NTFS junction point can be used as directory symlink since NTFS 3.0 (Windows 2000) using linkd or junction tools. NTFS symbolic link can also be used as symlink (for both file and directory) since Windows…
oHo
  • 51,447
  • 27
  • 165
  • 200
50
votes
3 answers

cannot install "code": classic confinement requires snaps under /snap or symlink from /snap to /var/lib/snapd/snap

how I can fix it? I've tried to create "soft link" like sudo ln /snap /var/lib/snapd/snap and also sudo ln /var/lib/snapd/snap /snap --> but it doesn't work. I just want to install VSCode in Manjaro
0xActor
  • 614
  • 1
  • 5
  • 7
17
votes
2 answers

Symbolic link not inheriting permissions

For example, I have foo.sh with 770 permissions. When I do: ln -s foo.sh bar.sh The link bar.sh has 2777 permissions. Why is this? I thought they were meant to be inherited?
joedborg
  • 17,651
  • 32
  • 84
  • 118
14
votes
1 answer

How to memorize the order of parameters to `ln` command?

I don't use ln command on daily basis, so when I need to create a link to a file, I always forget whether it's ln , or ln , so I have to take a quick glance at man ln. As ln is commonly used in the…
dorserg
  • 5,454
  • 3
  • 24
  • 29
11
votes
3 answers

symbolic link without expanding $HOME or "~"?

the basic idea is that I want to link to path that's relative to $HOME, rather than explicitly expand the $HOME variable, as I want to make sure the link works on multiple machines, e.g., when I do ln -s ~/data datalnk I want it to be directed to…
nye17
  • 12,857
  • 11
  • 58
  • 68
11
votes
1 answer

Follow symlinks in SVN

I have a linux directory (and don't need any windows checkout): /home/me/projects/project1 In this project, I need SVN (1.8.8) to follow a symlink "link1": /home/me/projects/project1/link1/ But SVN won't let me do that,…
Cyrille
  • 13,905
  • 2
  • 22
  • 41
10
votes
2 answers

Link to a specific inode

I have a file that was deleted, but is still held open my a program. I found the inode number using lsof. How can I create a hard link back to that inode? Any code helps, but Perl would be handy.
Jeff Ferland
  • 17,832
  • 7
  • 46
  • 76
8
votes
3 answers

Linux file deleted recovery

Is there a way to create a file in Linux that link to a specific iNode? Take this scenario: There is a file that is in course of writing (a log maybe) and the specific file is deleted but a link in the dir /proc is still pointing at it. In this case…
poe84it
  • 354
  • 2
  • 8
7
votes
4 answers

Create broken symlink with Python

Using Python I want to create a symbolic link pointing to a path that does not exist. However os.symlink just complains about "OSError: [Errno 2] No such file or directory:".. This can easily be done with the ln program, but how to do it in Python…
Mathias
  • 1,446
  • 2
  • 16
  • 31
6
votes
1 answer

Installing NetLogo in Linux

I have been trying to install NetLogo under my Ubuntu setup. I have downloaded the latest NetLogo 5.3 files and have extracted them. I placed the files in the /opt/netlogo-5.3.0/ directory. I then proceeded to create a symbolic link to the NetLogo…
csstudent
  • 107
  • 2
  • 6
6
votes
3 answers

How to git a folder outside the repository?

I have a git repository sitting as ~/a. At the same time, I have some stuff from ~/b/content/data/, which will be updated by another application. For backup purposes, I would like to add ~/b/content/data/'s stuff into git ~/a, without moving the…
Jane Foster
  • 441
  • 2
  • 6
  • 14
1
2 3
10 11