Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [hard-link]

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

1
vote
1answer
16 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
33 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
45 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
72 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
73 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
0answers
21 views

Using clamav efficiently when timeshift snapshots are present

As from the question title, 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 ...
3
votes
1answer
55 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
32 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
29 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
27 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
62 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
50 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
46 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
159 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
59 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 ...
10
votes
3answers
2k 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
153 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
80 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
0answers
54 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
298 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
336 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
44 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
129 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
382 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 ...
10
votes
1answer
2k 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 ...
1
vote
1answer
114 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
608 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
209 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
199 views

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

A n00b 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 ...
5
votes
2answers
1k 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
598 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
150 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 ...
1
vote
3answers
575 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
904 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
264 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
46 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
30 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. ...
4
votes
1answer
247 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
203 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 ...
35
votes
8answers
5k 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
406 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 ...
37
votes
9answers
6k 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
164 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 ...
29
votes
6answers
5k 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
459 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
2k 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
225 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
108 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
2k 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. ...