Saturday, May 4, 2024
4
rated 0 times [  4] [ 0]  / answers: 1 / hits: 1449  / 1 Year ago, mon, march 6, 2023, 3:40:06

I wonder to know if should I use ubucleaner script on Ubuntu Oneiric/Precise?


More From » command-line

 Answers
1

Short answer is: No, it's a bad idea.


Let's look at the code:


#!/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
aptitude clean

echo -e $YELLOW"Removing old config files..."$ENDCOLOR
sudo aptitude purge $OLDCONF

echo -e $YELLOW"Removing old kernels..."$ENDCOLOR
sudo aptitude 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

This script basically consists of 3 calls of a package management tool and it empties the trash folders of each user. Honestly what's the gain here? Freeing up some megabytes or gigabytes, that's all. If you're aiming for a performance gain you're mistaken. If your hard drive is the bottleneck of your current Ubuntu setup, I recommend buying a SSD. It's better to spend that money than spending valuable time trying to clean after something that always will get messy shortly after cleaning up.


I know CCleaner is very popular on Windows due to the habit of Windows users trying to clean up the system because they keep believing that this will increase/restore the system performance. This is partially true because some application developers do a pretty poor job at integrating their applications into Windows, best examples are vendor customized pre-installed versions of Windows and installer packages extracting themselves several times before installation and not cleaning up afterwards (I look at you LENOVO!).


Regarding privacy concerns Ubuntu started shipping an application in the default installation and I hope it will continue to improve that functionality, it looks promising.


However package management as in Ubuntu and most major Linux distributions solves most of the afore mentioned problems. Using the script for system administration is a bad idea. Instead you should be knowing what the script does and remember the commands to execute them individually when needed.


Cleaning APT cache


If I recall correctly, the graphical update manager already takes care of this, so use the update manager instead of aptitude clean if you can.


Removing old config files


Those files don't take up a lot of space and in some cases you would be happy to find an application already configured upon reinstall. If the opposite is the case you can always reconfigure the package via dpkg.


Removing old kernels


Old kernels can take up 200 megabytes and more each. It has been discussed several times how to safely integrate this feature into the update manager. There are blueprints out there, but they don't seem to be implemented until know, mostly because it's difficult to decide which kernel to keep and which not. Deleting all but the newest is considered not to be a good idea.


Emptying trash


In a proper setup this shouldn't be an issue, because home folders should be placed on another file system than the root file system. Then again you as a system administrator can't just go there and empty users trash folders. This is bad management style and may break the work flow of the users. This issue is usually solved via quotas. In turn when you empty users trash folders you should be cleaning up their .thumbnails folders and other folders, too. Nope, set a quota if you have to manage users and you're done.


Remember the sudo reminder:



We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things:



  1. Respect the privacy of others.

  2. Think before you type.

  3. With great power comes great responsibility.


root's password:



[#36410] Monday, March 6, 2023, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
rvousnove

Total Points: 456
Total Questions: 130
Total Answers: 98

Location: El Salvador
Member since Sun, Sep 12, 2021
3 Years ago
;