LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 02-05-2016, 12:56 PM   #1
ballsystemlord
Member
 
Registered: Aug 2014
Distribution: Devuan
Posts: 214

Rep: Reputation: Disabled
How can a dir have 17 non-hard non-sym links


So, I found a dir whose absolute path is /var/cache with the following stat info:
Code:
  File: '/var/cache'
  Size: 4096            Blocks: 8          IO Block: 4096   directory
Device: 803h/2051d      Inode: 3850482     Links: 17
Access: (0755/drwxr-xr-x)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2016-01-05 22:39:57.751115545 -0500
Modify: 2016-01-19 23:01:47.215809957 -0500
Change: 2016-01-19 23:01:47.215809957 -0500
 Birth: -
I wanted to move the said dir to another file system. The problem is that I can't figure out where it links to. The file system it's on is ext4 (don't know if it makes a difference.)
I executed
Code:
find /etc /usr /var /run /bin /sbin /lib64 /tmp /opt -samefile /var/cache; find -L /etc /usr /var /run /bin /sbin /lib64 /tmp /opt -samefile /var/cache
I also tried the same with the inode number.
I see simmilar for other dirs too / has 27 links.
Perhaps these are in proc?
 
Old 02-05-2016, 01:38 PM   #2
astrogeek
Moderator
 
Registered: Oct 2008
Distribution: Slackware [64]-X.{0|1|2|37|-current} ::12<=X<=15, FreeBSD_12{.0|.1}
Posts: 6,258
Blog Entries: 24

Rep: Reputation: 4193Reputation: 4193Reputation: 4193Reputation: 4193Reputation: 4193Reputation: 4193Reputation: 4193Reputation: 4193Reputation: 4193Reputation: 4193Reputation: 4193
There will be a hard link for (at least) each of the following...

* The directory name, directory
* The directory name, directory/
* The directory self reference, directory/.
* The parent reference of all sub-directories, directory/subdir/..

That can be a lot of links!
 
Old 02-05-2016, 02:22 PM   #3
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,770

Rep: Reputation: 2210Reputation: 2210Reputation: 2210Reputation: 2210Reputation: 2210Reputation: 2210Reputation: 2210Reputation: 2210Reputation: 2210Reputation: 2210Reputation: 2210
A directory will always have at least 2 hard links. Those are the link from the parent directory and the "." link to itself. Each immediate subdirectory also has a ".." link back to its parent. Those are the only permitted hard links to a directory. Any others constitute filesystem corruption. A link count of 17 just means that there are 15 subdirectories. You can go ahead and move that whole /var/cache tree with no problem.

Or, just throw it away. After all, it's just a cache and will be repopulated automatically. About the only thing that might be worth keeping are the packages that were downloaded for installing/updating, and that's only if you have keepackages set for one or more repos.
 
Old 02-09-2016, 09:57 PM   #4
ballsystemlord
Member
 
Registered: Aug 2014
Distribution: Devuan
Posts: 214

Original Poster
Rep: Reputation: Disabled
[solved]

Thanks, I was over thinking that one (takes gun, points at foot, changes mind, starts writing C).
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Help me with sym links Germany_chris Linux - General 7 12-18-2015 03:43 AM
No CD/DVD sym links in 13.1 Woodsman Slackware 12 08-17-2011 12:36 PM
Sym links and hard links akudewan Linux - Newbie 4 02-09-2005 05:08 AM
sym links -- RealPlayer lmellen Linux - Newbie 2 08-29-2004 02:29 PM
Dead sym links Hangdog42 Linux - General 5 10-02-2003 04:35 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 07:46 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration