5 Linux Speed Tips - page 2
Quick Launchers, File Manager Shortcuts
Viewing Available Disk SpaceI work with audio and digital photo files, so I need to keep an eye on how much disk space I have. This little command-line incantation spits it out long before graphical file managers finish adding it all up:
$ df -h | grep ^/dev Filesystem Size Used Avail Use% Mounted on /dev/sdb1 19G 3.3G 15G 19% / /dev/sdb2 54G 3.8G 47G 8% /home /dev/sda1 193G 118G 66G 65% /home/carla/sda1df is the "disk-free" command. -h means "human-readable". Piping it through grep weeds out the temp, udev, and other filesystems that have nothing to do with available disk space. The caret, ^, means "beginning of the line matches only." Without using grep to filter the results it looks like this:
Filesystem Size Used Avail Use% Mounted on /dev/sdb1 19G 3.3G 15G 19% / tmpfs 506M 0 506M 0% /lib/init/rw udev 10M 740K 9.3M 8% /dev tmpfs 506M 0 506M 0% /dev/shm /dev/sdb2 54G 3.8G 47G 8% /home /dev/sda1 193G 118G 66G 65% /home/carla/sda1Without ^, it would still display the udev and tempfs filesystems.
Finding Biggest DirectoriesThis little du (disk used) incantation sorts directories by size, so you can quickly find disk hogs. This example displays all directories one gigabyte or larger, starting from the current working directory, sorted with the biggest last:
$ du -h | grep ^[0-9.]*G | sort -n [...] 23G ./sda1/carla 36G ./sda1/photos/2007 39G ./sda1/Photos 53G ./sda1/photos 118G ./sda1 121G .Again, -h means "human-readable", instead of in bytes with no commas. grep ^[0-9.]*G means "show lines beginning with any number that also ends in capital G", and then sort -n puts them in order. To see the largest values first, use rn, reverse numbering. You can specify any directory like this:
$ du -h /home/carla/* | grep ^[0-9.]*G | sort -nYou need the asterisk wildcard, which means "everything", to display subdirectories.
This finds the ten biggest directories:
$ du -h |grep ^[0-9.]*G | sort -rn| head -n 10If you don't have directories that take up gigabytes, M is megabytes and K is kilobytes.
# find top ten biggest directories
alias topten='du -h |grep ^[0-9.]*G | sort -rn| head -n 10'
~/.bashrc is read after new logins, so to get instant gratification open a new terminal and type in your new alias:
$ topten 121G . 118G ./sda1 53G ./sda1/photos 39G ./sda1/Photos 36G ./sda1/photos/2007 23G ./sda1/carla 17G ./sda1/photos/2008 16G ./sda1/Photos/2007-sept-montana 16G ./sda1/photos/2007/2007-sept-montana 5.4G ./sda1/carla/picturesType alias to see your existing aliases.
- Skip Ahead
- 1. Quick Launchers, File Manager Shortcuts
- 2. Quick Launchers, File Manager Shortcuts
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: RHEL 6.5, Debian 7.2 and EOL for Linux 3.0.x
- 5Linux Top 3: CoreOS, Oracle Enterprise Linux 7 and Ubuntu 14.10