_______ _____ _
|__ __| / ____| |
| |_ ___ __ | | | | ___ __ _ _ __ ___ _ __
| | | | \ \/ / | | | |/ _ \/ _` | '_ \ / _ \ '__|
| | |_| |> < | |____| | __/ (_| | | | | __/ |
|_|\__,_/_/\_\ \_____|_|\___|\__,_|_| |_|\___|_|
####################################################################################################
Tux Cleaner v0.4
Tux Cleaner removes temporary and unneeded files (thumbnails, old logs, etc.) from your Linux
system. If no arguments are specified, script shows functions menu, otherwise it executes specified
functions.
Dialog menu (functions menu) mode shows various dialog windows with choices. Command-line mode
only executes specified functions without asking for confirmation, so you should be aware of that
and use command-line mode only after checking how the script works in dialog mode in your system.
Warning: the script requires root privileges, so you must run it as root or use sudo (sudo ./Tux_Cleaner.sh).
Dependencies: bash (>= 4.0), dialog (>= 1.1-20110707)
Author: Vytautas Bačiulis
E-Mail: Vytautas.Baciulis@gmail.com
Project website: https://sourceforge.net/projects/tuxcleaner/
Licence: GNU GPLv3 (http://www.gnu.org/licenses/gpl.txt)
####################################################################################################
Functions
* Thumbnails cleaner
* Unneeded files cleaner
* Logs cleaner
####################################################################################################
Bugs
* None, however it's possible that script can't handle some rarely used special characters.
####################################################################################################
To-Do list
* Checking for new versions and script updater
* Exceptions support (when passing arguments via command-line)
* Unneeded files cleaner: function to add custom extensions of unneeded files
* Packages cleaner
* Search for duplicates function
* Function to execute all functions using default settings or values
* Feedback function
####################################################################################################
Command-line mode
----------------------------------------------------------------------------------------------------
* 0. Execute all functions
* This function executes all functions using default settings/values.
* It doesn't ask for confirmation, prints messages about errors and successful or unsuccessful cleanup.
* No arguments can be specified.
Default settings/values:
* Thumbnails cleaner -- ALL -- deletes thumbnails from all users (incl. user "root") home directories.
* Unneeded files cleaner -- /home or /usr/home -- deletes all unneeded files found in /home or
/usr/home directories.
* Logs cleaner -- level1 -- deletes log files (found in /var/log) using level1 criteria.
Usage: ./Tux_Cleaner.sh -0
* Let's say, you want to execute all functions except logs cleaner using default values and logs
cleaner using level2: ./Tux_Cleaner.sh -0 -3 level2
Problem: the script will execute logs cleaner using level1 and only after finishing all functions
it'll execute logs cleaner using level2.
----------------------------------------------------------------------------------------------------
* 1. Thumbnails cleaner
* This function deletes thumbnails files (PNG format files) from specified users home directories
(/home/user/.thumbnails).
* It's 100% safe to use unless you keep some of your PNG format files in /home/user/.thumbnails
directory.
* The script also deletes thumbnails from user "root" home directory (/root/.thumbnails) if
argument "root" or "ALL" is specified.
Usage (case sensitive):
* ./Tux_Cleaner.sh -1 tom -- deletes thumbnails only from tom's home directory.
* ./Tux_Cleaner.sh -1 "tom john" -- deletes thumbnails only from tom's and john's home directories.
* ./Tux_Cleaner.sh -1 ALL -- deletes thumbnails from all users (incl. user "root") home directories.
Exceptions:
* Paths containing spaces are ignored (because username in Linux OS can't contain spaces).
* Incorrect usernames or users having no thumbnails directories are ignored.
Warnings:
* Argument "ALL" refers to all users, argument "all" refers to user "all".
* When specifying two or more users, they must be put in quotes and separated by spaces.
For example: ./Tux_Cleaner.sh -1 "user1 user2 user5 user6".
* If no thumbnails will be found, the script still will print the message
"MESSAGE: Thumbnails were deleted successfully!".
----------------------------------------------------------------------------------------------------
* 2. Unneeded files cleaner
* This function deletes files, which usually aren't necessary. Those files are:
* Files ending with ~ usually are older (backup) versions of edited text files.
* Thumbs.db are Microsoft Windows OS thumbnails files.
* It's 95% safe to use, because when using command-line version if you named your file some_file~,
the script will delete it even tough it's not an older version of text file. However, those are
very rare occasions and if needed, I'll implement backups making before every cleanup.
Usage (case sensitive):
* ./Tux_Cleaner.sh -2 /full/path/to/directory
* Path containing space characters must be quoted. Alternatively, you can add backslash character
before each space character.
* Path containing double quotes must have backslash characters added before each of them.
* Single quotes must have backslashes only when full path isn't quoted.
* Some special characters (such as : ? @ ^) can be specified without using backslash character.
* Character ! can't be specified when path is double quoted.
* Specifying special characters:
* When path isn't double quoted, backslash is necessary before characters ! \ | ~ ` & ( ) ; " ' < > space
* When path is double quoted, backslash is necessary before characters ` "
Warnings:
* This function doesn't ask for confirmation, so it's best firstly to try dialog menu mode and to
make sure nothing necessary would be deleted.
* If no unneeded files will be found, the script still will print the message
"MESSAGE: Unneeded files were deleted successfully!"
Examples:
* /home/username/Desktop
./Tux_Cleaner.sh -2 /home/username/Desktop
./Tux_Cleaner.sh -2 "/home/username/Desktop"
* /home/username/New projects
./Tux_Cleaner.sh -2 /home/username/New\ projects
./Tux_Cleaner.sh -2 "/home/username/New projects"
* /home/username/Projects: "testing" branch
./Tux_Cleaner.sh -2 /home/username/Projects:\ \"testing\"\ branch
./Tux_Cleaner.sh -2 "/home/username/Projects: \"testing\" branch"
* /home/username/"a": !/
./Tux_Cleaner.sh -2 /home/username/\"a\":\ \!/
----------------------------------------------------------------------------------------------------
* 3. Logs cleaner
* This function deletes log files.
* Level 1 -- Recommended level. Only logs matching those criteria are deleted:
* Log file is older than 7 days.
* Log file isn't written anymore and is "archived".
For example: let's say, logs are syslog, syslog.1, syslog.2.gz, syslog.3.gz, syslog.4.gz.
The script will delete syslog.1, syslog.2.gz, syslog.3.gz, syslog.4.gz (except those logs
which aren't older than 7 days).
* Level 2 -- Use this level only if you don't check logs after something goes wrong in your
system. This level is safe to use, because it doesn't delete most recent logs files.
For example: let's say, logs are syslog, syslog.1, syslog.2.gz, syslog.3.gz, syslog.4.gz.
The script will delete syslog.1, syslog.2.gz, syslog.3.gz, syslog.4.gz no matter when those
files were created and/or modified.
Usage (case insensitive):
* ./Tux_Cleaner.sh -3 level1 -- executes logs cleaner using level 1.
* ./Tux_Cleaner.sh -3 level2 -- executes logs cleaner using level 2.
----------------------------------------------------------------------------------------------------