Monday, October 12, 2009

11 ways to Completely Remove unwanted files from Ubuntu/Linux

Today i am going to write a new post about "Safely Removing unwanted files from your Linux/Ubuntu partition to free-up more space for new application's and speedup performance of OS" . I have collected some best and safe way to erase unwanted files from linux, and i listed those way for you.

Important's of removing unwanted files:
  • our first gain on removing unwanted files is freeup hardDisk space.
  • large amount of unwanted files will make linux slower under some condition's.
  • getting more space to installing new application's.
  • erasing some evidence of your activity
  • and make your system control in you hand.

Here is the 11 ways:

first of all we should know which folders are used as TMP and cache in linux to delete them.

your photo gallery thumbnails are created in the following folders
you can delete these folders. this thumbnails folders takes 28Mib on my PC.

Installed app's Package's:
when ever you use apt or synaptic to install packages. it will download packages and save those packages to this directory.
you can delete these packages,but before deleting this files you should remember "these files are your need application's .deb so if you want to install this packages in future without download new files, please move these files to other places.

$ apt:
apt-get have feature to remove no longer needed packages from ubuntu. todo run this commend on terminal:
$ sudo apt-get autoclean

Synaptic Package manager:

in synaptic package manager click on status button on left bottom, and then click on "Not installed (Residual config)".now synaptic will give list of packages that you removed, if anything there mark all for complete removal, and then click apply.

Remove Package configuration files:

When removing a application apt also give you a list of no longer needed dependencies to remove. When you select purge(ie: completely remove) will erase only packages, the configuration files will remain to remove these configuration files you need to run a simple bash code.

Run in Terminal:
echo "Searching for unwanted configuration files..."
purgelist=`sudo dpkg -l | grep ^rc | awk 'print $2 '`
sudo aptitude purge $purgelist
exit 0;

Delete files older than X days:

here we using find utility for this. this code will search for a file that older than X(user decided) days on the directory and delete.
find /path/to/files* -mtime +5 -exec rm {} \;

Auto remove on shutdown:

ubuntu stores many TMp files on /tmp folder. we have an idea to automatically remove these when each time you shutdown.

Sysklogd provides two logging services, one for your system and the other for your kernel. It sits in /etc/init.d/ and is a service that starts and stops with your computer. we need to modify this file to remove tmp folder.

first create backup of this file:
sudo cp /etc/init.d/sysklogd /etc/init.d/sksklogd.bak

Now we can modify our file with a happy conscious knowing we’ve made a backup.Now we can modify our file with a happy conscious knowing we’ve made a backup.
gksu gedit /etc/init.d/sysklogd
here i am used gedit to edit this file.
Once you’ve got it open, look for the part that says:
log_begin_msg “Stopping system log daemon…”
start-stop-daemon –stop –quiet –pidfile $pidfile –name syslogd
log_end_msg $?

You’ll want to add the below line just before the double semi-colons “;;” above. Note also that “;;” looks something like a spider face, which may be of use to you at some point down the road.

rm -fr /tmp/* /tmp/.??*

That’s the command that will remove just about anything from your /tmp directory.
Once you’ve added it, save the file and exit Gedit. When you shutdown, your /tmp directory will have emptied!

Removing dupe file's:

there is a nice program to find duplicate files from linux named as fdupes.
to install fdupes(15KiB or near):
sudo apt-get install fdupes

fdupes calculates the md5 hash of the files to compare them, and since each file will have a unique hash, the program identifies duplicates correctly. I let it run in the directory which contains my files recursively (which makes it check for duplicates across different directories within the specified directory, and saved the output to a file by doing:
$fdupes -r ./stuff > dupes.txt

Then, deleting the duplicates was as easy as checking dupes.txt and deleting the offending directories. fdupes also can prompt you to delete the duplicates as you go along, but I had way too many files, and wanted to do the deleting at my own pace. The deletion function is useful if you are only checking for duplicates in a given directory with a few files in it.

and also don't forget to clean your trash!

Softwares with GUI:

you can use the following applications to remove unwanted files on linux. these app's can delete some files listed above,the sad newes is still there are no app to remove all unwanted files on linux, we have to do all in manual.
ok here is the list of 3best apps:


1 comment:

  1. Nice tool...

    i found an interesting way to remove unwanted file.