Getting rid of history

One of the most common things happening when a computer is being used for a long time is that there tends to be various logs and extra files, which remain anything but useful. Given the previous, it is sometimes in place to purge some historical records and throw  those residuals out from the system altogether.  Here are some cleaning techniques for Linux boxes.

Option 1: Cleaning with Bleachbit

Bleachbit is a very easy to use and remains one of those programs, which I  recommend for all the users from newbie to expert. Bleachbit features a very nice GUI, which can really safe time if you are in a hurry. One big bonus is also that Bleachbit hardly ever produces catastrophical errors, which might lead to an unstable system. Bleachbit is commonly found from the software repositories of various Linux distributions. See more from: http://bleachbit.sourceforge.net/

Option 2: Cleaning  /var manually  (might be risky)

Linux systems feature a directory called /var, which holds logs and cached files inside. Generally speaking, logs and cached files (previously downloaded files) should not be needed so you can purge them if you want.  The two most safest choices to delete within /var are the subdirectories titled as log and cache. You might also want to delete some maintenance mails from the mail directory and you can also check the tmp subdirectory as well. Overall, tweaking the /var directory does remain a bit risky and might cause harm to the system if applied wrongly.

Edit. 17th of Ocotober: On many occasions it might be beneficial to remove the files inside log and cache folders. Sometimes removing those entire folders might cause unneeded hardships.

Option 3: Cleaning your history via terminal (Debian family)

In Debian family (Ubuntu,Debian, Linux Mint etc.) there are two specifically useful apt-get commands to help out cleaning cached files and leftover programs. I use sudo on the below but it could be a regular root user as well.

sudo apt-get clean = Cleans cached files from  /var/cache/apt/archives/ and /var/cache/apt/archives/partial/
sudo apt-get autoremove = Removes all the programs/dependencies, which were previously used by a, now uninstalled, program(s). You need to apply apt-get update before using the autoremove command like above.

Option 4: Cleaning the terminal client’s history

Cleaning the terminal client’s command history is quite useful from time to time and also very easy to do. As a root or a sudo you only need to type history -c and all your previous inputs will disappear. If you are being extemely cautious you can also reset the terminal with reset command – eventhough this remains a bit unpractical after history is purged since no user inputs remain.

When simple strategies are not enough

Consider this scenario: You are selling your computer. You might think that the simple deleting strategies are not enough since almost always some residual private data is being left on the hard drives. There also exist various programs, which are designed for data retrieval and thus a malicious person might be able to obtain some of your personal files (this topic will be discussed further on a later occasion).   What you might need to do is to wipe your hard drive clean by scrambeling all the data in it. The most easiest way to wipe the data out of your hard drive is to get a Linux live cd/dvd, which allows you to boot your machine without actually mounting any hard drives. If hard drives were to be mounted the cleaning would not be successful since, by default, your computer would refuse to wipe any mounted/currently being used hard drives clean.

In any case, once you are inside your live cd/dvd environment of choice you can open a terminal and execute as a root or a sudo the following dangerous command:

dd if=/dev/zero of=/dev/sda bs=1M

The command above will wipe all data from here to oblivion from a device called sda. Before executing the above command do make sure that the drive you want to get completely cleaned is actually sda and not hda or something else. If you are in any way uncertain do use a program such as gparted, which will reveal all your hard drives via nice GUI.

Before attempting any of the above steps I will strongly advice you to backup all your important data – since accidents and unintended results could, can and might occur.