Ubuntu Maintenance

Remove partial packages, unused dependences, orphaned packages

You have installed a lot of applications, uninstalled them.  A lot of times when you apt-get remove all those dependencies stay behind. There are a lot that think aptitude is the answer but I have found that when you aptitude remove an application it removes stuff you don’t want removed. Ubuntu has a few methods that will free up disc space and make your OS lean and fast.

First thing first there is a few commands that can clean up your disc.  I will explain them as we go.  First command is the package autoclean. What autoclean does is remove partial packages from the system.  To use autoclean type the following command in a terminal:

sudo apt-get autoclean
```Then enact the package clean command.  What this commnad does is to clean remove .deb packages that apt caches when you install/update programs.  To use the clean command type the following in a terminal window:```
sudo apt-get clean
```You can then use the autoremove command.  What the autoremove command does is to remove packages installed as dependencies after the original package is removed from the system.  To use autoremove tye the following in a terminal window:```
sudo apt-get autoremove
```Next step is to install the gtkOrphan GUI.  What gtkorphan does is to find packages that were once used but no longer have any purpose.  Be careful as to not remove the Gstreamer packages as they are for mp3 encoder/decoding and DVD playback.  Do not remove them.  To install gtkOrphan type the following in a terminal windowt:```
sudo apt-get install gtkorphan
```You will then be able to use gtkOrphan by going to System--->Administraion--->Remove orphaned packages.  It is pretty self-explanatory.  After you have completed the recommendations of this article you should have a slick clean Ubuntu OS.

### Remove old linux kernels.

dpkg -l ’linux-*’ | sed ‘/^ii/!d;/’"$(uname -r | sed “s/\(.*\)-\([^0-9]\+\)/\1/”)"’/d;s/^[^ ]* [^ ]* \([^ ]*\).*/\1/;/[0-9]/!d’ | xargs sudo apt-get -y purge This command will remove all kernel images expect the current one. hemal@hemal-desktop:~$ dpkg -l ’linux-*’ | sed ‘/^ii/!d;/’"$(uname -r | sed “s/\(.*\)-\([^0-9]\+\)/\1/”)"’/d;s/^[^ ]* [^ ]* \([^ ]*\).*/\1/;/[0-9]/!d’ | xargs sudo apt-get -y purge Reading package lists… Done Building dependency tree        Reading state information… Done The following packages will be REMOVED:   linux-headers-3.2.0-23* linux-headers-3.2.0-23-generic-pae*   linux-headers-3.2.0-25* linux-headers-3.2.0-25-generic-pae*   linux-headers-3.2.0-26* linux-headers-3.2.0-26-generic-pae*   linux-headers-3.2.0-27* linux-headers-3.2.0-27-generic-pae*   linux-headers-3.2.0-29* linux-headers-3.2.0-29-generic-pae*   linux-headers-3.2.0-30* linux-headers-3.2.0-30-generic-pae*   linux-headers-3.2.0-31* linux-headers-3.2.0-31-generic-pae*   linux-headers-3.2.0-32* linux-headers-3.2.0-32-generic-pae*   linux-headers-3.2.0-33* linux-headers-3.2.0-33-generic-pae*   linux-headers-3.2.0-34* linux-headers-3.2.0-34-generic-pae*   linux-headers-3.2.0-35* linux-headers-3.2.0-35-generic-pae*   linux-headers-generic-pae* linux-image-3.2.0-31-generic-pae*   linux-image-3.2.0-32-generic-pae* linux-image-3.2.0-33-generic-pae*   linux-image-3.2.0-34-generic-pae* 0 upgraded, 0 newly installed, 27 to remove and 0 not upgraded. After this operation, 1,195 MB disk space will be freed.


### Speed up Ubuntu

\* Show Hidden Startup Apps:

sudo sed -i "s/NoDisplay=true/NoDisplay=false/g" /etc/xdg/autostart/\*.desktop \* Install Preload from Software Center

\* Change Swappiness Value 1. Run terminal 2. Enter following line to see current swappiness value

cat /proc/sys/vm/swappiness (default value in Ubuntu for swappiness is 60) 3. Open file /etc/sysctl.conf in a text editor, I did sudo gedit /etc/sysctl.conf 4\. Enter the following parameter # Decrease swappiness value vm.swappiness=10