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

learn more… | top users | synonyms (1)

3
votes
1answer
40 views

Deleting hardlink with rm -rfv deletes the original?

I was reading up on similar questions on here about what happens when you delete a hardlink to a file and the majority of the answers I was getting were that the hardlink is deleted but the original ...
2
votes
0answers
18 views

Creating an Arch ISO image produces invalid cross-device link errors

I have been trying to create a custom Arch ISO by following the archiso article at The ArchWiki, unfortunately whenever I run ./build.sh -v from my ~/archlive directory I get one of two types of ...
21
votes
3answers
15k views

Determining if a file is a hard link or symbolic link?

I'm creating a shell script that would take a filename/path to a file and determine if the file is a symbolic link or a hard link. The only thing is, I don't know how to see if they are a hard link. ...
7
votes
2answers
2k views

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. ...
11
votes
4answers
7k views

What's the difference between a hard links and copied files?

My understanding is that hard links include a copy of the original file and that I could delete a hard-linked file in one directory, and it would still exist in the other directory. If that's the ...
1
vote
2answers
54 views

find all hard linked files between two directories

How do I find if any files among two or more directories are hard linked? In other words, do any files under two or more directories refer to the same file? Similar to How to find all hard links to ...
91
votes
7answers
31k views

Why are hard links to directories not allowed in UNIX/Linux?

I read in text books that Unix/Linux doesn't allow hard links to directories but does allow soft links. Is it because, when we have cycles and if we create hard links, and after some time we delete ...
0
votes
0answers
11 views
0
votes
0answers
27 views

File and folder size using ls and du [duplicate]

I created a folder and copied a 992 byte jpg file in it. Then I created a hard and soft links for the file. The hard link is the same size of the file and the soft link is 8 bytes. Now when I checked ...
10
votes
2answers
156 views

Are there any filesystems for which `ln -d` succeeds?

From the manpage for ln: -d, -F, --directory allow the superuser to attempt to hard link directories (note: will probably fail due to system restrictions, even for the superuser) Are there any ...
4
votes
1answer
44 views

unpacking tarball with hard links on a file system that doesn't support hard links

I got a tarball (let's say t.tar.gz) that contains the following files ./a/a.txt ./b/b.txt where ./b/b.txt is a hard link to ./a/a.txt. I want to unpack the tarball on a network file system (AFS) ...
-1
votes
1answer
29 views

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?
4
votes
1answer
49 views

Is there a tool to create a hard link to an unlinked inode?

Assume you have a filename/directory name, whatever, which is hard linked to inode 6400. Alas, the file/directory actually exists (completely intact, and maybe it only lives in a single data block, ...
16
votes
3answers
5k views

Can a file be retrieved by its inode?

I ran following commands in the order specified: $ln a b $ls -i a b 523669 a 523669 b $rm -f a $ls -i b 523669 b I concluded from this test that the command rm actually removes only the filename (a ...
2
votes
0answers
35 views

Space efficiency of Btrfs reflinks vs hardlinks

A webpage referenced by the Wikipedia article on Btrfs claims that (emphasis mine) [Btrfs] reflinks have the same use as hardlinks, but are more space efficient. I thought that the opposite was ...
2
votes
2answers
133 views

Hard-link creation - Permissions?

Which permissions affect hard-link creation? Does file ownership itself matters? Suppose user alice wants to create a hard-link to the file target.txt in a directory target-dir. Which permissions ...
1
vote
2answers
26 views

How are hard links counted in UNIX? [duplicate]

When we create a directory in UNIX it has 2 hard links: . and ... One to itself and another one to its parent directory. As I read the . increases counter of the directory, and the .. increases hard ...
2
votes
1answer
38 views

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 ...
3
votes
2answers
781 views

Link value is 2 by default for folders

Can anyone help me to understand the logic behind the link value being "2" for the first time when we create any folders/ directory in linux. I searched a lot , but couldn't get satisfactory logic
8
votes
5answers
6k views

Can I determine the number of sub-directories in a directory using `ls -l`?

When displaying directories using ls -l, their number of links (the second field in the output) is at least two: one for the dir name and one for . $ mkdir foo $ ls -l total 2 drwxr-xr-x 2 user ...
3
votes
1answer
64 views

Why can't a UID 0 process hardlink to SUID files in a user namespace?

Consider the following transcript of a user-namespaced shell running with root privileges (UID 0 within the namespace, unprivileged outside): # cat /proc/$$/status | grep CapEff CapEff: ...
0
votes
2answers
40 views

Does soft linking a directory hard link its subfiles?

Suppose I have the following configuration: Folder A file1 file2 I then create a soft link of Folder A as follows: ln -s A B so that we now have: Folder A file1 file2 Folder B ( symlink of ...
2
votes
2answers
43 views

link to an executable and remove some parameters

I currently am using Xamarin Studio, which has a bug in this version. It adds 2 parameters to an executable, which causes the output to flood with error messages, slowing down the build time from a ...
2
votes
3answers
655 views

Convert a hardlink into a symbolic link

It is easy to convert a symlink into a hardlink with ln -f (example) It would also be easy to convert a hardlink (filenames link and original) back to a symbolic link to link->original in the case ...
1
vote
1answer
69 views

What link should i use for home- & owncloud-data?

the plan is to built a debian-based sever with owncloud for syncing addressbooks, calendars, files etc. and also access large video-files in the LAN via webdav from some kodi-clients (maybe also use ...
16
votes
2answers
893 views

Do hard links count as normal files?

I was wondering if there was a way to register this, but since most modern search engines don't work well with phrases over about 5 words in length, I need some help on this one. I was wondering ...
1
vote
4answers
376 views

thoroughly find all links (hard and symlinks, and any combination thereof) leading to a file/dir

I read "most" of the proposed questions, but I believe they all miss the complexity of the right answer. I want, only using "basic" commands (for maximum portability) (i.e., something that would work ...
12
votes
3answers
2k views

How to copy a directory recursively using hardlinks for each file

I want to create a "copy" of a directory tree where each file is a hardlink to the original file Example: I have a directory structure: dirA/ dirA/file1 dirA/x/ dirA/x/file2 dirA/y/ dirA/y/file3 ...
0
votes
2answers
149 views

Why wont my hard links update each other?

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 ...
1
vote
2answers
106 views

Two hard linked files share inode

I'm working on an assignment for my college course, and one of the questions asks for the command used to create a hard link from one file to another so that they point to the same inode. We were ...
11
votes
3answers
5k views

How to `du` only the space used up by files that are not hardlinked elsewhere?

Using rsync --link-dest for space-saving snapshots, how can I figure out how much space I actually saved? Or more general: How to figure out how much space a directory uses considering only files ...
20
votes
4answers
1k views

Surprised by behavior of cp with hardlinks

I understand the notion of hardlinks very well, and have read the man pages for basic tools like cp --- and even the recent POSIX specs --- a number of times. Still I was surprised to observe the ...
38
votes
9answers
23k views
1
vote
1answer
52 views

Should I use hardlinks for my “sites-enabled” folder instead of softlinks?

Every article I find about web servers suggest creating a sites-available and sites-enabled directory within apache/nginx/etc. Then, using symbolic (soft) links, create a link from the available to ...
2
votes
2answers
78 views

Can files with different inum be hard linked?

I am a new Linux user learning from Arch Linux and recently Linux From Scratch (7.7). I set up a new installation of AL to be my LFS host; I manually (and also with the provided bash script) checked ...
3
votes
1answer
128 views

How does `lsof` keep track of open file descriptors' filenames?

I've noticed, if a file is renamed, lsof displays the new name. To test it out, created a python script: #!/bin/python import time f = open('foo.txt', 'w') while True: time.sleep(1) Saw that ...
3
votes
1answer
89 views

hardlinks seem to take several hundred bytes just for the link itself (not file data)

Additional Info Firstly, thank you for all the answers. So I re-ran the tests again to test the answer below that a directory/folder entry takes up 4KB and this was skewing my numbers, so this time ...
-2
votes
1answer
92 views

Create five copies of file with the same inode number

How can I create five copies of /etc/profile with the same inode number?
5
votes
2answers
172 views

What is the difference in file size between Symbolic and Hard links?

I plan to keep all my movies in one giant folder, and then create other folders for the genres, while creating links for all the movies in the genre folder. This way I can organize movies into ...
5
votes
1answer
1k views

Hard link permissions behavior different between CentOS 6 and CentOS 7

I'm getting a permissions error in CentOS 7 when I try to create a hard link. With the same permissions set in CentOS 6 I do not get the error. The issue centers on group permissions. I'm not sure ...
17
votes
1answer
311 views

dpkg replacing files on a FAT filesystem

When you upgrade or reinstall a package with dpkg (and ultimately anything that uses it, like apt-get etc) it backs up the existing files by creating a hard link to the file before replacing it. That ...
8
votes
4answers
7k views

`cp -al` snapshot whose hard links get directed to a new file when edited

I am trying to take snapshots of a massive folder regularly. I have read here: http://www.mikerubel.org/computers/rsync_snapshots/#Incremental that cp -al takes a snapshot of a folder by simply ...
2
votes
1answer
79 views

Generate SFV file, optimizing hard links

I'm currently running cfv -C -rr to generate a SFV file that contains the CRC32 checksums of all files in all subdirectories. The issue is that because there are so many hardlinks, this process is ...
9
votes
4answers
706 views

filesystem for archiving

I have some complex read-only data in my file system. It contains thousands of snapshots of certain revisions of a svn repository, and the output of regression tests. Identical files between snapshots ...
5
votes
1answer
476 views

Is it possible to create a non-empty file without write_close and rename event?

The reason why I am asking is because I'm using iwatch (not to confuse with a gadget device) to watch for filesystem events (in my case - file creation/renaming). What I cannot explain is this log: ...
3
votes
1answer
549 views

rsync's --link-dest option does not link because of file time

Consider this test case: mkdir a echo 'blah' > a/test mkdir b echo 'blah' > b/test rsync -r --link-dest=/tmp/b /tmp/a/ /tmp/c As expected, rsync creates c/test a hardlink of b/test (note the ...
3
votes
2answers
101 views

Several hard-links with different metadata in Linux using Ext4

Is it possible for Ext4 file systems (or maybe another one understood by Linux) to assign different metadata (like modification time, owner, access rights) to several hard-links that refer to the same ...
0
votes
1answer
761 views

Links in /usr/bin or /usr/local/bin: hard or symbolic?

For the links located in /usr/bin and in /usr/local/bin, are they better to be hard or symbolic? They seem to be all symbolic? Why?
1
vote
1answer
63 views

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 ...
0
votes
1answer
41 views

. as a command line argument to a command running in background

I run grep some-string -r . &. While it is running in bkg, I cd to another directory. It seems that grep interprets the hard link . differently then. What happens before and after I change the ...