Thursday, May 9, 2013

Agedu – A Unix utility for tracking down wasted disk space

agedu scans a directory tree and produces reports about how much disk space is used in each directory and subdirectory, and also how that usage of disk space corresponds to files with last-access times a long time ago. In other words, agedu is a tool you might use to help you free up disk space. It lets you see which directories are taking up the most space, as du does; but unlike du, it also distinguishes between large collections of data which are still in use and ones which have not been accessed in months or years – for instance, large archives downloaded, unpacked, used once, and never cleaned up. Where du helps you find what's using your disk space, agedu helps you find what's wasting your disk space. agedu has several operating modes. In one mode, it scans your disk and builds an index file containing a data structure which allows it to efficiently retrieve any information it might need. Typically, you would use it in this mode first, and then run it in one of a number of ‘query’ modes to display a report of the disk space usage of a particular directory and its subdirectories. Those reports can be produced as plain text (much like du) or as HTML. agedu can even run as a miniature web server, presenting each directory's HTML report with hyperlinks to let you navigate around the file system to similar reports for other directories.

Install agedu in ubuntu

Open the terminal and run the following command

sudo apt-get install agedu

Using agedu Syntax

agedu [ options ] action [action...]

You would typically start using agedu by telling it to do a scan of a directory tree and build an index. This is done with a command such as

$ agedu -s /home/test

which will build a large data file called agedu.dat in your current directory. (If that current directory is inside /home/test, don't worry – agedu is smart enough to discount its own index file.) Having built the index, you would now query it for reports of disk space usage. If you have a graphical web browser, the simplest and nicest way to query the index is by running agedu in web server mode:

$ agedu -w

which will print (among other messages) a URL on its standard output along the lines of

URL: http://127.0.0.1:48638/

(That URL will always begin with ‘127.’, meaning that it's in the localhost address space. So only processes running on the same computer can even try to connect to that web server, and also there is access control to prevent other users from seeing it – see below for more detail.) Now paste that URL into your web browser, and you will be shown a graphical representation of the disk usage in /home/test and its immediate subdirectories, with varying colours used to show the difference between disused and recently-accessed data. Click on any subdirectory to descend into it and see a report for its subdirectories in turn; click on parts of the pathname at the top of any page to return to higher-level directories. When you've finished browsing, you can just press Ctrl-D to send an end-of-file indication to agedu, and it will shut down. After that, you probably want to delete the data file agedu.dat, since it's pretty large. In fact, the command agedu -R will do this for you; and you can chain agedu commands on the same command line, so that instead of the above you could have done $ agedu -s /home/test -w -R

0 comments:

Post a Comment