28.09.2018 Views

Linux Dummies 9th

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

318<br />

Part IV: Junior Administrator Boot Camp<br />

Consider this example. Start with a simple command. The du command lists<br />

the contents of the directory you’re now in, along with its subdirectories and<br />

how much hard-drive space it takes up, with a total at the end. Try typing<br />

just the du command by itself. You see a long listing of files that looks something<br />

like this:<br />

rich@testbox:~$ du<br />

4 ./.local/share/totem<br />

8 ./.local/share<br />

12 ./.local<br />

4 ./.config/gnome-session/saved-session<br />

8 ./.config/gnome-session<br />

8 ./.config/gtk-2.0<br />

8 ./.config/totem<br />

40 ./.config<br />

44 ./.pulse<br />

That’s neat, but it probably raises more questions than it answers. The<br />

output gives you a long listing of data, but of what? Do those numbers represent<br />

bytes, kilobytes, or messages from outer space? To clarify, try adding a<br />

simple option to your command:<br />

rich@testbox:~$ du -h<br />

4.0K ./.local/share/totem<br />

8.0K ./.local/share<br />

12K ./.local<br />

4.0K ./.config/gnome-session/saved-session<br />

8.0K ./.config/gnome-session<br />

8.0K ./.config/gtk-2.0<br />

8.0K ./.config/totem<br />

40K ./.config<br />

44K ./.pulse<br />

You’re still issuing the same command, but now you’re providing an additional<br />

instruction about what you want displayed. The -h option tells du to<br />

show you the information in terms that humans can read more easily. Now<br />

Ms, Ks, and Gs appear next to the numbers so you can see how big these<br />

numbers actually are. But wait — there’s more. What if you just want to know<br />

the total amount of disk space this directory and its subdirectories are taking<br />

up? That calls for the -s flag:<br />

rich@testbox:~$ du -s<br />

24064 .<br />

rich@testbox:~$<br />

What if you want the total for a different directory? Or just for one of your<br />

subdirectories? The following command shows, in a human-readable way,<br />

how much hard drive space the Music directory takes up:<br />

du -sh ~/Music

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!