|
13 years ago 19 |
If you are an geeky user who keeps installing various software and updates then with the passage of time you will feel that your system is messed up. This is a shell script which lets you clean your system by removing the following:
here is it
#!/bin/bashOLDCONF=$(dpkg -l|grep "^rc"|awk '{print $2}')CURKERNEL=$(uname -r|sed 's/-*[a-z]//g'|sed 's/-386//g')LINUXPKG="linux-(image|headers|ubuntu-modules|restricted-modules)"METALINUXPKG="linux-(image|headers|restricted-modules)-(generic|i386|server|common|rt|xen)"OLDKERNELS=$(dpkg -l|awk '{print $2}'|grep -E $LINUXPKG |grep -vE $METALINUXPKG|grep -v $CURKERNEL)YELLOW="\033[1;33m"RED="\033[0;31m"ENDCOLOR="\033[0m"if [ $USER != root ]; thenecho -e $RED"Error: must be root"echo -e $YELLOW"Exiting..."$ENDCOLORexit 0fiecho -e $YELLOW"Cleaning apt cache..."$ENDCOLORaptitude cleanecho -e $YELLOW"Removing old config files..."$ENDCOLORsudo aptitude purge $OLDCONFecho -e $YELLOW"Removing old kernels..."$ENDCOLORsudo aptitude purge $OLDKERNELSecho -e $YELLOW"Emptying every trashes..."$ENDCOLORrm -rf /home/*/.local/share/Trash/*/** &> /dev/nullrm -rf /root/.local/share/Trash/*/** &> /dev/nullecho -e $YELLOW"Script Finished!"$ENDCOLOR
sudo chmod +x mintcleaner.sh
sudo sh mintcleaner.sh
arboyz@DynaBook-Portege-2000 ~ $ sudo chmod +x mintcleaner.sh[sudo] password for arboyz:arboyz@DynaBook-Portege-2000 ~ $ sudo sh mintcleaner.sh-e Cleaning apt cache...-e Removing old config files...No packages will be installed, upgraded, or removed.0 packages upgraded, 0 newly installed, 0 to remove and 108 not upgraded.Need to get 0B of archives. After unpacking 0B will be used.-e Removing old kernels...No packages will be installed, upgraded, or removed.0 packages upgraded, 0 newly installed, 0 to remove and 108 not upgraded.Need to get 0B of archives. After unpacking 0B will be used.-e Emptying every trashes...-e Script Finished!
Don't use old scripts without research: much has changed since 2011/2012. Some objections to this script:
It removes kernels. You should only remove kernels by means of the kernel tool in Update Manager (a tool that wasn't around five years ago, when this script was created).
It uses aptitude. Don't mix the use of aptitude and apt-get. They probably use different databases, so they might come to different conclusions about what's safe to delete and what not. You've already used apt-get when using Synaptic and Update Manager....
Works excellent!!! Been using for awhile now and no complaints. Thanks for sharing.
worked like a charm on my LM 17.2
Thank you very much!
Seems to be working well on Linux Mint 17.1 Cinnamon. Thanks for sharing.
Worked well, Mint 16.
Nice script! Good for studying scripts. There was a problem running it on my system however (LMDE-201403 (Cinnamon 64bit)).
A dialog box came up advising me that the script wanted to erase my boot image; when asked if I wanted to do that I said "NO".
The script finished executing and, after several boots and the exercise of several of my most often used applications, everything seems ok.
I'd "... refer to the original source." but that points to a generic Linux post some 3 years old now. The original poster probably has no particulars on Linux Mint.
Worked perfectly. My system needed to remove a few files and I ran it 3x and it ran straight through with nothing to report.
ourdeaux@lourdeaux-Pavilion-dv5000-EE393AV ~ $ sudo chmod +mintcleaner.sh
chmod: missing operand after `+mintcleaner.sh'
lourdeaux, your parameter is incorrect. the correct one must be $ sudo chmod +x mintcleaner.sh not
thanks for feedback all. glad if my article helpful
Great job! This is exactly what I was looking for. kudos!
This didn't work with my text editor, Kate, in Mint 13 KDE. What next, please?
Lee
ourdeaux@lourdeaux-Pavilion-dv5000-EE393AV ~ $ sudo chmod +mintcleaner.sh
chmod: missing operand after `+mintcleaner.sh'
Try `chmod --help' for more information.
lourdeaux@lourdeaux-Pavilion-dv5000-EE393AV ~ $ chmod --help
Usage: chmod [OPTION]... MODE[,MODE]... FILE...
or: chmod [OPTION]... OCTAL-MODE FILE...
or: chmod [OPTION]... --reference=RFILE FILE...
Change the mode of each FILE to MODE.
-c, --changes like verbose but report only when a change is made
--no-preserve-root do not treat `/' specially (the default)
--preserve-root fail to operate recursively on `/'
-f, --silent, --quiet suppress most error messages
-v, --verbose output a diagnostic for every file processed
--reference=RFILE use RFILE's mode instead of MODE values
-R, --recursive change files and directories recursively
--help display this help and exit
--version output version information and exit
Each MODE is of the form `[ugoa]*([-+=]([rwxXst]*|[ugo]))+'.
Report chmod bugs to bug-coreutils@gnu.org
very nice.
Works as promised!