Clean up and optimize Ubuntu 12.10 Quantal Quetzal

[aggiornamento 2013 Pulizia Ubuntu 12.10 da teminale con output e qualche commento ]

I installed ubuntu 12.10 in September and has now been officially released. It must be said that at this time the operating system has become quite stable and uses few resources. I use LXDE, and I really appreciate this new versions and the advantage of kernel 3.5.0.17. In this period, however, there have been many updates. Therefore, now is the time to do the cleaning.

For cleaning up Ubuntu 12.10 , you can use GUI applications like ubuntu tweak and/or  bleachbit  and with baobab to check disk space  but I prefer to use the terminal.

Here are the commands That I use to save space and clean up all ubuntu 12.10 versions ( Ubuntu, Lubuntu, Xubuntu … )

Cleaning up Ubuntu using the terminal

Let’s start by checking the occupation of disk space you can use the command

df -a

then check the size of the main folders

sudo du -sxm  /[^p]* | sort -nr   | head -n 15

Remove unnecessary libraries and packages:

To delete all package dependencies removed

sudo apt-get autoremove

delete the files (.deb) of the packages that are no longer installed in the system;

sudo apt-get autoclean

The following command is really interesting, because it allows the removal even of the configuration files. This can be useful when you want to reinstall applications from scratch.

sudo apt-get purge

clean  is much more radical than autoclean. It removes any files .deb  from the apt cache, including those relating to the packages currently installed. This command allow a good a good recovery of disk space counterpart is that if you reinstall a package it have to be downloaded.  (1.2 GB recovered)

sudo apt-get clean

##r remove from the cache (/ var / cache / apt) any package, except for the lock files

we can tie together the commands with:

sudo apt-get autoremove && sudo apt-get autoclean && sudo apt-get purge && sudo apt-get clean

( I recovered 1.2 GB )

Now, check and resolve any errors or broken dependencies with:
sudo apt-get check ; sudo apt-get -f install
Remove orphaned libraries
sudo apt-get install deborphan 
sudo apt-get remove --purge `deborphan`; sudo apt-get autoremove
or
sudo deborphan | xargs sudo apt-get -y remove --purge
and
To search and cleaning unused configurations

To search and cleaning folders and unused configurations files we can use :

sudo dpkg --purge `dpkg -l | egrep "^rc" | cut -d ' ' -f3`

to seek only

dpkg -l | egrep "^rc" | cut -d ' ' -f3

Remove Old Kernel

Each version of the kernel can occupy up to 150 MB. If you have downloaded the headers you get 250MB of space. Therefore becomes crucial periodically remove some of the older kernels.

Check the current kernel t

uname -r

View the installed kernels

dpkg --list | grep linux-image

maurizio@Lub12120:~$ dpkg --list | grep linux-image
ii  linux-image-3.5.0-16-generic          3.5.0-16.24                               amd64        Linux kernel image for version 3.5.0 on 64 bit x86 SMP
ii  linux-image-3.5.0-17-generic          3.5.0-17.28                               amd64        Linux kernel image for version 3.5.0 on 64 bit x86 SMP
ii  linux-image-extra-3.5.0-16-generic    3.5.0-16.24                               amd64        Linux kernel image for version 3.5.0 on 64 bit x86 SMP
ii  linux-image-extra-3.5.0-17-generic    3.5.0-17.28                               amd64        Linux kernel image for version 3.5.0 on 64 bit x86 SMP
ii  linux-image-generic                   3.5.0.17.19                               amd64        Generic Linux kernel image

Lists the headers installed

ls /usr/src | grep 'linux-headers'

First remove the headers
using somethings like this

sudo apt-get purge linux-headers-3.5.0-16

then remove any specific kernel that is no longer needed

sudo apt-get purge linux-image-3.5.0-16-generic

( 0.6 GB recovered )

Remove unnecessary location data packets

To remove packages and languages ​​that do not involve using the program localepurge.

sudo apt-get install localepurge

.
In the window that appears after installation, select the languages ​​you wish to protect.
Here you can select the languages ​​that interest us.
for example we can check:
en
en_GB
en_US
en_GB.UTF-8
en_US.UTF-8

then

 sudo localepurge

to reconfigure localepurge type

sudo dpkg-reconfigure localepurge

To save space: remove o shrink files

Let’s start by checking the folders size into home directory.
You can use the command

home directory

Let’s start by checking the folders size into home directory.
You can use the command

du -sm * .[^.]* | sort -nr   | head -n 15

Files to check periodically to save space:

.xession-errors

One of the files that can grow up to tens of GB and that may need to check is the file:
/home/<myhome>/.xsession-errors

This file can be erased from time to time.

or to reduce it and keep last 200 lines of messages

    cd ~
    tail  -n 200 .xsession-errors  > xsession-errors
    mv  xsession-errors .xsession-errors

A home directory that you can grow a lot is the directory /cache.
There there are the browsers cache so to clean up it I prefer to use browser commands.

The directory /home/my-home/tmp should be checked and emptied every so often.

directory  /var

at the root level, from time to time, check the   /var direcotry :
/var/log/
/var/tmp/…  
/var/cache/…

to display the size of the /var

sudo du -sxm /var/* | sort -nr | head -n 15

Alert. You should only delete files. Absolutely not delete the folders that contain them.

Large size file

May be useful to check if exist large size files everyware e for any users.
The command for 750MB size files may be like:

sudo find / -size +750M -exec ls -lhG {} \; | more

Services

When you start ubuntu like any S.O. are activated services that are not always necessary with the inevitable resource consumption. To check the services that are not strictly necessary on a terminal you can use sysv-rc-conf.

to install

sudo apt-get install sysv-rc-conf

to start with

 sudo sysv-rc-conf

Check or uncheck the options to set the start whether or not a service in a given runlevel (Less services are running more resources are available).

Free up RAM

To release the RAM could be useful

sudo -s   
Write the data in the buffer memory to disk.
sync  
Let's free some memory cache inactive
echo 3 > /proc/sys/vm/drop_caches

more: Liberare memoria RAM ubuntu debian linux

Optimize Ubuntu

Manage archives

Install applications to manage archives of files compressed.
If one needs to use the various formats of compressed files evaluate the installation of the following packages.

sudo apt-get install unace unrar zip unzip p7zip-full \
    p7zip-rar sharutils rar uudeview mpack lha arj cabextract file-roller
Common Codecs

A few common codecs

sudo apt-get install libavcodec53 libavformat53 libavutil51 libpostproc52 lame \
libcdaudio1 libdvdnav4 libdvdread4 libfaac0 libfaad2 libfftw3-3 libgsm1 libid3tag0 \
libjack-jackd2-0 libmad0 libmms0 libmp3lame0 libmpcdec6 libmpeg2-4 libjpeg-progs \
mencoder libxine1-ffmpeg  mplayer2 mplayer-gui

Medibuntu

Perhaps you have to evaluate installation of non-free-codec. “Medibuntu (Multimedia, Entertainment & Distractions In Ubuntu) is a repository of packages that cannot be included into the Ubuntu distribution for legal reasons (copyright, license, patent, etc). ”  Medibuntu :: Multimedia, Entertainment & Distractions In Ubuntu

sudo -E wget --output-document=/etc/apt/sources.list.d/medibuntu.list http://www.medibuntu.org/sources.list.d/$(lsb_release -cs).list

sudo apt-get --quiet update
sudo apt-get --yes --quiet --allow-unauthenticated install medibuntu-keyring
sudo apt-get update

w32codecs video codecs for popular proprietary formats not natively supported by mplayer Medibuntu — Details of package w32codecs in lucid

libdvdcss2 for play encrypted DVD Medibuntu — Details of package libdvdcss2 in quantal

Ubuntu 32bit

    sudo apt-get install w32codecs libdvdcss2

Ubuntu 64bit

    sudo apt-get install w64codecs libdvdcss2

FSlint  

FSlint is a useful application to search for duplicate files and not only in Ubuntu and Debian Linux ..

sudo apt-get install fslint

FSlint un utile applicativo per ricercare file duplicati e non solo in Ubuntu Linux

GUI

bleachbit is an effective way to clean a Linux system like Ubuntu: apt cache, browsers cache …

install

sudo apt-get install bleachbit

be used as either a user as root

Ubuntu-Tweak

Ubuntu Tweak allows configuration via GUI Ubuntu easily. Cleaning the cache of web browsers … and the removal of obsolete kernel, Configuring themes, sounds, default applications …

install  :

sudo add-apt-repository ppa:tualatrix/ppa
sudo apt-get update
sudo apt-get install ubuntu-tweak

Device busy

In case of error device busy proceed similarly to what reported in this post device busy fd0 in Lubuntu 12.10

List of useful applications 

Programmi essenziali per Ubuntu

Links:

8 pensieri su “Clean up and optimize Ubuntu 12.10 Quantal Quetzal

  1. Dopo aver seguito questa guida mi si è liberato molto spazio sul disco, ma d’altro canto ho iniziato ad avere problemi con alcune applicazioni tipo KSysguard ed il sistema sembra addorittura appesantito. Come posso ripristinare il corretto funzionamento di KSysguard il quale non si avvia più correttamente? Grazie. Saluti.

    • Premetto che se si sono applicate le varie azioni in maniera CORRETTA è un po’ strano che si sia appensantito. Comunque qualche suggerimento di carattere generale.
      Digitare questi comandi che evidenziano e/o risolvono problemi con i pacchetti.
      Se il sistema era OK nessuno dei comandi dovrà generare messaggi “verbosi” evidenziando che sono state fatte azioni o che ci sono azioni da compiere.

      sudo apt-get check 
      sudo apt-get -f install
      sudo dpkg --configure -a
      

      Per quanto riguardo Ksysguard (stai utilizzando KDE ?) la cosa più semplice da fare e rimuovere il pacchetto con tanto di eventuale configurazione e reinstallare:

      sudo apt-get purge ksysguard
      sudo apt-get autoremove
      sudo apt-get install ksysguard
      

      credo che saranno già stati applicati i tradizionali

      sudo apt-get update
      sudo apt-get upgrade
      
      • Niente da fare. Seguendo le tue istruzioni consigliate mi ha addirittura reinstallato tutto l’ambiente grafico rappresentato dai pacchetti kubuntu-desktop, kde-workspace etc ma al momento l’errore resta. Suggerimenti?

      • Ciao Manolo, nessuna delle istruzioni indicate poteva addirittura “reinstallare” tutto l’ambiente grafico.
        Non esiste; a meno che non si sia trattato di un upgrade. Non è semplice aiutarti senza vedere gli output dei comandi.
        A questo proposito possiamo continuare la discussione su questo post dedicato a ksysguard dove ho messo gli output a video. https://mauriziosiagri.wordpress.com/2013/02/01/ksysguard-il-task-manager-di-kde/

        Invitandoti a continuare la discussione nel post segnalato controlla se il processo ksysguard viene comunque caricato in memoria con

        ps -ef | grep ksysguard
        

        e prova ad avviare come root ksysguard

  2. Continuo sull’altra discussione. Del resto, aggiungo che ho scoperto che a seguito delle operazioni di questa guida non mi funziona nemmeno più la VirtualBox, nemmeno riscaricando i binari e reinstallando

    • Manolo mI sa che hai combinato qualche “pastrocchio” e devi avere problemi con le dipendenze. Allora per aiutare ho messo un altro post https://mauriziosiagri.wordpress.com/2013/02/02/pulizia-ubuntu-12-10-da-teminale-con-output-e-qualche-commento/ .
      In questo secondo post vengono applicati tutti i comandi e viene mostrato l’output a video di ogni singolo comando.
      La procedura è stata applicata a un computer con ubuntu 12.10 64 bit e con installato non solo virtualbox e ksysguard ma anche wine kvm-qemu e mille altre cose. Ovviamente applicati i vari comandi nessun problema virtualbox ok e pure ksysguard.

      A proposito di virtualbox parli di aver scaricato i binari e reinstallato non hai utilizzato quella del repository ufficiale? Comunque continuamo la discussione nei due posts generati anche perchè a mio avviso questi non sono problemi di tipo generale sono specifici della tua macchina.
      Del resto ho applicato molte volte i comandi riportati senza problemi.

      • Grazie ancora per il tuo interesse. Francamente non so proprio cosa possa essere successo. Di fatto sono giunto alla tua guida mentre cercavo metodi alternativi alla pulizia di sistema fatta con Ubuntu-Tweaks. Cercavo metodi alternativi perchè stranamente mi era finito lo spazio su disco. Dunque probabilmente qualche danno sarà stato causato prima di eseguire le tue istruzioni? Ma cosa? E come mai non me ne ero accorto? Bah, mistero!
        Ritornando alle tue domande, non ho installato Virtualbox dai repos ufficiali ma scaricati i binari direttamente dal sito ufficiale. Probabilmente, come dici, c’è qualche problema sulla mia macchina. Continuiamo nelle altre discussioni. Grazie ancora.

Lascia un commento