unix directory structure
In Unix directory structure, what is the 2nd column from left all about? Using ls commands. .
In Unix directory structure, what is the 2nd column from left all about? Using ls commands.
Participate on our website and join the conversation
This topic is archived. New comments cannot be posted and votes cannot be cast.
Responses to this topic
DefRef time again: the directory structure is the actual data structure describing your files.
What you refer to is the file list which is a representation of the directory structure
generated by the 'ls' utility.
(oh, and columns are numbered left to right with whitespace chars separating them
- if you're to use 'awk' or 'cut' or 'sort', you must know this well).
pedantically, then, you're wondering what the second column in the long or verbose
'ls' output means?
The column in between the file permission bits (column 1) and the file owner (column 3)?
It's the value of the "link count". A file is 'deleted' when the link count reaches 0,
at which point the zones used by the file are all marked 'free'.
Quick tutorial experiment to be performed in a directory where you have
write/create permission (say, for instance, your home/login dir):
[size:3][tt]touch test.fil
ls -l test.fil
cat >> test.fil
Here is the contents of my test file.
I have put content here so I can identify this file
as being the very one I created. The full reason
for doing this will soon be apparent.
CTRL-D ( <-- you type the Control-plus-'D' keys together)
ls -l test.fil ( <-- if you count up all the keystrokes including the Enter key..)
ln test.fil test2.fil
ls -l test*.fil ( <-- are you seeing double?)
ln -s test.fil test3.fil
ls -l test*.fil ( <-- hmm, symbolic links don't increase link count)
rm test3.fil
ls -l test*.fil
rm test.fil ( <-- remember, this was the name of the original file)
ls -l test*.fil
cat test2.fil ( <-- same old content, but now a different name)
[/tt]
What you refer to is the file list which is a representation of the directory structure
generated by the 'ls' utility.
(oh, and columns are numbered left to right with whitespace chars separating them
- if you're to use 'awk' or 'cut' or 'sort', you must know this well).
pedantically, then, you're wondering what the second column in the long or verbose
'ls' output means?
The column in between the file permission bits (column 1) and the file owner (column 3)?
It's the value of the "link count". A file is 'deleted' when the link count reaches 0,
at which point the zones used by the file are all marked 'free'.
Quick tutorial experiment to be performed in a directory where you have
write/create permission (say, for instance, your home/login dir):
[size:3][tt]touch test.fil
ls -l test.fil
cat >> test.fil
Here is the contents of my test file.
I have put content here so I can identify this file
as being the very one I created. The full reason
for doing this will soon be apparent.
CTRL-D ( <-- you type the Control-plus-'D' keys together)
ls -l test.fil ( <-- if you count up all the keystrokes including the Enter key..)
ln test.fil test2.fil
ls -l test*.fil ( <-- are you seeing double?)
ln -s test.fil test3.fil
ls -l test*.fil ( <-- hmm, symbolic links don't increase link count)
rm test3.fil
ls -l test*.fil
rm test.fil ( <-- remember, this was the name of the original file)
ls -l test*.fil
cat test2.fil ( <-- same old content, but now a different name)
[/tt]