Questions tagged [ln]

ln is the Unix utility for creating filesystem links.

From the ln man page:

NAME

ln - make links between files

SYNOPSIS

ln [OPTION]... [-T] TARGET LINK_NAME (1st form)
ln [OPTION]... TARGET (2nd form)
ln [OPTION]... TARGET... DIRECTORY (3rd form)
ln [OPTION]... -t DIRECTORY TARGET... (4th form)

38 questions
26
votes
1 answer

How to overwrite a symbolic link of a directory?

There are two directories foo1 and foo2. At first I make a directory symlink by ln -s foo1 bar. After that I want to change the symlink, so I typed ln -sf foo2 bar But bar is still linked with foo1. Symlink foo2 is created inside of foo1. What…
ironsand
  • 2,489
19
votes
1 answer

How to create symbolic links in /usr/bin on a Mac?

Environment: OSX Sierra, Darwin Kernel Version 16.3.0 Root Problem: I want to use a bunch of shell scripts in a central repository, which have a #!/usr/bin/zsh. On my Mac, the zsh is in /bin/zsh. Attempted solution: I want to create a symbolic…
12
votes
2 answers

Symlink to current folder as absolute path without typing whole path

Symlinks are saved shortcuts for relative paths: ~/foo➤ ln -s . ~/bar/foo ~/foo➤ ls -l ~/bar total 8 lrwxr-xr-x 1 me me 1B 15 May 14:38 foo -> . The file ~/bar/foo is a symlink to bars current directory, i.e. itself What if I want to create…
Gareth
  • 327
  • 1
  • 3
  • 11
10
votes
2 answers

How to find all soft links (symbolic links) in current directory?

Question relates to shell-scripting in bash. How to check with a script which files within the current directory are soft links? In case I have used the wrong term, when I say soft links, I am referring to files created using ln -s. The only thing I…
bguiz
  • 2,141
5
votes
1 answer

Symlink all files in a Folder to a new Folder

Ideally what I am seeking is a way to rename all my anime keeping original files intact without using extra data space The solution I can think of is creating a duplicate folder path to another location and then symlinking each file into the new…
5
votes
2 answers

Does the target in ln -s have to be a full path?

I've tried to invoke ln in directory ~/download as this: ln -s ./abc ~/abc [EDITED] but it does't work. I do ls -al in my home and get wrong link of abc. ln [OPTION]... [-T] TARGET LINK_NAME (1st form) So my question here is: Does ln need full…
fangzhzh
  • 151
4
votes
2 answers

What is "ln -L" (--logical) for?

I can read in the ln man page: -L, --logical make hard links to symbolic link references I read somewhere that ln -L could be used to re-link files that were deleted but which are still open, using the /proc filesystem. For example: ln…
user36520
  • 3,171
  • 3
  • 24
  • 19
3
votes
2 answers

Make a symlink in bash with two relative paths

I have two directories in my home: ~/dir1 and ~/dir2 with a file in the first: ~/dir1/file.txt Is there any way that I can make a symlink to it from ~/dir2 without moving to ~/ and if not why is that the case? I've tried from ~/ running: $ ln -s…
nettux
  • 201
  • 3
  • 7
3
votes
1 answer

How can I get Total Commander to recognize Cygwin symlinks?

I love Total Commander. I love Cygwin. But they are not always friends. One thing that bugs me, is the way symlinks work in Cygwin. Suppose I do this: $ ln -s my/path/to/nirvana budhism And then do: (because cygwin won't let me view budhism) $…
3
votes
5 answers

Does ln -s require you to be in a certain directory?

I want to create a simple symlink to a file. It works perfectly if I run the command from inside the directory where I want the symlink to be created: /path/to/link $ ln -s /path/to/file . But if I'm in any other directory, it creates a broken link…
evanrmurphy
  • 133
  • 1
  • 5
2
votes
1 answer

Find all files matching desription and create hard link in directory

I would like to find all .mkv files in my download directory and create a hard link to them in my /movies/ directory. Here’s what I have so far: for i in `find /download/ -name *.mkv`; do ln "$i" /movies/; done Which almost works: I receive a bunch…
curios
  • 390
2
votes
1 answer

Ignoring 'ln' errors in Vagrant provisioning

I'm using a shell script in my Vagrantfile to create a symlink for Node.js (in a Ubuntu VM): ln -s /usr/bin/nodejs /usr/bin/node That works fine when I call vagrant up for the first time, but when I call vagrant up --provision after that (i.e.,…
2
votes
1 answer

Why doesn't ln -s prompt that it fails when creating a symlink to an existing symlinked directory?

When running (on linux different ubuntu variations): >ln -s dir_1 symlink_dir >ln -s dir_2 symlink_dir It fails without telling that it fails. But if you do the same thing on a file instead or, add v to the option it does tell you that it…
giZm0
  • 123
  • 1
  • 5
2
votes
2 answers

Unix pipe: find | ln -s

I'm trying to symlink some php files using the following command: find `pwd` -name "*.php" | ln -s * /home/frankv/www/bietroboter.de/symlinks However, all the symlinks are broken because the little * does not reference the full path, only the file…
2
votes
2 answers

Problem with permissions when syncing to sites directory

Is there a way to symbolically link a directory using ln to my ~/Sites/ directory on OS X so that the permissions are correct so it may be viewed in a web browser when I'm doing web development on a local machine? This is what I did ln -s…
yolk
  • 141
1
2 3