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.
When i want to make a new folder like "test"
folder then if i want to know the Folder size then which command need to use , and is this folder size is fixed ? If i want to increase this folder then is it any way to do this ?
Suppose i make a folder "test2" into my root directory , Then when i run the following command then i found :
#du -h /root/test2 ; it shows :
I found this size is always fixed . But when i keep a file (which size is 4 MB) into this folder then it is possible to keep this 4MB file into this 8K folder . Now my question, how can it possible ? Normally it is not possible in windows .
I am littlebit confused about this matter . Plz anybody can help me about this matter to remove this confusion .
Can be bewildering but: A Folder is a File. It holds info on what files are in the folder. The empty folder shows up as 8K. Then as you add files to the folder it reports on the size of the files in the folder.
The size limit is determined by:
1. The Partition size.
2. Any policies on disc space allocation that may be in force.
In other words it's all automatic and there's nothing you need to do.
I think you confuse folders (directories) and partitions. Create a new folder in windows, right click it in windows explorer and select properties. Under the tab general, you will find size and size on disk (both being zero). This does not imply that you can't add any files in a windows folder.
Further the command du (disk usage) does not give the filesize, but the size-on-disk. The actual size is a lot smaller as can be seen with the command ls -l.
Your HD/partition is divided in blocks of i.e. 512 bytes. A file smaller than 512 bytes will still occupy a block. The command ls -l will report e.g. 20 bytes, but du will report 512 bytes. If the file is between 512 and 1024 bytes, ls -l will report e.g. 900 bytes, but du will report 1024 bytes. Etc etc
Under windows, the block size is influenced by the used filesystem (ntfs/fat16/fat32) in combination with the size of the partition. I assume it's similar under Linux (but don't know the finer details).
While writing this story, I found something that I can't explain. On my system, the size-on-disk for an empty directory is 512 bytes and the size-on-disk for a small file is 4K. Maybe someone has an explanantion (probably filesystem implementation).
Maybe 512 bytes is the allocation to store internal details for a folder in the superblock ( similar idea to file allocation table). Maybe files are always allocated 1 block of disk space.(4K +/- depending on partition size)
well, 512 bytes seems to always be the size of 1 disk sector but the cluster size varies depending on the volume size! Clusters (allocation units) are needed because there are limits in what can be address 12, 16, 32, or 48 bit file systems... You can address a single sector if the drive is small enough!
I'm not real technical on these things but I believe that's sort of the idea in windows and probably holds true in linux for some things to.
So windows would tell you an empty folder/file is 0 bytes but that is lie!!! Every directory entry takes up room including empty ones no matter what system! An empty file or folder cannot possibly be smaller than the cluster size on the formatted volume. Regardless of it being empty, it could be taking up 8KB on the drive!
I use to be more technical on these things when it mattered more for drive size... When you have a 32mb hard drive, every kilobyte counts!