Hard disks nowadays indeed come with lots of storage space. However, if you continuously add data without cleaning the unnecessary bits and bytes, some
day you will surely run out of free space. I compile the LFYCD, and therefore need
to download and test a lot of software. I always try to build the software from source. After a successful software installation, there is no need for the built binaries in the source directory. If I forget to clean them, after a few days, I run out of free space.
So it becomes necessary for me to find a tool that eases my house-cleaning job. The du (disk usage) command and two GUI tools-KDirStat for KDE and Baobab for du tells me about disk usage Let's start with the du command, which summarises the disk usage of each file and directory on a disk. If you run it without any arguments, it displays the disk usage of files and subdirectories in the present working directory. Now, try the following commands instead (note that my present working directory is my desktop):
sandeep@linux-i7c8:-/Desktop> du -ch
4.1M ./My Stuff/Blender 2.46 review/images 4.2M ./My Stuff/Blender 2.46 review
5.9M ./My Stuff/Swap/ Avidernux
2.4M ./My Stuff/Swap/SOng
5.IM ./My Stuff/Swap/VLC
14M ./My Stuff/Swap
27M ./My Stuff
17M /PDF Bangalore
82M
82M total
The -c option here gives the grand total, and the -h option presents the size in human-readable form. What if you want this du listing of the file sizes in an ascending order? Try the following command:
2.4M ./My Stuff/Swap/SOng
41M ./My Stuff/Blender 2.46 review/images
4.2M ./My Stuff/Blender 2.46 review
5.lM ./My Stuff/Swap/VLC
5.9M ./My Stuff/Swap/Avidemux
14M ./My Stuff/Swap
17M ./PDF Bangalore
27M ./My Stuff
82M
82M total
Compare the above output with the previous oneŽdo you notice that the order of the directory listing has changed now? Piping the previous output to the sort command helps achieve this with the aid of the (numerical-sort) switch, which reorders the output based on the file sizes provided by the du command.
In this manner you can check the contents of the largest directory and see if there are any unnecessary files there. If so, delete them to free up space. Another handy command is dfthat you can use to check the disk space usage on all mounted file systems:
sandeep@linux-i7cB:-> df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sdal udev /dev/sda3
5.4G 2.5G 2.6G 50% /
247M IBOK 246M 1% /dev 2BG llG 1BG 37% /home
Adding the -k flag to dfpresents the file sizes in a human readable form, viz. in KBs, MBs or GBs instead of lK block sizes.
All this is pretty nifty, but let's face it: it's often difficult to work with command line tools when the disk space is large and the number of files are more. In this case the GUI tools such as KDirStat for KDE and Baobab for GNOME come to the rescue.




Reply With Quote
Copyright Techfuels
Bookmarks