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!
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.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
Hmmm ... nice attempt of an explanation, but I don't think
it's correct. On 4 different machines here I get four different
sizes, and they're all under 1K (616,624,704,512) ... so the
"human-readable" didn't quite mess up the results.
Now, without checking the source for ReiserFS or ls, one can make an educated guess that what is reported by the directory size is the size of the directory itself - that is, the size of the directory name and its contents' names and attributes.
Believe it or not, each directory entry you make takes up disk space - more on some filesystems than on others. Take FAT for example: if you create a new, empty directory that directory takes up space in the file allocation table. If the filename is longer than a FAT-16 8.3 filename, behind the scenes that directory is broken up into multiple directory entries (a FUGLY hack, I might add) and that all takes up at LEAST one cluster (anywhere from 512bytes to 32KB depending on formatting options). EXT2 works in a similar way - each directory takes up a cluster, plus there needs to be meta-data stored, that is, the directory's timestamp, permissions, etc. not to mention the mappings to the files that directory contains. Some other filesystems are a little more efficient and store this info in a b-tree structure (ReiserFS, XFS, and if I recall correctly UFS as well) which resmbles an RDBMS more closely than a conventional filesystem.
I hope this helped shed some light on things rather than confused you more. Filesystems are actually fairly complex structures.
Well some filesystems (ReiserFS) are "zero-slack" which means that if a file is 1 byte, it takes one byte (well, plus a couple of delimiters). Others (ext2, uncompressed NTFS, FAT) require that whether file is 1 byte or 511 bytes on a filesystem partitioned with 512-byte clusters, that the file be allocated a minimum of one FULL cluster - that is, 512 bytes. The wasted space is usually referred to as "slack"
Why does LS report the file size as one byte? Because the file's contents is one byte. You're confusing file size with disk usage. If you dual boot Windows, here's a quick demonstration:
On an uncompressed FAT or NTFS partition, create an uncompressed file which is say, *picks an abitrary number* 42 bytes. Open up that file's properties, and in the properties tab, check out two entries:
* file size
* space used on disk (I forgot exactly what the two fields are called)
The numbers will be different. One will show the size of the file's contents, and the other will show how much space on the disk is allocated to it. The difference between the two is allocated but unusable space called "slack"