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

learn more… | top users | synonyms (1)

1
vote
1answer
61 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 ...
1
vote
0answers
23 views

Rsync link-dest - unsure if its creating hard links

This is my first attempt at a shell script. I'm simply trying to make incremental copies of certain folders from a server to another server using Rsync, but using the link-dest option to create ...
3
votes
4answers
636 views

How to diff two folders by inodes

I'm currently using a script to backup files on my computer. In a nutshell, it works like this: rsync --link-dest=$FOLDER/current $SOURCE $DESTINATION However, I think that my script may be ...
3
votes
3answers
691 views

Forcibly create directory hard link(s)?

I understand the reasoning why nearly every unix version doesn't allow hard-linking of directories (in fact HFS+ on OS X is the only one I know, but even that isn't made easy to do yourself). However, ...
1
vote
3answers
37 views

Create link between two existing files

For example: I have file a.txt and file b.txt. I want a link from a.txt to b.txt. If I open/read file a.txt, file b.txt should open/read. If I try something like ln -s a.txt b.txt I get an error ...
0
votes
1answer
46 views

Can rsync be used to make only hard links, not copies? [duplicate]

I'm working on a system to automatically back up my computer using rsync and the Google Drive app (I have a Macintosh computer). (This app creates a directory whose contents are saved to the Google ...
4
votes
1answer
171 views

Where is information about hard/soft links stored?

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 ...
12
votes
5answers
739 views

Why are hard links only valid within the same filesystem?

I am reading this intro to the command line by Mark Bates. In the first chapter, he mentions that hard links cannot span file systems. An important thing to note about hard links is that they ...
0
votes
2answers
66 views

rsync --link-dest not working as expected with symlinks

I'm using rsync to backup some of my files: rsync -aEN --delete --link-dest="$CURR/" "$SOURCE/" "$NEW/" The --link-dest option works fine with most files, but not with symlinks. When I was writing a ...
1
vote
3answers
251 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
1answer
58 views

Extract hard link files with tar

I am trying to get list of all files in tar folder show them all on a page with links to download files. On click on single files it will be downloaded. This all is working fine except the hard link ...
2
votes
2answers
67 views

What is the best way to unlink hard-linked files?

Using rdfind I found a lot of hard-linked files (~60-90) and I want to unlink all of them. One possible solution is to just find all files -link +1 and just copy them, delete them and move it back to ...
3
votes
4answers
74 views

How to delete all duplicate hardlinks to a file?

I've got a directory tree created by rsnapshot, which contains multiple snapshots of the same directory structure with all identical files replaced by hardlinks. I would like to delete all those ...
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. ...
3
votes
1answer
54 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
28 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 error....
23
votes
3answers
18k 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. ...
11
votes
4answers
8k 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
61 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 ...
94
votes
7answers
33k 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
161 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
72 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
32 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
53 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
38 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
213 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
32 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
49 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
899 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
67 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
43 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
45 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
764 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
85 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
936 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
389 views

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

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 ...
14
votes
3answers
3k 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 ...
1
vote
2answers
113 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 ...
40
votes
9answers
24k views
2
votes
2answers
84 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
138 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
95 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
103 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
230 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 ...