Questions tagged [hard-link]

A hard link is file system entry that associates a name with another file on a file system.

A hard link is file system entry that associates a name with another file on a file system.

255 questions
19
votes
7 answers

Breaking a hard-link in-place?

I am keeping my dotfiles under version control and the script deploying them creates hard links. I also use etckeeper to put my /etc under version control. Recently I have gotten warnings like this: warning: hard-linked files could cause problems…
0xC0000022L
  • 16,593
11
votes
1 answer

Editing a file with several hard links

Let's say I have two hard links pointing at the same picture. /photography/picture_1.jpg /best_pictures/picture_1.jpg What happens if I edit /photography/picture_1.jpg? Is the hard link broken and did I end up with 2 different files? Does it keep…
mxdsp
  • 233
  • 2
  • 6
9
votes
4 answers

Properly unlinking hard links

I have a script that goes like this ln /myfile /dev/${uniquename}/myfile I want to remove the link of /dev/somename/myfile to decrease the link count. How do I do this?
e_mam106
  • 217
5
votes
5 answers

Why are hard links are not updated when modified with an editor

I am using Mac OS X, but the command line. I want to make a link from my .profile file, to another file on my system so that updating one updates the other and vice versa. This article makes me think that a hard link is what I need. The command I…
Startec
  • 1,879
3
votes
1 answer

How can I convert a hard link to a normal file?

I realise that every file is a hard link. This is what I mean precisely: if an inode has more than one file pointing to it, how can I copy the inode so that every file is pointing to a separate inode with the same content? For example: echo…
Flimm
  • 4,218
2
votes
1 answer

"No such file or directory" after executing a link

I downloaded Tor Browser and I want to add a shortcut to it to the desktop. So I wrote: ln /home/myusername/Documents/tor-browser_en-US/start-tor-browser.desktop /home/myusername/Desktop/start-tor-browser.desktop But when I do…
user1
  • 233
1
vote
1 answer

Why does looking for hardlinks fail?

Here is how I find hard links located in /tmp: $ for file in /tmp/*; do if [ "$(stat -c %h -- "$file")" -gt 1 ]; then ls "$file" -l ; fi; done total 0 srwxrwxr-x 1 t t 0 Mar 20 23:01 debconf.socket total 0 srwxrwxr-x 1 t t 0 Mar 20 22:58…
Tim
  • 101,790
1
vote
1 answer

What operations raise link count

I had an interview, where the interviewer asked what operations raise the link count of a file, besides ln and its underlying syscall, I didn't know. He stated that opening a file will increase the link count by one to prevent deletion of an opened…
Gregg
  • 13
1
vote
1 answer

Determine a file with the most Hard-Links

i got a homework today. Can u help me guys? "Determine on any PC pool that hosts regular file on the local file system root who has the most hard links! Avoid doing a search of the user home directories or other NFS mounted directories. Type a file…
Marko
  • 11
0
votes
2 answers

Creating hard links

$ ln fun fun-hard $ ln fun dir1/fun-hard $ ln fun dir2/fun-hard $ ls -1 total 16 drwxrwxr-x 2 me 4096 2018-01-14 16:17 dir1 drwxrwxr-x 2 me 4096 2018-01-14 16:17 dir2 -rw-r—-r—- 4 me 1650 2018-01-10 16:33 fun -rw-r—-r—- 4 me 1650 2018-01-10 16:33…
0
votes
2 answers

Creating a hard link increases the hard link count for two names

gui@Latitude:~$ cd playground gui@Latitude:~/playground$ ls -l total 8 drwxrwxr-x 2 gut gut 4096 set 20 16:18 dir1 -rw-r--r-- 1 gut gut 2903 set 20 14:46 gato gui@Latitude:~/playground $ ln gato gato-rato gui@Latitude:~/playground $ ls -l total…
0
votes
1 answer

Hard links on a mounted disk

I have a work laptop that I will soon have to return to my employer. Having foreseen this, I ordered a second internal disk and mounted it at /home/ so that I can just pull it out and mount it in the next machine without having to go through…
Bob
  • 3
0
votes
1 answer

getting "Invalid cross-device link" doing a cp -l - same volume

This command - run as Admin (not Root) in directory /volume2/Media/AllOurMedia/1 Our Pictures/Cataloged ( 3-5): cp -l HL_Test.JPG /volume2/phototest/ got this response: cp: cannot create hard link '/volume2/phototest/HL_Test.JPG' to 'HL_Test.JPG':…
Bones
  • 1
0
votes
2 answers

Why are there lots of hard links in /usr

I've read this link, now I simply want to know why there are lots of hard link in /usr. For example, in my Ubuntu server, installed git, I found the command git here: /usr/bin/git. I execute ls -l /usr/bin/git and get the output as below: -rwxr-xr-x…
Yves
  • 3,291
-1
votes
1 answer

copying a file to a new directory, does this just create a new hardlink?

I am attempting to grasp hardlinks. When one copys a file from /dir1/file1 to /dir2/file1 does this create a hardlink, or is the data actually duplicated and now two hardlinks exist?
Oscalation
  • 1,139
1
2