hard-link

Why hard link doesn't corrupt if we remove the original file?

Why hard link doesn't corrupt if we remove the original file? Why the hard link doesn’t corrupt if we remove the original file? If I remove the original file then the softlink gets corrupt but hard link doesn’t so why it does’t corrupt Asked By: Rahul Sharma || Source It is because hardlinks are essentially …

Total answers: 3

Hard link as destination of cp and rsync

Hard link as destination of cp and rsync Where do I find documentation of behavior of cp and rsync commands when the destination path shares the inode with another path? In other words, when I do $ cp [options] src dest $ rsync [options] src dest and when there is dest2 that is a hard …

Total answers: 1

How does `ls` find hard links?

How does `ls` find hard links? Setup The following sequence of commands is setup for my question. root@cd330f76096d:/# cd root@cd330f76096d:~# ls root@cd330f76096d:~# mkdir -p my_dir/my_subdir root@cd330f76096d:~# ls -hAil total 12K 6175969 -rw-r–r– 1 root root 3.1K Oct 15 2021 .bashrc 6175970 -rw-r–r– 1 root root 161 Jul 9 2019 .profile 7382820 drwxr-xr-x 3 root root …

Total answers: 1

home/user/Desktop and Public Folders Show as Type Link (broken) (inode/symlink)

home/user/Desktop and Public Folders Show as Type Link (broken) (inode/symlink) Ubuntu 22.04 LTS asked me for an update which I did and apparently everything went ok but upon restarting all my home folders appeared in my Desktop. Looking into my home folder I found out that home/user/Desktop and Public folders show as: Type Link (broken) …

Total answers: 3

Is '..' really a hard link?

Is '..' really a hard link? This is a bit of a theoretical question, but it’s important to use proper names for things. In UNIX/Linux file systems, .. points to the parent directory. However, we know that hard links cannot point to directories, because that has the potential to break the acyclic graph structure of …

Total answers: 5

Hard links on a mounted disk

Hard links on a mounted disk I have a work laptop that I will soon have to return to my employer. Having foreseen this, I ordered a second internal disk and mounted it at /home/<user> so that I can just pull it out and mount it in the next machine without having to go through …

Total answers: 1

Hardlink that "split" when a file changes

Hardlink that "split" when a file changes Is it possible (in classical ext4, and/or in any other filesystem) to create two files that point to the same content, such that if one file is modified, the content is duplicated and the two files become different? It would be very practical to save space on my …

Total answers: 3

Properly unlinking hard links

Properly unlinking hard links I have a script that goes like this ln /myfile /dev/${uniquename}/myfile I want to remove the link of /dev/somename/myfile to decrease the link count. How do I do this? Asked By: e_mam106 || Source TL;DR… just delete the file name you don’t want (with rm). If you create a hard link …

Total answers: 4

Atomically write a file without changing inodes (preserve hard link)

Atomically write a file without changing inodes (preserve hard link) The normal way to safely, atomically write a file X on Unix is: Write the new file contents to a temporary file Y. rename(2) Y to X In two steps it appears that we have done nothing but change X “in-place”. It is protected against …

Total answers: 1

Why I can't create a hard link from device file in other than /dev directory?

Why I can't create a hard link from device file in other than /dev directory? When I wanted to create a hard link in my /home directory in root mode, Linux showed the following error message: ln: failed to create hard link ‘my_sdb’ => ‘/dev/sda1’: Invalid cross-device link The above error message is shown below: …

Total answers: 3

cp behaves weirdly when . (dot) or .. (dot dot) are the source directory

cp behaves weirdly when . (dot) or .. (dot dot) are the source directory This answer reveals that one can copy all files – including hidden ones – from directory src into directory dest like so: mkdir dest cp -r src/. dest There is no explanation in the answer or its comments as to why …

Total answers: 2

The number of links for a folder doesn't reflect the real status?

The number of links for a folder doesn't reflect the real status? A question for ls command. root@cqcloud script]# ls /var/www/html -la total 36 drwxr-xr-x 9 root root 4096 Aug 31 01:12 . drwxr-xr-x 7 root root 4096 Aug 31 01:10 .. drwxr-xr-x 2 root root 4096 Aug 26 04:07 cmd drwxr-xr-x 5 root root …

Total answers: 1

Info on cp –preserve=links

Info on cp –preserve=links I’m trying to understand what cp –preserve=links does when used by itself. From my tests it seems that it copies a normal file normally and dereferences symlinks, but it seems like it just has the same effect as cp -L when used on a single file. Is that true or is …

Total answers: 2

Nautilus – no support for hard links?

Nautilus – no support for hard links? I finally got round to studying and understanding hard links in my quest to check I have understood the basics, of which I have managed to skip a lot of. After realizing how brilliant they are, I wonder why there isn’t better support for them in Ubuntu’s default …

Total answers: 2

Do hard links really take up so much disk space?

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 links is creating what appears to be duplicates of …

Total answers: 1

Use cases for hardlinks?

Use cases for hardlinks? 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 I’ve come across when searching the web is deduplicating identical files. Asked By: Matthew Cline …

Total answers: 9

Replace file with hard link to /dev/null

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 not seem to support writing to a different log file. How can I write …

Total answers: 7

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

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. Example: $ mkdir folder $ ls -li total …

Total answers: 4

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

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 (that is, as user bar, group bar); the other as baz:baz. Changing users is …

Total answers: 5