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 wrote a quick script to perform a "df | grep /my/directory/here" and pull out the amount of used space. When the number didn't look right to me, I went back and noticed a difference between df and df -h. When I simply do a "df" I might get a number for "used" as 197370964. If I do a df -h it will tell me 189G.
Realizing that the number that df is giving me is the number of 1024 blocks, wouldn't that mean that 197370964 should translate to 202GB (197370964 x 1024)? I don't understand the discrepancy. How does one manually convert the # of 1024 blocks to a human-readable number?
your looking at it wrong, 197370964 / 1024 = ~192,745. 192,745 / 1024 = ~188. I lost the decimal points each time, but roughly it comes out to 188.2 GB (well technically GiB but I prefer to use GB by it's original meaning). Also -h is short for --human-readable as it goes anyway.
Looks like I was beaten to it, oh well, not gunna remove it now anyways =P.
Last edited by r3sistance; 02-11-2009 at 10:07 AM.
Thanks to all who replied, what you say makes sense of course. However, I'm still confused why my OS would report 189G and not 188G if the 'true' answer is 188.2. Shouldn't it round down?
The reason I'm re-visiting this issue of course is because the larger the number gets, the bigger the discrepancy. To give full disk usage statistics I'm giving the total disk space allocated for a set of servers... each server is showing 2.1T when I do a "df -h". If I just do a "df" and then /1024 3 times (to get gigs) I get 2.01G:
2163071696 / 1024 = 2112374.703125 MB
2112374.703125 / 1024 = 2062.8659210205078125 GB
2062.8659210205078125 / 1024 = 2.01451750099658966064453125 TB
I realize it's not much of a difference, but how do I know what the 'true' value is? Is Linux automatically rounding up every time?
Now that df -H has been brought up, I tried that and I got back 2.3T. So is the allocated disk space for this filesystem 2.1T, 2.01T, or 2.3T? And why the differences?