Created
December 27, 2017 05:10
-
-
Save ohsevin/a2323d4f4b7edef38233ee87d7894651 to your computer and use it in GitHub Desktop.
clovercleaner.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
OLDCONF=$(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 ]; then | |
echo -e $RED"Error: must be root" | |
echo -e $YELLOW"Exiting..."$ENDCOLOR | |
exit 0 | |
fi | |
echo -e $YELLOW"Cleaning apt cache..."$ENDCOLOR | |
apt clean | |
echo -e $YELLOW"Removing old config files..."$ENDCOLOR | |
sudo apt purge $OLDCONF | |
echo -e $YELLOW"Removing old kernels..."$ENDCOLOR | |
sudo apt purge $OLDKERNELS | |
echo -e $YELLOW"Emptying every trashes..."$ENDCOLOR | |
rm -rf /home/*/.local/share/Trash/*/** &> /dev/null | |
rm -rf /root/.local/share/Trash/*/** &> /dev/null | |
echo -e $YELLOW"Script Finished!"$ENDCOLOR |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
README // INSTALL // TODO :
Below shows preview of commands for script above shown using short url; "tiny.cc/clovercleaner"
$ sudo wget http://tiny.cc/clovercleaner
--2017-12-27 00:17:15-- http://tiny.cc/clovercleaner
Resolving tiny.cc (tiny.cc)... 192.241.240.89
Connecting to tiny.cc (tiny.cc)|192.241.240.89|:80... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: https://tiny.cc/clovercleaner [following]
--2017-12-27 00:17:15-- https://tiny.cc/clovercleaner
Connecting to tiny.cc (tiny.cc)|192.241.240.89|:443... connected.
HTTP request sent, awaiting response... 303 See Other
Location: https://gist.githubusercontent.com/ninetyfivenorth/a2323d4f4b7edef38233ee87d7894651/raw/79ff9016f224292082b6bd390389a0ac2574e81c/clovercleaner.sh [following]
--2017-12-27 00:17:16-- https://gist.githubusercontent.com/ninetyfivenorth/a2323d4f4b7edef38233ee87d7894651/raw/79ff9016f224292082b6bd390389a0ac2574e81c/clovercleaner.sh
Resolving gist.githubusercontent.com (gist.githubusercontent.com)... 151.101.56.133
Connecting to gist.githubusercontent.com (gist.githubusercontent.com)|151.101.56.133|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 969 [text/plain]
Saving to: ‘clovercleaner’
clovercleaner 100%[===================================================>] 969 --.-KB/s in 0s
2017-12-27 00:17:16 (9.61 MB/s) - ‘clovercleaner’ saved [969/969]
[username]@[linuxOS-domain]:~
$ sudo bash clovercleaner
Cleaning apt cache...
E: Invalid operation clean
Removing old config files...
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages will be REMOVED:
libwine*
0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] Y
(Reading database ... 263457 files and directories currently installed.)abase ... 100%
Removing libwine:amd64 (1.6.2-20) ...
Purging configuration files for libwine:amd64 (1.6.2-20) ...
Removing old kernels...
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
linux-compiler-gcc-4.9-x86 linux-kbuild-4.7
Use 'apt-get autoremove' to remove them.
The following packages will be REMOVED:
linux-headers-4.7.0-0.bpo.1-amd64* linux-headers-4.7.0-0.bpo.1-common* linux-image-4.7.0-0.bpo.1-amd64-unsigned*
0 upgraded, 0 newly installed, 3 to remove and 0 not upgraded.
After this operation, 221 MB disk space will be freed.
Do you want to continue? [Y/n] N
Abort.
Emptying every trashes...
Script Finished!
Just an example of an output result of this quick effective commonly combined commanded .sh script.
//cheers