A hard link is file system entry that associates a name with another file on a file system.
33
votes
2answers
8k views
Why hard links not allowed to directories in UNIX/Linux
I read in text books that UNIX/Linux doesn't allows hard links to directories but soft links do. Is it because, when we have cycles and if we create hardlinks, and after some time we delete the ...
27
votes
2answers
883 views
Why is '.' a hard link in Unix?
I've seen many explanations for why the link count for an empty directory in Unix based OSes is 2 instead of 1. They all say that it's because of the '.' directory, which every directory has pointing ...
26
votes
7answers
5k views
18
votes
5answers
2k views
Why do hard links exist?
I know what hard links are, but why would I use them? What is the utility of a hard link?
14
votes
3answers
1k views
Is there a limit of hardlinks for one file?
Is there a limit of number of hardlinks for one file? Is it specified anywhere? What are safe limits for Linux? And what for other POSIX systems?
12
votes
1answer
359 views
How to find all the links to a directory
When I stat a directory I get a listing that tell me there are 5 links to the directory.
stat dir
My question is how do I get information (names and locations) to all these 5 links?
10
votes
3answers
1k views
What happens when you delete a hard link?
If you do rm myFile where myFile is a hard link, what happens?
8
votes
4answers
502 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 ...
8
votes
5answers
2k 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 ...
8
votes
2answers
556 views
Dereferencing hard links
In the manual page of tar command, an option for following hard links is listed.
-h, --dereference
follow symlinks; archive and dump the files they point to
--hard-dereference
follow ...
6
votes
1answer
49 views
Is there a way to express: `--link` or fall back to ordinary copy in cp (from GNU coreutils)?
Is there a way to tell cp to --link (i.e. create hard links), but fall back in the case where I am attempting inter-device hardlinks? Inter-device links aren't possible and would cause cp to fail.
...
5
votes
4answers
473 views
What's the difference between a hard links and copied files?
RHEL 6
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 ...
5
votes
2answers
534 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 ...
5
votes
1answer
52 views
Finding all the hard-links of a file without traversing the file system
I have seen in this page that inodes have a link counter to know how many files (read: "directory entry") point to this inode. Is there a way to know which directories contain such entries without ...
4
votes
4answers
373 views
Symbolic link and hard link questions
Let's say /A/B/c.sh is symbolic linked to /X/Y/c.sh.
If c.sh has the command "./SOMETHING", '.' means /A/B/ or /X/Y/?
How about the hard link?
4
votes
4answers
1k views
How to copy directories with preserving hardlinks?
How to move directories that have files in common from one to another partition ?
Let's assume we have partition mounted on /mnt/X with directories sharing files with hardlinks.
How to move such ...
4
votes
1answer
268 views
How to replace a symbolic link with an equivalent hard link?
Having a (single, no batch filesystem processing needed) symlink, what a command line to use to turn it into a hard link to the same file?
4
votes
3answers
43 views
Why does mcedit recommend removing hardlinks when saving a file?
Whenever I use mcedit to edit a file that is hard linked somewhere and I want to save the file, the editor asks me if I want to remove the hard links. Is that common behavior on Linux or is mcedit ...
3
votes
1answer
115 views
Can we use symbolic link and hard link for directories?
I know we can do that for files. What about directories?
It seems that cpanel uses that a lot.
3
votes
4answers
337 views
What are inodes good for?
I wonder if storing the information about files in inodes instead of directly in the directory is worth the additional overhead. It may be well that I'm overestimating the overhead or overlooking some ...
3
votes
3answers
158 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
1answer
66 views
How can I delete a hardlink to a directory?
Before I get 100s of answers that tell me it is impossible to hardlink directories in linux: yes, I know that.
The file in question appeared in lost+fount after I checked the filesystem with e2fsck ...
2
votes
2answers
111 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
3answers
63 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, ...
2
votes
0answers
84 views
Hard links vs. Soft links: When would you want to use one over the other? [duplicate]
Possible Duplicate:
What is the difference between symbolic and hard links?
Today, my teacher talked about the differences between 'hard links' and 'soft links', but she never really ...
1
vote
3answers
150 views
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:
...
1
vote
2answers
684 views
Keep tracking of symbolic links?
I use symbolic links quite often, but after moving the original file, I lose track of the symbolic link. I also use symbolic links for keeping track of some files in the same directory, but again, I ...
1
vote
1answer
94 views
How do I manually modify an inode?
I am using Ubuntu Linux and, just for fun, I want to create a hardlink to a directory (as seen here). Because I'm just doing this for fun, I'm not looking for any sort of pre-developed ...
1
vote
1answer
139 views
rsync hardlink attempt copies
I've tried setting up a script to hardlink my files to my box.com account (as it's a backup of my music library). As I want to run it automatically to sync my music across several devices, I wanted to ...
1
vote
1answer
653 views
Backing up hard links (rsync)?
My question begins with: Do I actually have hard links on my disk at all (except for "." and ".." of course)? I'm not sure how I would find that out?
If no, the question is already answered.
If yes, ...
1
vote
1answer
137 views
How to get a list all the “aliases” of a file (including of type directory) efficiently?
How can one get the list of all the aliases of a file (including of type directory) efficiently, given that a file:
may have multiple hard links, multipe soft links, multi-level soft links
may be ...
1
vote
2answers
27 views
Incremental backup with hard links for multiple folders
Can anyone refer me to a simple backup script or program, that will backup in the following way:
Incremental
Rotation of X backups
Backup to a mounted drive (no need for remote connections)
Multiple ...
0
votes
1answer
83 views
How hardlink and softlink works in background?
I am looking for an explanation of the following:
what happens in Linux when we create soft link and hardlink
how are they accessible
why do symlinks always display 777 permissions
0
votes
1answer
198 views
Hardlinks in Dropbox not updated
I want to create a backup of a single .tex file. I created the hard link to the file (which is not in Dropbox directory, lets say it is A) inside Dropbox directory. I did this so because I do not want ...
0
votes
0answers
54 views
How to safely remove hard-link to home folder?
In a folder owned by my user /sites/Website there is a dir named ~.
When I cd to this directory, I am redirected to ~/, my home folder.
At first I thought this was a symbolic link, but doing ls ...
0
votes
0answers
153 views
Multiple Linux or Unix Distributions, Same Home Partition or Data?
To avoid conflicts I have always installed multiple Linux and Unix distributions each with it's own home partion or directory, and in the era of 3TB hard drives this is often very practical; I also do ...
0
votes
0answers
102 views
Purpose of hard link and soft link [duplicate]
Possible Duplicate:
What is the difference between symbolic and hard links?
I've read quite a few articles regarding hard links and soft links, but I still dont understand the purpose of ...
-3
votes
1answer
35 views
Invalid cross-device link while Hardlinking in the same file system
I have /home/myuser/Desktop/rc/.netrc file that i want hardlink to /root, ie home directory of root user.
When i do:
ln /home/user/Destkop/rc/.netrc /root
it gives the following error:
ln: ...
