oio11: (Default)
[personal profile] oio11

Clean Ubuntu

Well now, a little cleaning is required. Generally Ubuntu is well optimized but if lack of space, or you want to optimize to the maximum we must do something.

 

Prerequisite

 

Software to maintain and clean his system

 

From a terminal

 

Graphics mode

 

Delete temporary files of the installation files

Delete .deb packages to save space, or after several facilities downloaded packages accumulate and use a lot of space. These installation packages are stored in the / var / cache / apt / archives /

Accuracy: The downloaded packages are useless if you have internet. It only allow you to reinstall the applications in offline mode. Removing them does not cause removal of applications already installed by those packages.
Since a terminal by typing the command follows:

  • Delete the cache of expired packages:
      sudo apt-get autoclean 
  • Delete all cache:
      sudo apt-get clean 
  • Remove installed packages as dependencies and become useless:
      sudo apt-get autoremove 
 

Removing Software

Be careful not to delete important packages such as ubuntu-desktop! The wisest course is to check what those packages by doing a little research on the net. If you have uninstalled incorrectly core packages, reinstall them quickly before you restart.
Since a terminal by typing the command follows:
 

By saving the configuration

  sudo apt-get remove <name of unused package to delete> 
 

By deleting the configuration

(Can resolve configuration problems and restore the default settings) Since a terminal with the command follows:

  sudo apt-get purge <name of unused package to delete> 
 

Remove Orphan software

It happens that after deleting an application, modules or non-required dependencies are not removed. The application deborphan removes the packages which installed application will no longer appealed.

 

Residues of deleted software

Since a terminal with the command follows:

  sudo dpkg -P $ (dpkg -l | grep '^ rc "| tr -s'' | cut -d '' -f 2) 
 

Empty baskets

Check the contents of baskets before deletion.
GNU / linux, displaced in the recycle bin objects are placed in a folder named Trash accompanied or not other characters.
  • For your personal space, this folder is located in the folder hidden .local / share / Trash in your home folder.
  • For external units mounted (USB sticks, SD cards, remote units) it is hidden, is called .Trash-1000 and is located mostly on the root of the mounted partition (.Trash-1000 If the file does exist no, it will be created).

:!: The basket of versions and variants of Ubuntu contains all the currently supported baskets of all mounted partitions.

  • To check the contents, just a click on the trash icon at the bottom of the bar launchers or on the desktop according to Ubuntu variant or in the file explorer.
  • To delete items, just select them and then delete.
  • For delete, click on the clear button.
  • To empty a basket an external unit mounted (USB key, SD card, remote units), simply delete the folder .Trash-1000 unit.
  • Only to empty the trash on your personal space, enter in a terminal the command Next
      rm -r -f ~ / .local / share / Trash / files / * 
 

Delete a lot of files: "/ usr / bin / rm list too long arguments"

When using the rm command with a wildcard (* .dat, for example), bash starts by creating the file list corresponding to the joker before passing to the rm command. If the list is too long, you get a kind of error message:

  bash: / usr / bin / rm list too long arguments 

To work around this problem, you must pass the arguments (delete files) 1 by 1 to the rm command with a script, and then use the find command:

  find ./ -type f -name '* .dat' -delete 

Explanation: the find command to search; -type f: Specifies that you search for files -name '* .dat' specifies the name of the files to search for (here all files ending with the extension .dat); -delete: deletes the files found.

For more information, 'man find' in the terminal will explain everything not to do anything stupid.

 

Remove thumbnails of pictures

Gnome Nautilus, while browsing photos in folders, files, icons are a smaller version of the image. By dint and although the occupied space is not astronomical, they pile into the "~ / .thumbnails / normal" folder. Its content can be deleted. The following command to delete all the thumbnails of more than seven days.

  find ~ / .thumbnails -type f -delete -atime 7 
 

Delete Files "local" unnecessary

Site Preview: http://packages.debian.org/stable/admin/localepurge

"Simple script that recovers disk space wasted by local files and localized man pages unnecessary. It will be invoked automatically at each facility with apt."

Please note that you must be extremely careful during the installation.

During installation you will be asked to choose the language to retain! Beware if you do not choose the script language will not hesitate to delete everything! and you will have problems during the next reboot.

To install and configure simply type:

  sudo apt-get install localepurge 

During installation select (up / down button to move, select the language with the space bar) the installation language of your system: in this case FR for French.

To start you need to open a terminal and validate the command:

This command requires no parameter, it runs directly without confirmation and the result appears clean
  sudo localepurge 
If a problem has to be reinstalled local:
  sudo apt-get install local --reinstall 

OR

  sudo aptitude reinstall Local 
 

Removing backup files

These are hidden files ending with a "~". They serve as backup in case the source file (text, html, php, conf ...) would be deleted or accidentally changed. They accumulate, accumulate ...

You must ensure that this does not delete your saved configurations. Therefore, it is recommended not to use sudo (which could alter files not located in / home).

(thank you to Yannick_LM) View files to be deleted can be time consuming but allows you to check if the files are legitimate or not:

  find ~ / -name '* ~' -print0 

See list with a newline:

  find ~ / -name '* ~' 

Delete without confirmation:

  find ~ / -name '* ~' -print0 |  xargs -0 rm 
 

Removing old kernels

To remove old kernels, see the section Removing older kernels the kernel page.

 

Clear the cache of your browser

Epiphany:

Graphics mode: Edit → Preferences → Privacy → → Delete Temporary Files

Otherwise clear the ~ / .gnome2 / epiphany / mozilla / epiphany / Cache

Firefox: Tools → Clear Recent History ... → Cache

 

Script staff

This is just a proposal, just to automate things, customizing the script is not the subject of this article, but if you find bugs or if you do not get to create your own script I suggest you start a thread here: Forum Ubuntu developers or contact me if any
Here is a script that accelerates these manipulations for allergic to command lines: maintenir_systeme

If you do not trust this script I propose to create your own.

Step 1 Choose your command lines:

  sudo apt-get autoclean
 rm -r -f ~ / .local / share / Trash / files / * 

Step 2 Create a file nettoyage.sh example and fill it:

  nano nettoyage.sh 

copy and paste the command line:

  sudo apt-get autoclean
 rm -r -f ~ / .local / share / Trash / files / * 
 find ~ / .thumbnails -type f -exec rm -atime 7 {} \; 

Step 3 Customize execution:

  echo "Script cleaning Ubuntu"
 sudo apt-get autoclean
 echo "Obsolete packages have been removed OK"
 3 sleep
 find ~ / .thumbnails -type f -exec rm -atime 7 {} \;
 echo "Deleted icons"
 rm -r -f ~ / .local / share / Trash / files / * 
 echo "emptied Trash"
 3 sleep
 find ~ / -name '~ *' -exec rm {} \;
 echo "Temporary files (ending in ~) of the HOME file were suprimmés"
 echo "Cleaning completed" 

Step 4 Check the files in the trash (recovery impossible)

Step 5 Run it (after making it executable):

  chmod + x nettoyage.sh 
  sh nettoyage.sh 
 

DRAFT

You have an idea of ​​cleansing? Write it after this note until a valid experienced contributors and included in the previous parts

When apt-get stops working due to lack of space

I recently stumbled on a problem of space for the installation of a new kernel. After listing all available cores, I began to remove them manually in the / boot directory and in the grub menu.lst to prevent subsequent error, I would say it's a little nag but obviously it works . For example kernel 2.6.28-19 deletion

  cd / boot
 find ./ -name "* * 2.6.28-19"
 rm ./vmlinuz-2.6.28-19-server
 rm ./config-2.6.28-19-server
 rm ./abi-2.6.28-19-server
 rm ./System.map-2.6.28-19-server
 rm ./vmcoreinfo-2.6.28-19-server
 rm ./initrd.img-2.6.28-19-server 

and removing the grub menu.lst of the corresponding line

Clear Adobe Flash Player temporary files every browser launch (here Firefox)

Change the browser shortcut:

  rm -r ~ / .adobe / flash_player; rm -r ~ / .macromedia / flash_player; firefox% u 

seeking in folders files ending with tilde

  find $ HOME -name "* ~" -a!  -path "$ HOME / .local / share / Trash *" -ok mv "{}" ~ / .local / share / Trash / files / \;

 find / var / www / -name "* ~" -a!  -ok {} mv ~ / .local / share / Trash / files / \; 

Clear X days older files to a folder

In the current folder, delete all older than 15 days files:

  find.  -mtime -print -exec rm 15 "{}" \; 

Otherwise, a script that retrieves an argument (here the oldest files from any number of days):

  #! / bin / bash

 echo "Enter the folder in which you want to delete the file [path]."
 read path
 cd "$ {path}"
 if [$?  = 1]
 Then
   echo "The path is incorrect."
   echo "You are located in the following folder:"
   pwd
   echo "This script will select the folder where you stand no default. Continue? [Y / N]"
   read rep1
 else
   rep1 = 'o'
 fi
 if [$ rep1 = 'o']
 Then
   echo "Delete old files for how long? [In number of days]"
   read cbTemps
   find.  -mtime + $ cbTemps -print -exec rm "{}" \;
   if [$? = 1]
   Then
     echo "An error has occurred. Interruption of the script."
   else
     echo "Removing old files of more than $ cbTemps days) successful. script interruption."
   fi
 else
   echo "Interrupting the current script."
 fi 

At startup, empty the trash of his old files

In the settings, session startup, add this command to automatically remove over 30 days files. It can prevent the beast down the overflow PC ...

  find ~ / .local / share / Trash / files / -mtime 30 -delete 
 

See as well

https://translate.google.com/translate?hl=ru&ie=UTF8&prev=_t&sl=auto&tl=en&u=http://doc.ubuntu-fr.org/nettoyer_ubuntu
http://doc.ubuntu-fr.org/nettoyer_ubuntu

October 2025

S M T W T F S
   1234
567891011
12131415161718
19202122 232425
262728293031 

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Feb. 3rd, 2026 08:55 pm
Powered by Dreamwidth Studios