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

learn more… | top users | synonyms (1)

2
votes
1answer
7 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 ...
1
vote
1answer
30 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
29 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
56 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
53 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
41 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?
4
votes
2answers
45 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 ...
4
votes
1answer
100 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 ...
16
votes
1answer
208 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 ...
2
votes
1answer
45 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 ...
7
votes
3answers
347 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 ...
5
votes
1answer
238 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: ...
2
votes
2answers
48 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 ...
1
vote
1answer
52 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
170 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?
0
votes
1answer
28 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 ...
1
vote
1answer
36 views

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 ...
0
votes
2answers
38 views

How to specify the file type in a hard link [closed]

Does anyone know how to specify the file type of a hard link? Is this even possible? For example, I want to link to an HTML file (with content type text/html) in my website directory, so I used ln ...
1
vote
1answer
47 views

Can a hard link break the file system structure?

I want a very simple example of how can a hard link break the file system structure. I saw somewhere that people say it's because of loops, however, I can make a loop with a soft link and so I still ...
3
votes
1answer
286 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 ...
1
vote
0answers
135 views

Directory symlink to inode, not path (e.g. directory hardlinks)

I'm trying to better understand why directory hardlinks are not possible. Roughly, I think of directories and files as follows: directory --------- inode # exposed as . inode_of_parent # ...
1
vote
1answer
162 views

Hard Linking Other Users' Files

Suppose User A and User B have disk quotas of 1 GB. Also suppose User B creates a 900 MB file with permission 0666. This allows User A to access that file temporarily (for some project, etc.). Notice ...
1
vote
2answers
279 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 ...
0
votes
2answers
130 views

Change file hard link count

On my Linux machine, I have the following file: drwxr-xr-x 2 jsgdr Unix_31 4096 Dec 2 17:46 jsgdr How to change the permission 2 to 4 so that I will this: drwxr-xr-x 4 jsgdr ...
0
votes
1answer
50 views

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 ...
0
votes
2answers
517 views

How to find out a file is hard link or symlink? [duplicate]

I have a file in ~/file.txt. I have created a hard link by : ln ~/file.txt ~/test/hardfile.txt and a symlink file : ln -s ~/file.txt ~/test/symfile.txt Now, How can I find out that which file ...
14
votes
3answers
5k views

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

I'm creating a shell script that would take a a filename/path to a file and determines 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 ...
1
vote
1answer
157 views

Linux command to copy as hard links, while deleting unwanted files?

I'm looking for a command that behaves both like cp -al in only creating hard links rather than copying file contents, and rsync -a --delete in removing files from the destination that are not ...
2
votes
2answers
69 views

Use the same file link for both Linux and Windows

As in the title, is it even possible to do so? I mean, can I create a link on Linux and than make this link valid also on Windows? Use-case I have the folder /media/Data/DownloadedMusic on a NTFS ...
1
vote
0answers
19 views

What means a number of links > 1 for directories? [duplicate]

Both programs stat and ls -l tell about the number of (hard) links to file(s). Going under the assumption that one usually cannot create hardlinks for directories in Linux it confuses me to see ...
0
votes
0answers
227 views

How to create a hardlink to a directory in Solaris?

I started to study the Solaris in my university. Teacher told me to do a hardlink to a directory. And he said that I can not to use mount command. For example: # mount -F lofs /dir1/dir2 ...
0
votes
2answers
170 views

ls hard link question

I run ls -la on the Volumes directory. It shows the MM dir to have 9 hard links and the Media dir to have 12. If I then cd to the MM directory and run ls -la, it shows only 7 items whereas if I cd to ...
5
votes
2answers
318 views

Is there a better way than cp to copy millions of files while preserving hard links?

So in this story on the GNU coreutils ML, someone used cp to copy 430 million files and needed to preserve hard links, and just barely got it to finish after 10 days. The big problem was that, in ...
2
votes
2answers
296 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
5
votes
1answer
660 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. ...
0
votes
1answer
48 views

“Links” to dirs that have features of both hard and soft links?

It is not allowed to create a hard link for a dir. But the soft like will not work, if I later change the name of the dir. How would you solve the dilemma? Are there applications which can ...
1
vote
3answers
52 views

Sharing a project tree between environments

To save space and time I copied a large project tree on a network drive as hard links, i.e. cp -a -r --link proj proj_B (background: it's huge, needs to be rebuilt from two incompatible ...
3
votes
2answers
789 views

How to create file links on a vfat filesystem of a mounted disk under Linux?

I have an external drive containing different pieces of music. The drive is a vfat formatted drive to be able to work with arbitrary devices. On the device I have music stored from different artists ...
1
vote
3answers
379 views

Seemingly Inconsistent Behavior for “ln” & “ln -s”

As we all know, the ln command creates a link, with the default being a hard link and the -s option creating a symlink. The general syntax is ln [-s] OLD NEW, where OLD is the file you are linking to ...
24
votes
5answers
6k views

How to tell which file is original if hard link is created

For example, I have a file myold_file. Then I use ln to create a hard link as mylink: ln myold_file mylink Then, even by using ls -a, I cannot tell which is the old one. Is there anyway to tell?
4
votes
1answer
189 views

“hard-linking” parts of a big file in which only a small part has changed

I use rsync to make backups: rsync -a --link-dest=PATHTO/$PREVIOUSBACKUP $SOURCE $CURRENTBACKUP This way I save space due to using hard links. The problem appears when I need to backup a huge file ...
4
votes
5answers
2k views

How to get folder size ignoring hard links?

I use rsnapshot for backups, which generates a series of folders containing files of the same name. Some of the files are hard linked, while others are separate. For instance, hourly.1/file1 and ...
3
votes
1answer
99 views

Where are information stored information about hard/soft links

Where does the *nix system store information about number of hard links to a specific inode? I can't find any information about that. Everywhere what a hard link is but rarely a bit more advanced ...
5
votes
2answers
464 views

Linux: How does hard-linking to a directory work?

I'm aware that Linux does not allow hard-linking to a directory. I read somewhere, that this is to prevent unintentional loops (or graphs, instead of the more desirable tree structure) in the ...
2
votes
2answers
696 views

Is a -rw-rw-rw- file really inaccessible inside a drwxrwx— directory?

Say I have a directory with these permissions: drwxrwx--- Inside this directory, a file with these permissions: -rw-rw-rw- Is the file readable/writable by everyone or not ? If not, how secure ...
0
votes
2answers
728 views

Hard links versus symbolic links: which one is faster / smaller? [duplicate]

Hard links Given a file original.txt, a hard link hardlink.txt will point to the same inode and continue to exist even when original.txt is deleted. Symbolic links Given a file original.txt, a ...
3
votes
1answer
266 views

setgid binary doesn't have permission, mount's right, I'm missing something, but what, please?

I'm sorry, I know this has to be something simple but I've checked the manpages, the mount, the permissions ... (edit: combined history into one sequence as requested. Starting to seem a not-simple ...
0
votes
3answers
292 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 ...
7
votes
2answers
3k views

Can a file be retrieved by its inode?

Run command like the following: $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 command rm actually removes the filename (a in this test) only ...
7
votes
2answers
134 views

Why is there a mix of symlinks and hardlinks in /bin?

I understand the technical difference between symlinks and hardlinks, this is a question about their use in practice, particularly I'm curious to know why both are used in seemingly similar ...