Freeing Up Disk Space in Ubuntu


After using Ubuntu for some time, you might find that the disk begins to get full. You can keep an eye on disk usage by using the following command in a terminal window:

df -h

This will show the free space in terms of megabytes or gigabytes for each partition, also expressed as a percentage figure. If the disk does start to get full, you can take steps to make more space available.

Emptying the /tmp Folder
An easy way to regain disk space is to empty the /tmp folder. Like its counterpart in the Windows operating system, this is the folder in which temporary data is stored. Some applications clean up after themselves, but others don’t, leaving behind many megabytes of detritus.

Because the /tmp folder is accessed practically every second the system is up and running, to empty it safely, it’s necessary to switch to run level 1. This ensures few other programs are running, and avoids the risk of deleting data that is in use. First, switch to the text console by pressing Ctrl+Alt+F1. Then enter these commands to switch to run level 1:

sudo killall gdm
sudo init 1

A recovery menu will appear. Select the Drop to Root Shell Prompt option. Then enter the following to empty the /tmp folder and reboot:

rm -rf /tmp/*

On a similar theme, don’t forget to empty the desktop Trash. This can hold many megabytes of old data. If you see an error message about permissions when emptying the Trash, you can do so manually from a terminal window. Simply type sudo rm -rf ~/.Trash/* to get the job done.

Emptying the Cache of Package Files
You might also choose to clear out the Advanced Packaging Tool (APT) cache of old .deb package files. On a system that has been very frequently updated, this can free many megabytes (possibly gigabytes) of space. You can empty the cache by typing the following command in a terminal window:

sudo rm -f /var/cache/apt/archives/*.deb

However, the apt-get clean and apt-get autoclean commands are considered a much safer way to remove unwanted package files.

If you want to restore any packages later on, simply locate them in the Synaptic Package Manager list, click the check box, and click Mark for Reinstallation. This will cause the package to be downloaded, installed, and configured.

Be careful to type the command to empty the APT cache exactly as it’s written. Even inserting an additional space can lead to very bad consequences!

Removing Unused Software
If you still need disk space, consider uninstalling unused programs. As you’ve learned, you can manage software through the Synaptic Package Manager (System -> Administration -> Synaptic Package Manager).

To remove a package, click its check box and select Mark for Removal. However, it’s not a good idea to simply scroll down the list and remove anything that seems dispensable.
Because of the way Linux works, many seemingly insignificant packages are actually vital to the running of the system. Instead, it’s a better idea to look for programs on the Applications menu, and then return to the Synaptic Package Manager to remove them by searching for their names.

As always, removing software can create dependency problems, so you might find yourself limited in what software you can actually remove.

If you want to remove all the desktop games, simply search for gnome-games and gnome-games-data in the Synaptic Package Manager, and mark them for removal.

Source of Information : Apress Beginning Ubuntu Linux


Subscribe to Computing Tech

Enter your email address:

Delivered by FeedBurner

Add to Technorati Favorites Top Blogs