Operating System - HP-UX
1748018 Members
3337 Online
108757 Solutions
New Discussion юеВ

Re: one simple query regarding ls -lrt output

 
SOLVED
Go to solution
Amit Jindal_1
Frequent Advisor

one simple query regarding ls -lrt output

Hi HP UX Gurus . ..
I have got a question regarding the ls -lrt output. Feeling a bit embarrassed to raise this kiddie type question ... who cares! my boss don't have a id in this forum..

$ pwd
/home/user1

$ ls -lart
total 2566
-rw-r--r-- 1 user1 users 362 Apr 15 2003 .kshrc
-rw-r--r-- 1 user1 users 636 Apr 15 2003 .login
-rw-r--r-- 1 user1 users 535 Apr 15 2003 .profile
-rw-r--r-- 1 user1 users 591 Apr 15 2003 .cshrc
-rwxr-xr-x 1 user1 users 24576 Jan 26 2004 a.out
-rwxr-xr-x 1 user1 users 629 Sep 21 2005 spacevg
-rwxr-xr-x 1 user1 users 197 Nov 11 2005 final
drwxr-xr-x 2771 root root 48128 Jun 20 2006 ..
drwxr-xr-x 4 user1 users 96 Jan 15 2007 perf
-rw------- 1 user1 users 34506 Nov 13 11:13 .gpmhp-host1
-r-xr-xr-x 1 user1 users 1188080 Mar 7 11:08 tcpdump
-rwxr-xr-x 1 user1 users 149 Mar 19 17:36 .history
drwxr-xr-x 3 user1 users 1024 Mar 20 09:24 .
-rw------- 1 user1 users 2694 Mar 20 09:26 .sh_history

$ du -sk .
1244 .

$ df -g .
/home (/dev/vg00/lvol_home ) :
8192 file system block size 1024 fragment size
212992 total blocks 596 total free blocks
596 allocated free blocks 22912 total i-nodes
386 total free i-nodes 386 allocated free i-nodes
1073741835 file system id vxfs file system type
0 flags 255 file system name length
/home file system specific string
$

#########################

1) What is the first line from the output of ls -lrt signifies ? I read somewhere that it is total number of blocks used. Can I somehow map the no of the blocks to the du -sk output.

2)The second column of the output is the link count to that file, so against . and .. the values are 3 and 2771 respectively. What does that means ? I guess.. is my home dir /home/user1 is being referred from 2 other locations ?
16 REPLIES 16
Avinash20
Honored Contributor

Re: one simple query regarding ls -lrt output

1) What is the first line from the output of ls -lrt signifies ? I read somewhere that it is total number of blocks used. Can I somehow map the no of the blocks to the du -sk output.

## It signifies number of files
"Light travels faster than sound. That's why some people appear bright until you hear them speak."
Avinash20
Honored Contributor

Re: one simple query regarding ls -lrt output

Sorry.. Ignore my above post !!
"Light travels faster than sound. That's why some people appear bright until you hear them speak."
Amit Jindal_1
Frequent Advisor

Re: one simple query regarding ls -lrt output

But how can it be the number of files ?? I have done a ls -lart and there are 12 files. Then it should be 12 not 2566.

Avinash20
Honored Contributor

Re: one simple query regarding ls -lrt output

Answer 1>

When an option is specified that results in a listing of directory and/or file sizes in bytes or blocks (such as the -s or -l (ell) option), a total count of blocks, including indirect blocks, is also printed at the beginning of the listing.
"Light travels faster than sound. That's why some people appear bright until you hear them speak."
Avinash20
Honored Contributor

Re: one simple query regarding ls -lrt output

The second column of the output is the hard link count
"Light travels faster than sound. That's why some people appear bright until you hear them speak."
Avinash20
Honored Contributor

Re: one simple query regarding ls -lrt output

You could find the link file via

find / -linkedto
"Light travels faster than sound. That's why some people appear bright until you hear them speak."
Amit Jindal_1
Frequent Advisor

Re: one simple query regarding ls -lrt output

I know the second column is the hard link count.


drwxr-xr-x 2771 root root 48128 Jun 20 2006 ..
drwxr-xr-x 3 user1 users 1024 Mar 20 09:24 .

Against . the ln count is 3 and against .. it is 2771, What are these numbers ? how can i verify it ? The hard link is not there for folders then who is referring to the home dir ? I have checked the ls -li output for inode numbers, but no answers ..

Avinash20
Honored Contributor

Re: one simple query regarding ls -lrt output

shivaji@root/tmp/test1>ll
total 32
-rw-rw-rw- 1 root sys 8 Mar 3 20:45 a
-rw-rw-rw- 1 root sys 19 Mar 3 20:46 b
shivaji@root/tmp/test1>find / -linkedto a
/tmp/test1/a
shivaji@root/tmp/test1>
shivaji@root/tmp/test1>
shivaji@root/tmp/test1>ln -s a c
shivaji@root/tmp/test1>ll
total 32
-rw-rw-rw- 1 root sys 8 Mar 3 20:45 a
-rw-rw-rw- 1 root sys 19 Mar 3 20:46 b
lrwxrwxrwx 1 root sys 1 Mar 3 20:59 c -> a
shivaji@root/tmp/test1>find / -linkedto a
/tmp/test1/a
shivaji@root/tmp/test1>find /tmp/test1 -linkedto a
/tmp/test1/a
shivaji@root/tmp/test1>ll
total 32
-rw-rw-rw- 1 root sys 8 Mar 3 20:45 a
-rw-rw-rw- 1 root sys 19 Mar 3 20:46 b
lrwxrwxrwx 1 root sys 1 Mar 3 20:59 c -> a
shivaji@root/tmp/test1>find / -linkedto c
/tmp/test1/c
shivaji@root/tmp/test1>ln a d
shivaji@root/tmp/test1>ll
total 48
-rw-rw-rw- 2 root sys 8 Mar 3 20:45 a
-rw-rw-rw- 1 root sys 19 Mar 3 20:46 b
lrwxrwxrwx 1 root sys 1 Mar 3 20:59 c -> a
-rw-rw-rw- 2 root sys 8 Mar 3 20:45 d


AS suggested earlier, you could verify it via

# find / -linkedto
"Light travels faster than sound. That's why some people appear bright until you hear them speak."
Avinash20
Honored Contributor

Re: one simple query regarding ls -lrt output

For directories
drwxr-xr-x 2771 root root 48128 Jun 20 2006 ..
drwxr-xr-x 3 user1 users 1024 Mar 20 09:24 .

Let me check
"Light travels faster than sound. That's why some people appear bright until you hear them speak."