Archivio

Posts Tagged ‘du’

Clean up and optimize Ubuntu 13.04 Raring Ringtail

New_icons_17 Pulire e ottimizzare Ubuntu risorse

New_icons_17 Pulire e ottimizzare Ubuntu 13.04 Raring Ringatail – con applicazioni GUI

I installed ubuntu 13.04   raring ringtail two week beforet it was officially released. I installaed Lubuntu 13.04. However, I often use as a desktop environment the awesome window manager.  I  appreciate  the advantage of kernel 3.8.xx that leads to an improvement in the recognition of hardware devices. In Lubuntu strangely I’m currently experiencing some annoying logout. Now is the time to do the cleaning. In this post thas use as template previous Clean up and optimize Ubuntu 12.10 Quantal Quetzali I have added output of commands.

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

Here are the commands That I use to save space and clean up all Ubuntu 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
maurizio@lub12-10-i2c:~$ df -a
Filesystem     1K-blocks      Used Available Use% Mounted on
/dev/sda3       20027728  11473844   7529864  61% /
....
/dev/sda13      98645612  71807680  21820332  77% /media/Backup
....

then check the size of the main folders

sudo du -sxm  /[^p]* | sort -nr   | head -n 15
maurizio@rarl1304:~$ sudo du -sxm  /[^p]* | sort -nr   | head -n 15
6202	/home
3483	/usr
916	/var
398	/lib
68	/root
55	/boot
17	/etc
10	/sbin
10	/bin
4	/lib32
...

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.

sudo apt-get clean

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

I usually tie together the commands with:

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

In my case the directory /var is not particularly large and the recovery of space is small. But it is also possible to recover more than 1 GB of disk space

Now, check and resolve any errors or broken dependencies with:
sudo apt-get check ; sudo apt-get -f install
maurizio@rarl1304:~$ sudo apt-get check ; sudo apt-get -f install
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Reading package lists... Done
Building dependency tree       
Reading state information... Done
0 upgraded, 0 newly installed, 0 to remove and 3 not upgraded.

OK. There were no problems. Better that way.

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

Everything ok

...
0 upgraded, 0 newly installed, 0 to remove 
...
To search and cleaning unused configurations

To search folders and unused configurations files we can use :

dpkg -l | egrep "^rc" | cut -d ' ' -f3
maurizio@rarl1304:~$ dpkg -l | egrep "^rc" | cut -d ' ' -f3
fglrx
jackd2
libconfig++9:amd64
libffado2
libxml++2.6-2
qjackctl

To cleaning a configuration we can use

sudo dpkg --purge jackd2

or to cleaning all unused configurations files we can use :

sudo dpkg --purge `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
maurizio@rarl1304:~$ uname -r
3.8.0-21-generic

View the installed kernels

dpkg --list | grep linux-image

maurizio@rarl1304:~$ dpkg --list | grep linux-image 
ii  linux-image-3.8.0-19-generic          3.8.0-19.30                         amd64        Linux kernel image for version 3.8.0 on 64 bit x86 SMP
ii  linux-image-3.8.0-21-generic          3.8.0-21.32                         amd64        Linux kernel image for version 3.8.0 on 64 bit x86 SMP
ii  linux-image-extra-3.8.0-19-generic    3.8.0-19.30                         amd64        Linux kernel image for version 3.8.0 on 64 bit x86 SMP
ii  linux-image-extra-3.8.0-21-generic    3.8.0-21.32                         amd64        Linux kernel image for version 3.8.0 on 64 bit x86 SMP
ii  linux-image-generic                   3.8.0.21.37                         amd64        Generic Linux kernel image

Lists the headers installed

ls /usr/src | grep 'linux-headers'
maurizio@rarl1304:~$ ls /usr/src | grep 'linux-headers'
linux-headers-3.8.0-19
linux-headers-3.8.0-19-generic
linux-headers-3.8.0-21
linux-headers-3.8.0-21-generic

First remove the headers
using somethings like this

sudo apt-get purge linux-headers-3.8.0-19
maurizio@rarl1304:~$ ls /usr/src | grep 'linux-headers' 
maurizio@rarl1304:~$ sudo apt-get purge linux-headers-3.8.0-19
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages will be REMOVED:
  linux-headers-3.8.0-19* linux-headers-3.8.0-19-generic*
0 upgraded, 0 newly installed, 2 to remove and 3 not upgraded.
After this operation, 72,1 MB disk space will be freed.
Do you want to continue [Y/n]? 
(Reading database ... 192109 files and directories currently installed.)
Removing linux-headers-3.8.0-19-generic ...
Removing linux-headers-3.8.0-19 ...

then remove any specific kernel that is no longer needed

sudo apt-get purge linux-image-3.8.0-19-generic

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

home directory

Home directory is a bit large so we can check
the subfolders size using the commands
cd /home/

du -sm * .[^.]* | sort -nr   | head -n 15
maurizio@rarl1304:~$ sudo du -sm * .[^.]* | sort -nr | head -n 15
3438	GrandOrgueCache
1159	.cache
709	Music
392	Fin
119	.config
103	Downloads
62	.opera
61	.local
47	Videos
...

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 directory :
/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

  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

We can try to maximize ram  in ubuntu 13.04 with

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
Ubuntu List of useful applications

Ubuntu essential programs – ubuntu 12.10 e 12.04

or

Programmi essenziali per Ubuntu 12.04 e Ubuntu 12.10

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  BleachBit in Ubuntu

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

Links:

Clean up and optimize Ubuntu 12.10 Quantal Quetzal

ottobre 24, 2012 8 commenti

[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:

Calcolare la dimensione e svuotare il cestino da terminale in ubuntu/linux

Du è il comando che può essere efficacemente utilizzato via terminale per determinare lo spazio occupato dal cestino in ubuntu/linux.

Per visualizzare l’occupazione di spazio di Trash :

du -hs ~/.local/share/Trash/* | sort -h

Per visualizzare dimensione i files  che possono essere cancellati in sicurezza

du -hs ~/.local/share/Trash/files/* | sort -h

Se si gradisce l’ordine inverso si può utilizza l’opzione -r quindi sort diventa sort -hr

Per svuotare il cestino in sicurezza. Quando si usa rm ( remove ) è opportuno prestare la dovuta attenzione.

rm -rf  ~/.local/share/Trash/files/*

Determinare la dimensione delle directory in linux

du è il comando per determinare la dimensione di una directory in Linux

la forma base di du command è

du /dir/da/calcolare

le sue opzioni più interessanti

du -hc ## con somma totale è fomato (KB,MB.GB )

Per avere la dimensione del primo livello di sottodirectories

du -sm  ./* | sort -nr

se è supportata l’opzione -d

du -h  -d 1

-m ## dimensione in MB

Per la dimensione delle directories del filesystem ordinate e in MB

sudo du -sm  /[^p]* | sort -nr

Se si desiderano exludere i file system esterni ( -x) e limitare alle prime 15 dir.

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

per determinare le dimensioni dellahome inluce le directory nascoste.

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

.[^.]* dir nascoste

se è supportato -d

sudo du  -m -d 1  /  |  sort -nr

du opzioni

du --help
Usage: du [OPTION]... [FILE]...
  or:  du [OPTION]... --files0-from=F
Summarise disk usage of each FILE, recursively for directories.

Mandatory arguments to long options are mandatory for short options too.
  -0, --null            end each output line with NUL, not newline
  -a, --all             write counts for all files, not just directories
      --apparent-size   print apparent sizes, rather than disk usage; although
                          the apparent size is usually smaller, it may be
                          larger due to holes in ('sparse') files, internal
                          fragmentation, indirect blocks, and the like
  -B, --block-size=SIZE  scale sizes by SIZE before printing them; e.g.,
                           '-BM' prints sizes in units of 1,048,576 bytes;
                           see SIZE format below
  -b, --bytes           equivalent to '--apparent-size --block-size=1'
  -c, --total           produce a grand total
  -D, --dereference-args  dereference only symlinks that are listed on the
                          command line
  -d, --max-depth=N     print the total for a directory (or file, with --all)
                          only if it is N or fewer levels below the command
                          line argument;  --max-depth=0 is the same as
                          --summarize
      --files0-from=F   summarise disk usage of the
                          NUL-terminated file names specified in file F;
                          if F is -, then read names from standard input
  -H                    equivalent to --dereference-args (-D)
  -h, --human-readable  print sizes in human readable format (e.g., 1K 234M 2G)
      --inodes          list inode usage information instead of block usage
  -k                    like --block-size=1K
  -L, --dereference     dereference all symbolic links
  -l, --count-links     count sizes many times if hard linked
  -m                    like --block-size=1M
  -P, --no-dereference  don't follow any symbolic links (this is the default)
  -S, --separate-dirs   for directories do not include size of subdirectories
      --si              like -h, but use powers of 1000 not 1024
  -s, --summarize       display only a total for each argument
  -t, --threshold=SIZE  exclude entries smaller than SIZE if positive,
                          or entries greater than SIZE if negative
      --time            show time of the last modification of any file in the
                          directory, or any of its subdirectories
      --time=WORD       show time as WORD instead of modification time:
                          atime, access, use, ctime or status
      --time-style=STYLE  show times using STYLE, which can be:
                            full-iso, long-iso, iso, or +FORMAT;
                            FORMAT is interpreted like in 'date'
  -X, --exclude-from=FILE  exclude files that match any pattern in FILE
      --exclude=PATTERN    exclude files that match PATTERN
  -x, --one-file-system    skip directories on different file systems
      --help     display this help and exit
      --version  output version information and exit

Check trash size and empty trash using terminal in ubuntu

Check trash size via terminal using “du”.

To sort in reverse order use  sort -hr

du -hs ~/.local/share/Trash/* | sort -h 
du -hs ~/.local/share/Trash/files/* | sort -h

To empty trash  use

rm -rf  ~/.local/share/Trash/files/*

be carefull using rm.

 

 
Daterminare lo spazio occupato dal cestino da terminale utilizzando “du”.

Per ordinare in ordine inverso usare sort -hr

du -hs ~/.local/share/Trash/* | sort -h 
du -hs ~/.local/share/Trash/files/* | sort -h

quindi svuotare il cestino via terminale con

rm -rf  ~/.local/share/Trash/files/*

prestare molta attenzione utilizzando “rm” i files rimossi poi potrebbero non essere recuperabili .

Categorie:Linux, Ubuntu Tag:, ,