Questions tagged [hard-link]

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

0
votes
1answer
12 views

Link files and dirs with write permissions in target directory

I have a user account at my local library (they use openslx), in which I can store files. My actual home folder is "mounted" (I'm not sure how) in /home/[my_userID]/PERSISTENT instead of /home/[...
0
votes
1answer
29 views

Hard links with MergerFS

If someone uses the command "cp -alr" on a directory located in a non-path preserving merged pool will it always create a directory on the same disk with all of its contents as hard links? For ...
1
vote
1answer
29 views

Safely remove a symlink or hardlink

Does using rm on a symlink or a hard-link remove the source in addition to the link? Is there a good way to delete a hard-link or a symlink without deleting the source? And if there is a good way ...
0
votes
1answer
49 views

Difference between file descriptor and soft/hard link

If soft link and hard link are pointer to a file. And file descriptor is a file handle pointing to an open file. Then what exact difference is between the two if both of them are a kind of pointer ...
0
votes
1answer
42 views

What happens when you copy a hardlink?

Imagine I have a file something/a.txt, which I hardlink from b.txt. Now, if I cp b.txt c.txt, is c.txt a hard link to a.txt, or is it a copy of the contents of a.txt?
0
votes
1answer
43 views

A command to know if some file are “only” an hard link and “not” a symlink [duplicate]

I need a command for an if condition to know if 'file_name' is an hard link (not symlink). Thanks
1
vote
1answer
66 views

What to do when hard link is lost because of my text editor

So, I have a file, for this instance we shall call it $HOME/Documents/hello.txt. I will write some text inside it: Hello, welcome to my text file And I will hard-link this file here: $HOME/Documents/...
1
vote
2answers
44 views

How can you move hardlinks to another disk

If we have a file on a disk and create a hard link pointing to it then we have two references to the same data. If one link gets deleted it does not affect the other link as it is directly pointing ...
2
votes
1answer
78 views

Overlay storage driver internals

A follow-up from this question. My further reading on Docker storage drivers revealed that the overlay driver merges all the image layers into lower layers using a hard link implementation which ...
16
votes
2answers
713 views

How to create a hard link to an inode (ext4)?

If I know the index node (inode) of a file, but I don't know its path (or any of its paths), is it possible to create a hard link to that inode directly? I could find the file using sudo find / -inum ...
1
vote
0answers
30 views

Rsnapshot made my external disk run out of space

I have Rsnapshot doing incremental backups from Client1 to Server1 (RAID 5) within folder "BACKUP". On Server 1, tonight, I copied the "BACKUP"to an external disk for the first time using the command ...
1
vote
1answer
138 views

Why don't FAT filesystems support links? [closed]

FAT filesystems represent files via linked lists of clusters (linked file allocation). They have a region on disk for one or more tables (File Allocation Table) which have as many entries as ...
1
vote
1answer
28 views

Determine extra size of hard link tree

It is relatively common to use a "hard link tree" to create a second backup of a folder that is effectively just a copy of the files that have changed since the original backup. For example, rsync ...
-2
votes
1answer
61 views

creating test1 and test2 files in /var directory in Linux, [closed]

I need to create test1 and test2 files in /var directory in Linux , and creating Hard link for test1 file and soft link for test2 file in /tmp
1
vote
1answer
413 views

unlink delete files which are not links [duplicate]

I created a hard link $ ln hours.sh hours_link test it $ ls -l hours* -rw-r--r-- 2 me staff 653 Apr 12 2018 hours.sh -rw-r--r-- 2 me staff 653 Apr 12 2018 hours_link remove it with unlink $ ...
0
votes
3answers
321 views

How do you count the total number of hard links within a directory?

I've been trying to use the -ls and find commands to total the number of hard link occurrences within a directory. Is there a simple way to accomplish this beyond physically counting all of the link ...
4
votes
3answers
93 views

unique contribution of folder to disk usage

I have a backup containing folders for daily snapshots. To save space, identical files in different snapshots are deduplicated via hard links (generated by rsync). When I'm running out of space, one ...
1
vote
1answer
91 views

Using clamav efficiently when timeshift snapshots are present

I am searching for a simple way to perform a full system scan using clamav on a machine that also has Timeshift based snapshooting enabled. As suggested by this answer on the Ubuntu site, I was using ...
3
votes
1answer
145 views

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 "...
0
votes
1answer
43 views

what is the right approach to copy folder content that include links

we have the following folders / links /files under /usr/hdp/2.6.0.3-8/zookeeper folder -rw-r--r--. 1 root root 794542 Apr 1 2017 zookeeper-3.4.6.2.6.0.3-8.jar drwxr-xr-x. 6 root root 4096 Mar 28 ...
1
vote
0answers
36 views

Some questions about Hard-links, and backups

Recently I accidentally whipped out a directory with important stuff, and now I'm starting to think about the best ways to have backups, a remote copy It's already in place but I was thinking, about ...
-3
votes
1answer
60 views

hard-link inode behaviour

bash: ~/Desktop $ mkdir DIR bash: ~/Desktop $ cd DIR bash: ~/Desktop/DIR $ echo 000_111 > fileA bash: ~/Desktop/DIR $ ln fileA fileB bash: ~/Desktop/DIR $ cat fileA fileB 000_111 ...
0
votes
1answer
135 views

df du hardlinks and space reclaimation

I am really confused on how to build an understanding around hardlinks. I work with a DB hosted on Linux. The Db in order to take backups creates hardlinks to data files in a different directory. ...
-1
votes
1answer
271 views

Send program's serial output to pseudo-terminal used by serial sniffer such as jpnevulator [duplicate]

I am running an application that communicates through a real serial port e.g. /dev/ttyS0 to a remote device. I can configure this application to use /dev/ttyS0, /dev/ttyS1, etc., by passing the ...
1
vote
2answers
51 views

How many times is the disk accessed?

This is regarding generic UFS. From what I understand when an absolute path is given (eg: /home/userU/file.txt) the disk is accessed for each directory and the file. Hence in this case the disk is ...
2
votes
1answer
549 views

How do hard links, symbolic links, and ACL folder permissions interact?

This one was a bit tricky for me to realize, but I came across a very weird behavior involving ACL extended file permissions and hard/symbolic links. I'll do my best to keep my question short and to ...
2
votes
0answers
73 views

HFS+ on fedora, many broken directory hard link [closed]

There is a hard disk. In one directory there are around 1000 directories, and every each one hard linked to other location in the same hard. the problem is that in fedora 35 of them I could open, the ...
11
votes
3answers
5k views

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 ...
1
vote
1answer
228 views

Create hard link if possible, else use symlink

I am trying to write a shell script to create link for file from my dotfiles repo to my home folder. I want to use hard link if possible because it cannot be broken when moving it to somewhere in ...
0
votes
2answers
98 views

Why are there lots of hard links in /usr [closed]

I've read this link, now I simply want to know why there are lots of hard link in /usr. For example, in my Ubuntu server, installed git, I found the command git here: /usr/bin/git. I execute ls -l /...
1
vote
1answer
99 views

Linux - Directory with zero link count (Rancher container)

I have a permission error in a Rancher container's shell when accessing certain directory, but the permissions are correctly set. Then I noticed that the link count for said directory is zero, as ...
1
vote
0answers
503 views

Incremental backups - rsync with hard links, or rsync to zfs with snapshots?

I need to set up a backup server to pull data from on-site linux servers. The server will be running Ubuntu 16.04. A requirement is to be able to access backups of files which have been subsequently ...
1
vote
0answers
638 views

Is /usr/bin/bash the same as /bin/bash (CentOS 7) [duplicate]

Are /usr/bin/bash and /bin/bash the same thing? They seem to have the same inode number and attributes: [vagrant@tmp-ansible-test-vm ip_lookup]$ ls -il /bin/bash /usr/bin/bash 1574356 -rwxr-xr-x. 1 ...
1
vote
1answer
118 views

Paths in ln with hard links and soft links

How does the relative paths work in ln (-s or not)? For example if I type ln -s foo bar/banana.txt what does this mean? What is foo relative to? Because it doesn't seem to be relative to the current ...
0
votes
1answer
193 views

pax command for incremental backup with hard links similar to rsync

I discovered the pax command recently, and was amazed at how efficient it is when copying locally from one SSD to another, for instance. For local backup, I'm contemplating replacing a rsync ...
5
votes
2answers
385 views

Calling a function by a second name (homework)

I'm writing a function called restore that will copy a file from a backup directory to the current directory. I now need to create a hard link to restore so that it can be called as purge. How would I ...
13
votes
2answers
3k views

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 ...
2
votes
1answer
251 views

Simulating a hard-link to a directory [duplicate]

I have a kind of problem. I am trying to hard-link all my dotfiles [files that customize certain apps] in one folder for ease of use, called ~/dotfiles/ , but multiple programs that I have, have ...
0
votes
2answers
960 views

Rm hardlink without removing file/directory itself

Say I create a hardlink with ln x y. Is there a way to remove the link at y without removing the file at x, after I create the link? It looks like I did a rm -rf on y and it deleted x as well, would ...
0
votes
0answers
286 views

Why my rsync -Hav is not copying hard links?

I know this has been asked before, but for some reason my version of rsync -H does not seem to be working consistently. I have a backup system with lots of hard links. I want to copy the thing to a ...
6
votes
1answer
227 views

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 ...
6
votes
2answers
2k views

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 ...
1
vote
1answer
900 views

df and hard links issue for backup

We are doing incremental backup with use of hard links the initial size was 10 TB and we added 1 TB weekly . backup1: 10TB week2: 1TB week3: 1TB du -hs week2 reports 11 TB; it is ok as inode are ...
2
votes
3answers
218 views

Is /etc/init.d hard-linked on CentOS?

I understand why hard links on directories are dangerous (loops, problems for rmdir because of the parent-directory-link) and have read the other questions on that topic. And so I assumed that hard ...
2
votes
3answers
1k views

Why can I not hardlink to a file I don't own even though I can move it?

Example script: #!/bin/sh -e sudo useradd -m user_a sudo useradd -m user_b -g user_a sudo chmod g+w /home/user_a set +e sudo su user_a <<EOF cd umask 027 >> file_a >> file_b >&...
3
votes
5answers
1k views

Link 2 existing files

I have 2 existing files : abcd and xyz. $ cat abcd abcd $ cat xyz xyz Now, when I try to softlink these files, I get this message : ln: cannot create xyz: File exists I do not want to use ln -sf ...
1
vote
2answers
360 views

Convert identical files to hardlinks [duplicate]

I have a lot of music in a tree under one directory, saved in whatever format I initially got it in, for quality. I have a second directory tree which is similar in structure, but with all files in a ...
2
votes
1answer
53 views

Why did `cp -uav` of a git repo show “removed” for some files?

I used cp -uav to update a copy of a git repo, including uncommitted files. Why did it say it's removing files? It looks like this: $ cp -uav repos copy removed 'copy/repos/h/.git/objects/e6/...
0
votes
1answer
32 views

Why soft links from standard folders?

My observation is, most of the python files sitting in some standard locations like site-packages are symbolic links to actual file name(sitting in non-standard folder) pointing to inode. ...
3
votes
1answer
358 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 ...