What is the link count in the inode of a newly-created directory and what command do I use to determine this?

SaucyJim
SaucyJim used Ask the Experts™
on
I am filing out a questionnaire and want to be sure I answer every question as accurately as possible. I have scoured the web for this question and it continues to elude me. I believe the link count to a newly created directory would be zero, but the question refers to the inode of the directory.

Thanks in advance for a command and output containing this information. :)
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
ozo
Most Valuable Expert 2014
Top Expert 2015

Commented:
2
mkdir directory
ls -ld directory
As ozo says, the link count of a newly created directory is 2. But you might want to understand why.

The directory it is created in has a link to it with the name it was given -- that's 1

Inside the directory there is a link created that is given the name '.' -- that's 2

The second column from the output of 'ls -al' shows you  the number of links.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial