Questions tagged [hard-link]

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

Filter by
Sorted by
Tagged with
3
votes
1answer
389 views

rsync inconsistently fails to hardlink

I have a backup script which uses rsync -avz --link-dest=$oldbkp $source $newbkp at its core. The problem is that rsync a lot of times doesn't recognize that a file in $source hasn't changed and so it ...
2
votes
1answer
292 views

How to restore a hardlinked file

I have a filesystem with a series of date stamped archival backups of another filesystem. The backup uses hardlinks to copy only the delta between consecutive archival instances. The drive has had ...
36
votes
8answers
6k views

What is the difference between a hard link and a file?

A hard link is defined as a pointer to an inode. A soft link, also known as a symbolic link, is defined as an independent file pointing to another link without the restrictions of hard links. What is ...
1
vote
1answer
531 views

“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-...
4
votes
1answer
2k views

Do hard links really take up so much disk space?

I've found that I need to use hard links with a particular program (Ableton Live) that is unable to see aliases/symlinks, which is of course how I have all my working files organized. But making hard ...
39
votes
9answers
7k views

Use cases for hardlinks? [closed]

In what situations would one want to use a hard-link rather than a soft-link? I personally have never run across a situation where I'd want to use a hard-link over a soft-link, and the only use-case ...
3
votes
4answers
186 views

Bash: Path or link to a line in a file?

/path/to/fname#line1242 Is there a way to refer to a specific line number in a file as part of the pathname, or some way to package a link to a line number, which looks/behaves like a pathname? For ...
31
votes
6answers
7k views

Replace file with hard link to /dev/null

I'm running an application that writes to log.txt. The app was updated to a new version, making the supported plugins no longer compatible. It forces an enormous amount of errors into log.txt and does ...
2
votes
1answer
642 views

dotfiles: can/should(?) gnu stow make hard links, so I can still use xfce settings gui programs

I'm trying to manage my dotfiles under version control. My dotfiles repos contains a xfce-base folder, this folder contains the .config/xfce4/.../xy-setting.xml stuff. I can stow, or better, symlink ...
3
votes
2answers
3k views

How does tar deal with hardlinked files? [duplicate]

I have a 2.5 TB of data that I want to put in a 2TB hard drive to mail somewhere. It's not hopeless, as a very large fraction of the data consists of duplicate files. I am considering using jdupes ...
0
votes
2answers
296 views

How to claim disk space by removing all the files and hard links?

I've been trying for hours to figure this out but cant seems to do it My question Is I have a file name easy and there's 4 different sub directories in it now what I have to do is delete ...
0
votes
2answers
147 views

Simfs hardlinks whereabouts

I got a weird hardlink at centos 6.5 vps server. It's man made, I assume, but I'm not the one who did it. df tells some info. [root@root]# df Filesystem 1K-blocks Used Available Use% ...
29
votes
4answers
3k views

How to unlink (remove) the special hardlink “.” created for a folder?

On Linux, when you a create folder, it automatically creates two hard links to the corresponding inode. One which is the folder you asked to create, the other being the . special folder this folder. ...
2
votes
1answer
89 views

handy script to reduce hardlink count?

I'm transitioning a large fileset from a filesystem with a high _PC_LINK_MAX (maximum number of hardlinks per inode) to a lower one. In particular, I'm messing about with Amazon EFS, which has a ...
2
votes
1answer
522 views

How can I convert a hard link to a normal file? [duplicate]

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

Are hard links for directories possible on ext2/3/4 filesystems?

I've read that the command (and perhaps the system call, too) for creating hard links will not let one create hard links for directories. I also understand that hard links can pose problems for path-...
0
votes
1answer
2k views

What is the difference between “find -H” and “find -L” command?

When I executed the command both commands gave the same output. I created a soft link and a hard link for a file but still both commands gave the same output. Is there a difference between find -H and ...
4
votes
4answers
495 views

How do I prevent sed from destroying hardinks?

My question is similar to How do I prevent sed -i from destroying symlinks?, but concerning hardlinks. Using sed -i to work on a file destroys all the hardlinks the file has, since sed works by ...
32
votes
5answers
2k views

One file wants to belong to two users. How? Hard linking fails

Two setuid programs, /usr/bin/bar and /usr/bin/baz, share a single configuration file foo. The configuration file's mode is 0640, for it holds sensitive information. The one program runs as bar:bar (...
2
votes
1answer
794 views

How does restorecon handle links?

I noticed that the rule /usr/sbin/shutdown -- gen_context(system_u:object_r:shutdown_exec_t,s0) labels /usr/sbin/shutdown shutdown_exec_t when /usr/sbin is a directory. But it doesn't restore the ...
3
votes
2answers
730 views

cp overwriting without overwriting hardlinks to destination

Say I have the following setup : $ cat fileA textA $ cat fileB textB $ ln fileA myLink $ cat myLink # as expected textA I do not understand the following behaviour : $ cp fileB fileA $ cat myLink #...
7
votes
2answers
3k views

What is the difference between the link and ln commands?

From the man pages: ln - make links between files and link - call the link function to create a link to a file These seem to do the same thing however ln takes a lot of options as well. Is link ...
2
votes
1answer
548 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
3answers
8k 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 ...
3
votes
1answer
3k 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 ...
21
votes
5answers
11k 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 only ...
0
votes
2answers
1k 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
1answer
1k 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 ...
3
votes
2answers
498 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 ...
4
votes
4answers
3k 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 ...
2
votes
1answer
167 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
256 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....
1
vote
2answers
806 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 ...
10
votes
2answers
383 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 ...
-1
votes
1answer
52 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?
5
votes
1answer
241 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, ...
5
votes
1answer
2k 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) ...
3
votes
0answers
796 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 ...
1
vote
2answers
71 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 ...
5
votes
1answer
3k 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 ...
0
votes
2answers
121 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
69 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 ...
1
vote
2answers
203 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 ...
20
votes
2answers
2k 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 ...
15
votes
2answers
18k 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 ...
3
votes
4answers
2k views

Why won't 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 ...
3
votes
1answer
156 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: ...
2
votes
2answers
1k 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 ...
20
votes
4answers
2k 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 ...
2
votes
1answer
139 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 ...