Linux Commands for 99 Bottles of Beer and Disk Space - page 2
99 Bottles of Beer, df commanddu shows the total space used by my home directory:
$ du -hs ~ 122G /home/carlahs means use human-readable numbers and show the total for the whole directory, and ~ is a shortcut for "my own home directory". Use this to get the total size of any directory. If you leave off the s it lists every subdirectory and file. You can also get the size of any individual file:
$ du -h worried-man.wav 18M worried-man.wavOr all the same type of files in the current directory:
$ du -h *.jpg 144K jpgtest1.jpg 132K jpgtest.jpg 28K nascarcap.jpg 128K firefox-win.jpg 48K funny-pictures-cat-is-grumpy.jpgThis finds the ten biggest directories or files in my home directory:
$ du -a ~ | sort -nr | head -n 10 127353376 /home/carla 122939388 /home/carla/sda1 55389844 /home/carla/sda1/photos 40650788 /home/carla/sda1/Photos 37020884 /home/carla/sda1/photos/2007 23911504 /home/carla/sda1/carla 17702480 /home/carla/sda1/photos/2008 16547200 /home/carla/sda1/Photos/2007-sept-montana 16547200 /home/carla/sda1/photos/2007/2007-sept-montana 5634812 /home/carla/sda1/carla/picturesIf you leave off the a option it only reports directories. I can't use the human-readable option because that does not sort correctly. I'm sure there is some nifty regular expression that knows 1000M is bigger than 1000K, but I haven't figured it out yet. Ace admins script these commands to monitor disk usage, and to send them alerts when disks get too full.
See man df, man du, man bash, man sort, and the excellent book Learning the Bash Shell to learn more.
Solid state disks (SSDs) made a splash in consumer technology, and now the technology has its eyes on the enterprise storage market. Download this eBook to see what SSDs can do for your infrastructure and review the pros and cons of this potentially game-changing storage technology.
- 1Linux Top 3: GNOME 3.12 and New Betas for Ubuntu 14.04 and OpenMandriva Lx 2014.0
- 2Linux Top 3: Linus Lashes out, Linux 3.14 Gets PIE and Ubuntu One is Done.
- 3Linux Top 3: Ubuntu 14.04, Debian Gives Squeeze More Life and Red Hat Goes Atomic
- 4Linux Top 3: Linux 3.11, Kubuntu Goes Commercial
- 5Linux Top 3: RHEL 6.5, Debian 7.2 and EOL for Linux 3.0.x