Skip to main content

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
0 votes
1 answer
40 views

How to Avoid Copying Large Folders When Creating a chroot Sandbox Using Symlinks, Hard Links, or Bind Mount?

I am working on creating a chroot sandbox and want to avoid the time-consuming and storage-intensive process of copying large directories such as bin, lib, and others. Is it possible to use symbolic ...
Foad's user avatar
  • 379
0 votes
0 answers
25 views

ls long listing column "number of hard links": What does that mean? [duplicate]

Please shed some light on that erratic, second column of ls -l, that numeric column between the 1st one - the permission string - and the third one - the user ownership. I just can't pin it down, what ...
futurewave's user avatar
3 votes
3 answers
257 views

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

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
user avatar
1 vote
1 answer
95 views

mirror a directory tree by hard links for file contents and symlinks for directory structure

what is the best way to mirror an entire directory, say original/, to a new directory, say mirror/, which has the structure mirror/data/ and mirror/tree/, such that every file in the directory ...
windfish's user avatar
  • 113
0 votes
2 answers
92 views

Creating hard links [duplicate]

$ ln fun fun-hard $ ln fun dir1/fun-hard $ ln fun dir2/fun-hard $ ls -1 total 16 drwxrwxr-x 2 me 4096 2018-01-14 16:17 dir1 drwxrwxr-x 2 me 4096 2018-01-14 16:17 dir2 -rw-r—-r—- 4 me 1650 2018-01-10 ...
user599592's user avatar
3 votes
1 answer
136 views

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 ...
norio's user avatar
  • 225
0 votes
2 answers
63 views

Creating a hard link increases the hard link count for two names

gui@Latitude:~$ cd playground gui@Latitude:~/playground$ ls -l total 8 drwxrwxr-x 2 gut gut 4096 set 20 16:18 dir1 -rw-r--r-- 1 gut gut 2903 set 20 14:46 gato gui@Latitude:~/playground $ ln gato gato-...
Guilherme Woolley's user avatar
-1 votes
1 answer
70 views

creating hard links Linux question [duplicate]

From the book The Linux Command Line by William Shotts, page 33: So now we have four instances of the file fun. Let's take a look at our playground directory. [me@linuxbox playground]$ ls -1 total 16 ...
Guilherme Woolley's user avatar
0 votes
0 answers
69 views

How do I get the number of hardlinks of a folder?

I am on Mac. However, I use gstat (GNU stat) so my understanding is that behavior should match linux. I cd to a folder. Then I use gstat --format=%h .. The output is 65. Next, I use gfind . -maxdepth ...
Matt Groth's user avatar
3 votes
1 answer
476 views

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 -...
Sweet Shell O'Mine's user avatar
0 votes
0 answers
49 views

archiver/backups does not save/restore hardlinks

I will explain what kind of hardlinks and where and why they appeared, and why to save them. pictures on the server are saved: ../foto/M/ay/uZbIKBgsXr0222858001661067986M ../foto/M/ay/...
Aliskin's user avatar
  • 121
23 votes
5 answers
5k views

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 ...
dr_'s user avatar
  • 30.7k
0 votes
1 answer
266 views

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 ...
Bob's user avatar
  • 3
1 vote
2 answers
1k views

How to make hardlinks across two NFS shares?

Is there a way to make hard-links, from the client side, across two or more NFS mounts, if the shared NFS directories are hosted on a single backing filesystem? (Such that the server would have no ...
Max Power's user avatar
  • 266
3 votes
2 answers
171 views

How can I copy directories recursively with hardlinks with variables in bash?

The operation I'm trying to do is take directory 1: Dir1 Dir A File A Dir B File B Then use the find command to check every file in Dir 1 for whether or not they have an ...
GeneralTully's user avatar
8 votes
1 answer
669 views

Deleting a hard link's tail file changes the change time of the head or vice versa. Why?

Note: Question although says vice versa but it really does not have any meaning since both of them point to the same inode and its not possible to say which is head and which is tail. Say I have a ...
Himanshuman's user avatar
0 votes
1 answer
1k views

How to find all hardlinks to a given inode? [duplicate]

Is there a way to list all hardlinks, by path/filename, or even just by file name alone, that point to a given inode? I have a file that ls -al reports has three hardlinks, but it should only have two....
DasKraut's user avatar
1 vote
3 answers
719 views

Are hardlinks with rsync a bad solution?

I've read a lot recently about how making backups with rsync using hardlinks (--link-dest) is a good solution as it's so fast and the backup is complete. But surely it's really a very bad solution ...
johnmuir's user avatar
0 votes
1 answer
5k views

getting "Invalid cross-device link" doing a cp -l - same volume

This command - run as Admin (not Root) in directory /volume2/Media/AllOurMedia/1 Our Pictures/Cataloged ( 3-5): cp -l HL_Test.JPG /volume2/phototest/ got this response: cp: cannot create hard link '/...
Bones's user avatar
  • 1
0 votes
0 answers
260 views

rsync --link-dest only matching hard-links at the end of the overall transfer

This command is used in a script used for creating regular backups: rsync -aP --link-dest="$BACKUP_DIR/Latest/TheProject" \ "$SOURCE_DIR/" "$BACKUP_DIR/inProgress/...
Bruno's user avatar
  • 1,143
0 votes
3 answers
1k views

What is the fastest way of copying long paths for the cp command? [duplicate]

I'm controlling a Linux based NAS through SSH on a Windows computer. What I'm trying to do is use the cp -al command to rapidly copy folders from one directory to another, hardlinking all the files ...
GeneralTully's user avatar
0 votes
0 answers
31 views

Where is hard link data stored in the system? [duplicate]

I understand that a hard link is a pointer to the inode of a file, but I can't find any information about where the data about the hard link itself is stored; stuff like its name, path and the index ...
rage's user avatar
  • 1
0 votes
0 answers
223 views

How to remove hardlink to /home created by timeshift?

After installing timeshift on Kali Linux, the same device/drive with a different name/path was created as seen in the system monitor under the File Systems tab: Even after uninstalling timeshift, the ...
ayush7ad6's user avatar
7 votes
1 answer
2k views

Why does this new directory have a link count of 3?

$ sudo su # dd if=/dev/zero of=./myext.img bs=1024 count=100 . . . # modprobe loop # losetup --find --show myext.img /dev/loop0 # mkfs -t myext /dev/loop0 . . . # mkdir mnt # mount /dev/loop0 ./mnt # ...
Shisui's user avatar
  • 173
1 vote
1 answer
682 views

Is symbolic link to hardlink (inode) of directory possible? (that would point to the same physical location after mount on top of that directory?)

Some time ago I wanted to be able to access files in a directory which was overshadowed by later mount point. I recall finding several QAs on SE giving answers, but I recall none I've tried worked. ...
Martian2020's user avatar
  • 1,271
0 votes
3 answers
104 views

linux hardlinks [duplicate]

Okay so I understand that this is a relatively Novice question about linux however in any case concerning hardlinks, If I create a hardlink to an existing file, then delete the original then the data ...
yes itsme's user avatar
0 votes
1 answer
412 views

Hard link to soft link

Can one force ln not to follow a soft link in its first argument? For example, in the following I would like hard to be a hard link to the soft link soft: $ mkdir dir $ ln -s dir soft $ ln soft hard ...
Olius's user avatar
  • 103
1 vote
1 answer
1k views

Why can't I symlink a preexisting file to a target file? [duplicate]

I have an example to better illustrate what I'm talking about: $ touch tas $ ln -s /etc/leviathan_pass/leviathan3 /tmp/l2/tas ln: failed to create symbolic link '/tmp/l2/tas': File exists Basically I ...
arpg's user avatar
  • 13
1 vote
2 answers
2k views

backing up rsync with hard links -- can you hard link files moved to different folders? [duplicate]

I use rsync for incremental backups of my folder /hi AND I use --link-dest=[some.server]/hi. Lets say I have 1000 photos in a folder /hi/there, which is backed up on my server with rsync. Now I move ...
martin-tct's user avatar
0 votes
1 answer
1k views

Why can't I create a hard link in a directory on Ubuntu?

I just started learning about the Linux command line with the book "The Linux Command Line". I was trying to create a hard link by following instructions from the book and typing this ...
EhizSuperstar 's user avatar
1 vote
2 answers
1k views

How can I preserve hardlinks with tar while creating archives of multiple folders?

I have multiple subfolders and some of them contain hardlinks to other subfolders: # mkdir /tmp/data # mkdir /tmp/foo # mkdir /tmp/foo/bar # mkdir /tmp/foo/baz # truncate -s 10M /tmp/foo/bar/file1 # ...
mgutt's user avatar
  • 497
0 votes
1 answer
1k views

On xfs, why can't I hardlink to /tmp/, giving the error "Invalid cross-device link" when my fstab indicates tmp is on the same partition?

My error: ln "99700.fa821246f01ef7f3d86a503e33de5753b50640d69de790fd3db5a5dc31ffa45d1dc64a93f950379ee432aa27cbb0593e6e50ddbb6f8a7e279afaf90cec961233.png" /home/anon/foo.png # ^ ...
Anon's user avatar
  • 215
1 vote
1 answer
2k views

Git - how to add/link subfolders into one git-repository directory

Assuming I have a file structure like this: ├── Project-1/ │   ├── files/ │   └── special-files/ ├── Project-2/ │   ├── files/ │   └── special-files/ └── Project-3/ ├── files/ └── special-...
nath's user avatar
  • 5,924
3 votes
1 answer
4k views

Is there any advantage to using a hard-link on ZFS instead of relying upon deduplication when considering only disk space allocation?

If I want to create multiple instances of a file on a ZFS file system, is there any advantage to using a hard-link instead of relying upon deduplication as a method of preserving disk space? This ...
Zhro's user avatar
  • 2,759
2 votes
1 answer
413 views

Why . and .. are hard links to directories while in *nix systems hard links are not allowed for directories?

I know how hard links and symlinks work and I know why hard links can't be used for directories but in this case, is it some kind of exception? For example I do: ls -al Documents total 8 drwxr-xr-x ...
pjk's user avatar
  • 323
4 votes
1 answer
1k views

GNU cp: What's the difference between `--link` and `--reflink=always`?

What's the difference between --link and --reflink=always? I use the following command as an mv substitute, and I am wondering if using --reflink is a better choice. command gcp -r --link --archive --...
HappyFace's user avatar
  • 1,674
2 votes
1 answer
428 views

about ln command : condition of cross-device

On openSUSE Tumbleweed 20210606 with kernel GNU/Linux 5.12.9-1-default I tried making a hard link of file from /cust to ~/backup: df /cust && df ~/backup && ln -P /cust/customization....
rikuri's user avatar
  • 23
0 votes
0 answers
563 views

What is the difference between link and ld command in linux ..?

First, let tell what do I think about them:- ld ld is a GNU linker according to man page. I think, It takes an object file as input and return an executable output file. ld combines a number of object ...
Abdul_Kuddus's user avatar
0 votes
1 answer
201 views

How can I have it so, that when hardlinks which are not the original, are editted, that they would first be copied then editted?

This is something I imagine I might have to submit a patch or feature request for, but I'd like to know if it is possible to create a hardlink to a file, that when that hardlink which was not the ...
Jannies - They do it for free's user avatar
0 votes
0 answers
131 views

How do I derive multiple bash variables from a folder path and filenames?

This is about the twentieth time I've tried to write this post but it always becomes a behemoth... so I'm going to try and keep it short. Basically what I want to do is push my noobie skills to the ...
Hollis Hurlbut's user avatar
0 votes
2 answers
1k views

du counts hard links only once but hard links have the same size as the first hard link?

I have a large directory structure that has many hard links from the first hard link which lives in a different directory structure. For example dir1 has the following structure : [dir1]$ tree . ├── ...
moth's user avatar
  • 307
3 votes
3 answers
704 views

Why didn't inode change anymore with a hard link

I use Vim 8.2 to edit my files in my Ubuntu 18.04. When I open a file, do some changes and quit with Vim, the inode number of this file will be changed. As my understanding, it's because the backup ...
Yves's user avatar
  • 3,381
1 vote
2 answers
950 views

Finding duplicate files using bash script

How do you write a bash one-liner that will find binary files with identical contents, permissions, and owner on the same ext4 file-system, from the current working directory recursively, and replace ...
Himadri Ganguly's user avatar
0 votes
1 answer
265 views

How to find evey softlink to a directory?

Take /etc dir as example. On my system it has 144 links. And as dir's can't have hardlinks (this is my understanding), the number 144 should refer to softlinks (1 original + 143 softlinks). $ ll -i ...
samshers's user avatar
  • 718
8 votes
2 answers
5k views

How to effectively trace hardlink in Linux?

Softlinks are easily traceable to the original file with readlink etc... but I am having a hard time tracing hardlinks to the original file. $ ll -i /usr/bin/bash /bin/bash 1310813 -rwxr-xr-x 1 ...
samshers's user avatar
  • 718
2 votes
1 answer
295 views

In an NTFS filesystem, does hardlink count, as reported by ls and stat, include other link types as well as hardlinks

Does NTFS count other link types with the same counter it uses for hardlinks? Or does Linux include other link types when it calculates hardlink count in an NTFS filesystem? I have an NTFS filesystem ...
James Watson's user avatar
0 votes
2 answers
135 views

Linking and Copying

I have a few questions regarding links in UNIX Can I say Soft links in UNIX are analogous to shortcuts in windows? Difference between copying and hard-linking? Can anyone give me a use-case where I ...
hakiki_makato's user avatar
1 vote
0 answers
52 views

Using link-dest thwarted by permissions

I'm trying to do a weekly archive of a source folder using the previous week as a source for link-dest. However, the actual source folder has one set of permissions (on files) that differ from what ...
vontrapp's user avatar
  • 111
0 votes
2 answers
174 views

Unix: ".." doesn't point to parent -- how is this possible?

I recently ran into the following problem on a Solaris 11 system I do development on: Somehow, a few directories had their parent pointer (..) pointing to a different directory from the parent. Let'...
A. McKenney's user avatar
0 votes
1 answer
316 views

Move daily backup directories (made by rsync) to another directory in the same partition

I have a daily rsync script backing up my data on an external hard drive at /mnt/X (root of hard drive). I am using --link-dest to use hard links and avoid duplicating data. I need to move all my ...
mohi's user avatar
  • 103

1
2 3 4 5 6