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.
I'm just wondering how to make the df utility report the correct free space on a partition.
I recently freed up some space on one of my partitions by deleting a load of old mail messages.
The du utility reports only 172MB used out of 494MB whereas the df utility reports 425MB used out of 494MB!
I rely on the df -h as a quick check on disk space so it looks a little alarming at present, esp as a load of log files are stored on this partition.
Does linux have fragmentation issues similar to windows & if so is there a way I can 'reclaim' some of this lost space?
Do I have to worry about this or shall I just assume the du utility is reporting the correct disk usage and ignore the df utility from now on?
Depending on the filesystem, there may be some room reserved exclusively for the root user.
Also, on a filesystem like reiserfs, there will be a journal which won't be counted by "du". Plus add things like the directories. You may try running "sync; sync" and recheck the results.
On my Dell laptop, I just installed SuSE linux. I have a partition mounted on /usr/local. There presently are not any files in it but 33M are being used according to "df".
If the --apparent-size option is used with the "du" command, then a text file that only contains the characters 'medmedia\n' will count as 9 bytes long, but may actually take up 1024 bytes. ( Some file systems will store such a file in the directory structure itself to save space. )
Also, if there are sparse files being used, the actual space being taken up on a drive will differ greatly from the reported file size normally reported by "du".
If the drive is failing, you may have a large number of blocks marked bad.
Are you sure you were not in a subdirectory on the partition. The "du" command will report the sizes of files below the directory you current are in, but not count files above it.
One other possibility is that you have been hacked, and a root kit is hiding the existance of files from the "du" command. If /var and /tmp are on their own partitions, are they mounted with the "noexec" option?
The trash bin is located in your home directory and not on other partitions.
Also, the contents of the Trashbin are counted by "du".
Run "du ~/" | grep "Trash" to see for yourself.
The files in ".local/share/Trash" will show up.
The /var partition will contain a large number of empty directories, which will occupy space on the hard drive, but not being files will not add anything to the results of "du". However, this would probably only account for a 1 MB discrepancy.
My /var directory has about 1300 directories and around 250 files under 100 bytes in length. How does yours compare?
Try running a consistency check on your /var partition. Also scan for root kits. Most of things that I mentioned that can cause a discrepancy between du and df will cause du to be higher. Except for the --apparent-sizes option. Check if du is aliased. Also run du with the full pathname. Chehave the oposck the consistency of these commands. I.E. "sudo rpm -V coreutils"
What filesystem are you using. An ext filesystem may have too many blocks reserved. The reiserfs and ext3 filesystem might have a journal that is way to large. Could someone or something have run reiserfsck --badblocks with a badblocks file that marked most of your blocks as bad?
Given the huge difference between the two values, I keep coming up wondering about hacker/rootkit damage or a hardware problem with the drive. The /var parition is world writable, so that is where mischief usually starts.
satinet, he is having a problem with the /var directory. It is on it's own partition. Root's trash bin if it exists will be in the /root directory on the (/) root partition. A user's will be in their home directory on the /home directory which often is in its own partition. The /var partition doesn't contain a trash bin. And the du command would still count any files in it. The trash bin is used by the KDE or Gnome window managers. The du and df commands are core utilities and will notice any files including the trash bin in the hidden .kde directory.
Putting an item in the trashbin will place it in ~/.local/share/trash/files/ and a .info file will be in ~/.local/share/trash/info/
If you log into KDE or Gnome as the root user (which would be a good thing), then these may not even exist.