Questions tagged [ln]

ln - Command line tool to create hard links to existing files and soft links to existing and non-existent files.

142 questions
188
votes
6 answers

Too many levels of symbolic links

I created this file structure: test/src test/firefox When I run this command: ln -s test/src test/firefox I would expect a symbolic link test/firefox/src to be created pointing to test/src, however I get this error instead: -bash: cd: src: Too…
David Zorychta
  • 1,993
  • 2
  • 12
  • 6
157
votes
3 answers

How to change ownership of symbolic links?

I am facing some issue with creating soft links. Following is the original file. $ ls -l /etc/init.d/jboss -rwxr-xr-x 1 askar admin 4972 Mar 11 2014 /etc/init.d/jboss Link creation is failing with a permission issue for the owner of the file: ln…
Zama Ques
  • 3,186
  • 12
  • 39
  • 54
116
votes
4 answers

Create a symbolic link relative to the current directory

I'm trying to create a symbolic link in my home directory that points to a directory on my external HDD. It works fine when I specify it like this: cd ~ ln -s /run/media/name/exhdd/Data/ Data However it creates a faulty link when I try this: cd…
jcora
  • 3,874
  • 7
  • 34
  • 52
89
votes
13 answers

Tips for remembering the order of parameters for ln?

I have used ln to write symbolic links for years but I still get the order of parameters the wrong away around. This usually has me writing: ln -s a b and then looking at the output to remind myself. I always imagine to be a -> b as I read it when…
Zhro
  • 2,495
  • 4
  • 28
  • 45
33
votes
1 answer

Why are reboot, shutdown and poweroff symlinks to systemctl?

In Arch Linux, if I do ls -l in /sbin, I can see that reboot, shutdown and poweroff are all symlinks to /usr/bin/systemctl. But issuing reboot, shutdown and systemctl commands obviously does not all have the same behaviour. Is ls -l not showing me…
Gradient
  • 3,579
  • 10
  • 31
  • 37
33
votes
2 answers

Why use 'ln -sf' in Linux?

I have 2 questions. The first one is for the -sf options and the second one is for the more specific usage of -f options. By googling, I figured out the description of command ln, option -s and -f. (copy from…
casamia
  • 565
  • 1
  • 5
  • 7
31
votes
5 answers

ln -s with a path relative to pwd

I'm trying to create a bunch of symbolic links, but I can't figure out why this is working ln -s /Users/niels/something/foo ~/bin/foo_link while this cd /Users/niels/something ln -s foo ~/bin/foo_link is not. I believe it has something to do with…
Niels B.
  • 445
  • 1
  • 4
  • 8
30
votes
2 answers

Executable symbolic link results in "command not found"

I created a symbolic link (yesterday) like this: sudo ln -s bin/python /usr/bin/prj-python When I run: prj-python file.py I get: prj-python: command not found When I try creating the link again, I get: ln: creating symbolic link…
xralf
  • 16,149
  • 29
  • 101
  • 149
30
votes
2 answers

Why does ln -s accept a single argument

> cd /tmp > ln -s foo > ls -alhF /tmp lrwxrwxrwx 1 user user 3 Jul 29 14:00 foo -> foo Is this a bug in ln or is there a use case for symlinking a file to itself? This is with coreutils 8.21-1ubuntu5.1.
Squidly
  • 445
  • 4
  • 8
29
votes
2 answers

Is there way to replace value of symbolic link?

Is there a way to replace the value of a symbolic link? For example, I want to change a symbolic link from this: first -> /home/username/foo/very/long/directories/that/I/do/not/want/to/type/again to this: second ->…
ironsand
  • 5,085
  • 12
  • 50
  • 73
23
votes
3 answers

Move a file and replace it by a symlink

Can someone give me a command that would: move a file towards a new directory and leave a symlink in its old location towards its new one
Yollanda Beetroot
  • 333
  • 1
  • 2
  • 6
19
votes
1 answer

How to force creation of a symbolic link?

I have a particular directory full of other directories organized (named) by date. For ease of reference, I have a symlink called current pointing to the latest one. In the script that creates new date directories, I wish to create or fix the…
Wildcard
  • 35,316
  • 26
  • 130
  • 258
19
votes
2 answers

Is there a difference between hardlinking with cp -l or ln?

I am implementing a backup scheme using rsync and hardlinks. I know I can use link-dest with rsync to do the hardlinks, but I saw mention of using "cp -l" before "link-dest" was implemented in rsync. Another method of hardlinking I know of is…
twan163
  • 5,590
  • 4
  • 14
  • 17
17
votes
1 answer

What does ln stand for?

In Linux you can use the ln command to make links. $ touch foo $ ln -s foo foo_link $ ls -l lrwxrwxrwx 1 cklein cklein 3 May 29 16:11 foo_link -> foo I assume that the 'l' in ln stands for "link", but what does the 'n' stand for? What does…
Cory Klein
  • 18,391
  • 26
  • 81
  • 93
17
votes
3 answers

How to create a folder symlink that has a different name?

I want to create a symlink ~/.pm2/logs -> /opt/myapp/log When I run ln -sFf /opt/myapp/log ~/.pm2/logs I get a symlink ~/.pm2/logs/log -> /opt/myapp/log which is not what I want. I'd prefer a POSIX-compatible solution if possible.
ptkvsk
  • 273
  • 1
  • 2
  • 6
1
2 3
9 10