Clean Ubuntu
Nov. 4th, 2015 02:39 pmClean 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
- Have the administrative rights.
- Having a configured and enabled Internet connection.
Software to maintain and clean his system
From a terminal
Graphics mode
- KleanSweep (environment KDE)
- GtkOrphan (for orphaned packages)
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
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
- 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.
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."
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:
sudo localepurge
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 ...
(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
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
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
Contributors: Yurek, John Lux, macsim, yvecai, black_leunix.
http://doc.ubuntu-fr.org/nettoyer_ubuntu