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
5
votes
3 answers

error:" ln: failed to create symbolic link ‘./sys/kernel/config/nvmt’: Operation not permitted" even with root access

I am trying to setup NVMe over Fabrics using post "https://community.mellanox.com/s/article/howto-configure-nvme-over-fabrics". I could reach step 10, but when I try to create the soft link according to step 10 as a root user, I am getting…
Marjan Radi
  • 51
  • 1
  • 2
5
votes
0 answers

Make symlinked file non-writable

I have this situation, a real folder called "git" is symlinked to .githooks: Is there a way to make the symlinked files non-writable, without affecting the original files? I don't want users to accidentally modify the source in the git folder…
Alexander Mills
  • 90,741
  • 139
  • 482
  • 817
5
votes
2 answers

Can I add a file by putting the symbolic link in the git repository?

Is there a way to push a file external to the git repository by putting a symbolic link. I want for instance to push the file /root/my_file and have created a symbolic link my_symbolic_link in the git repository. # ls -lA …
user123456
  • 364
  • 1
  • 3
  • 16
5
votes
2 answers

`ln -s` in a script acts as `cp`

Problem I have this bash script: ACTIVE_DB=$(grep -P "^[ \t]*db.active" config.properties | cut -d= -f2 | tr -s " ") echo $ACTIVE_DB if [ "$ACTIVE_DB" = "A" ] then ln -sf config-b.properties config.properties else ln -sf config-a.properties…
Olivier Grégoire
  • 33,839
  • 23
  • 96
  • 137
4
votes
1 answer

Makefile and symbolic links

I'm experiencing a strange problem with a makefile. I simply want to set a symbolic link in the makefile but get an error message on one machine (Linux 2.6.18-238.12.1.el5) make: execvp: ln: Too many levels of symbolic links It works perfectly fine…
hanno
  • 6,401
  • 8
  • 48
  • 80
4
votes
2 answers

How to stop recursive symbolic link

I have a the following folder : Folder A Folder B (which is a symbolic link to Folder A) The issue is that when I access Folder B, I can go infinitely deeper (ie Folder A > Folder B > Folder B > Folder B) because Folder B is inside Folder A. Is…
Kentricks
  • 51
  • 1
  • 4
4
votes
3 answers

Symlink multiple files to an existing folder

I have this command: ln -sf src/* lang/golang/src/genericc/ I want to symlink all the files in src to the existing genericc directory, but when I run the above command I get broken symlinks in the destination. Anyone know how to do this?
Alexander Mills
  • 90,741
  • 139
  • 482
  • 817
4
votes
1 answer

How do I link directories in python (Linux cmd ln -s equivalent)?

I'm translating Linux commands to a python script. How would I perform the Linux command 'ln -s' CMD: ln -s /users/me/link_file hello I want to link 'hello' to 'link_file' in python Thanks!
Xandy
  • 155
  • 2
  • 2
  • 9
4
votes
1 answer

How change symlink path for many files?

I was changed directory name. In this directory thousands of files. Some projects use this files, projects have got symlinks on it. How to find all symlinks, which have got folder name in their address? how to change all this symlinks to another…
butteff
  • 115
  • 2
  • 9
4
votes
1 answer

bash script that executes ln -s command is getting error code on exit but symlinks are being created successfully

I wrote a bash script that is supposed to iterate thru the files and directories in TARGET DIR and create a symlink to all directories in DESTINATION DIR. The script works but the ln command is giving an exit code of >0 from what I can tell and so…
obitori
  • 43
  • 1
  • 5
4
votes
1 answer

How to create MacOS/Linux link for reading data file?

I have a huge raw data file which I do not intend to change or copy. And I have two projects in RStudio and both need to be able to access it. I originally created the alias (in MacOS) in the following way right click the file ~/A/data.csv in…
kindadolf
  • 209
  • 1
  • 8
4
votes
0 answers

Access rights for site-enabled nginx folder

I would like to split my nginx websites configuration in multiples files and I have a problem. So I have 3 files in /etc/nginx/sites-available folder and i created their symbolic links in /etc/nginx/site-enabled with these commands : ln -s…
LnlB
  • 180
  • 2
  • 11
3
votes
2 answers

Symbolic Links in Ubuntu Recursively link to files in one directory to another

After searching stackoverflow and Google for the past hour I thought I would ask. If the title does not make sense here is what I am looking to achieve. /var/www/xxx/ Say there are files in this above directory. /var/www/yyy/ I want the files…
kwallbmoc
  • 35
  • 2
  • 4
3
votes
1 answer

Cannot remove symbolic link to directory

I have a directory reference in my Downloads directory that contains a symbolic link (created with ln -s) to another directory. I get conflicting error message when trying to remove the symlink: rm returns "Is a directory" rmdir returns "Not a…
Tom Kelly
  • 1,458
  • 17
  • 25
3
votes
1 answer

Why ln -sf does not overwrite existing link to directory

According to documentation, command ln -f removes existing destination file. Does this mean that if I create a symlink, -f should remove of overwrite any existing symlink at destination? I have a symlink, say, L, pointing to DIR1 and type ln -sf…
ddbug
  • 1,392
  • 1
  • 11
  • 25
1
2
3
10 11