Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I believe you are referring to the "total 28" - that is the total files in the directory and subdirectories...
The number can be deceptive, as a directory always has two links, one to itself, and one to its parent, and you have to deduct those... the real confusion is caused by directories that have directories... each of these has a link to its parent directory, which can inflate the count.
It would be true if you had a 1K block size... 28672/1024=28
But it doesn't fit my system at all (4k block):
Code:
$ ls -lh /home
total 108K
drwxr-xr-x. 4 root root 4.0K Jul 11 2010 Fedora
drwx------. 30 hsm hsm 4.0K Dec 16 2010 hsm
drwxr-xr-x. 120 jesse family 8.0K Feb 13 01:36 mine
drwxr-xr-x. 2 root root 48K Oct 31 2008 lost+found
drwxr-xr-x. 75 pam family 4.0K Jan 17 19:18 another
drwxr-xr-x. 3 root root 4.0K Jul 15 2010 repository
drwxr-xr-x. 4 root root 4.0K Dec 23 19:03 sys
drwx------. 22 testing testing 4.0K Jul 14 2012 testing
So unless, I'm looking at something wrong, 4+4+8+48+4+4+4+4=80. not 108
Personally, I think the number is useless.
Found a reference... it is the file size / 1024, not block count. What it does for directory size (which is undefined) is not clear. It also seems to drop "." files...
What about if you use the -s option...
ls -ls /home
In my case, I get the same result as with ls -lh. The block size is reported, but the computation doesn't work. Using the file size/1024 should work... if you can read the directory.
There is some ambiguity, as some filesystems the file length is not normal. The stat(2) man page indicates that the field st_size is the length of regular files and symbolic links. That doesn't work for directories or pipes (either undefined, or invalid). It doesn't work for directories very well because directories on some filesystems may have large holes in the allocation because they use a hash/btree for access speed, thus the block count would indicate a small file, but the file size could indicate a large one. Holes may also occur in regular files in the same way, but they are marked as regular files - and may be copied (a directory can't, when using cp to "copy" a directory, it actually creates a new directory and then copies whatever files are in the original directory to the new directory).
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.