hardlink interview questions
Top hardlink frequently asked interview questions
I understand the differences between symbolic and hard links, but I've never understood why choose one or the other.
Source: (StackOverflow)
I can read in the ln man page:
-L, --logical
make hard links to symbolic link references
I read somewhere that ln -L
could be used to re-link files that were deleted but which are still open, using the /proc
filesystem. For example:
ln -L /proc/1234/fd/12 /tmp/my-file
But I'm getting ENOENT
: No such file or directory. If I try on a different filesystem, I get instead Invalid cross-device link.
If I can't use ln -L
to recover deleted files, then what could it be used for?
Source: (StackOverflow)
I used the following command to create a hard link to an executable:
ln `which xcrun` gcc
The link worked as expected. However, it seems I don't have the permissions to remove it.
$ rm gcc
override rwxr-xr-x root/wheel compressed for gcc? y
rm: gcc: Permission denied
$ unlink gcc
unlink: gcc: Permission denied
Uh oh.
$ ls -l gcc
-rwxr-xr-x 3 root wheel 1172 May 10 2012 gcc
I don't have sudo
access. What do I have to do to delete the hard link?
Source: (StackOverflow)
I have used cp -rl
to copy a folder. When measuring the size of the source and of the result of the copy du -sl
returns slightly different sizes, even though diff
confirms that their content are identical:
$ cp -rl folderA/ folderB/
$ du -sl folderA folderB
98561224 folderA
98590512 folderB
$ diff --brief -ra folderA/ folderB/
$
Both folders reside on the same hard drive, no modifications to any of them have been done between the copy and the measure. I found nothing in the documentation of du
and cp
which could explain the difference.
Source: (StackOverflow)
I've created some hard links on my Windows 7 file system using mklink. It was some time ago and I can't remember for sure where, or which files. When I use Explorer, all files look the same. When I use the command line and type "dir", they all look the same.
How do I find hard links? Or how do I determine whether a specific file IS a hard link?
Source: (StackOverflow)
Is it possible to link two files or folders without having a different extension under Windows?
I'm looking for functionality equivalent to the soft and hard links in Unix.
Source: (StackOverflow)
My objective here is to synchronize my emule credit file (application.dat?) by Dropbox. But the credit file is not inside the Dropbox directory (by default). So I want to make a hard link to get this objective done.
I know I can make a hard link by Perl in Windows. (I learnt Perl in Windows XP. Only hard link is valid in Windows XP.) But it sounds like overkilling to me to make that done by installing new software, as I expect I am not going to use Perl in the near future.
Any ideas? The simpler, the better.
Source: (StackOverflow)
Short: Is it possible to (robo)copy a directory tree using hard links instead of physical copy?
I want to make a daily backup of my data files, every day in it's own directory. Now most files don't change every day, so my idea to speed up backup and use less disk space was to copy the backup of (day-1) to (day) using hard links, then use robocopy to replace the files which have changed since yesterday.
This way I would only need to copy the full backup once to the USB drive, afterwards I could just copy the changes and still have directories containing all the files, sharing files with other backups using hard links. This way I got two full backups but it uses only file space for one+differential, and the backup files are accessible without need for special software, which is a big plus for me.
Is this possible?
Is there a program to create hard link copies of all files in a directory tree?
Am I missing some pitfall I'm not aware of?
Source: (StackOverflow)
On a Win7 NTFS volume, I'm using cwrsync which supports --link-dest correctly to create "snapshot" type backups. So I have:
z:\backups\2010-11-28\cygdrive\c\Users\...
z:\backups\2010-12-02\cygdrive\c\Users\...
The content of 2010-12-02 is mostly hardlinks back to files in the 2010-11-28 directory, but there are a few new or changed files only in 2010-12-02. On linux, the 'du' utility will tell me the actual size taken by each incremental snapshot. On Windows, explorer and du under cygwin are both fooled by hardlinks and shows 2010-12-02 taking up a little more space than 2010-11-28.
Is there a Windows utility that will show the correct space acutally used?
Source: (StackOverflow)
If I have a specific file in a UNIX filesystem, is there a way to use bash to find all links to that file, both symbolic and hard? If I need different commands for each, what are they?
Source: (StackOverflow)
I have searched around and am trying to understand the difference between a hard link and symbolic link (soft link).
I found this link is quite useful. But I am still not very clear. I understand soft link is not a copy of original file, but is a hard link a copy or not?
Source: (StackOverflow)
I was trying to create a directory hard link (not a symbolic one).
I've tried this: mklink /d /h newfolder currentfolder
but it's telling me Access is denied. I don't understand how is access denied because I'm running batch as administrator.
How do we create a directory hard link?
==
Windows Vista Home Premium SP2
Source: (StackOverflow)