Linux Shell Scripts

Linux is very customizable especially if you take advantage of the terminal mode and enter commands at the command line. You can automate these commands by writing them in a small text file with the extension '.sh', this is called a bash shell script. You can execute the script by typing 'sh'.

You can write or edit bash shell scripts to automate and personalize many tasks, such as backups, daily downloads (use the wget command), mirror your files to another server (rsync), basically anything you can imagine.

The scripts provided here are some examples to get you started quickly, you will have to provide some paths and details specific to your system so read through the script and modify them where required.

Backup shell script

The backup shell script will allow you to create automatic backups of your htdocs and mysql directories (webserver and database) on a daily basis (1, 7 or 14 days history), automatically rotates the backups, mirrors to another server, FTP's to another server,restore the files from any given day to return your system to a previous state, exclude option for certain databases or htdocs directories, and send out an optional email confirmation upon success or failure of the backup process.

MySQL Repair and Optimize shell script

This shell script will optimize or repair a MySQL database, it can handle a large amount of tables and will go through the tables one by one.

Create SSL certificate shell script

You can use this script to create your own self-signed SSL certificate.

Screensaver shell script

If you have the Cmatrix screensaver installed on your system, you can show a Matrix style screensaver on your terminal. With this shell script, you can run the screensaver as a process which will be killed the moment the load on the server gets too high. You can use this script as an example to run your shell scripts as a background process.

Sorting shell script

This shell scripts helps you arrange your movies, books, music or any other documents into genres or categories. The way it works is that you enter your 'genres/categories' and a specific search string and the script will determine the appropriate genre by the highest amount of hits for each genre on google. The example will categorize your movies into genres. Download it here:


backup.sh_.zip4.39 KB
mysqltool.sh_.zip844 bytes
ssl_certificate.sh_.zip659 bytes
screensaver.sh_.zip756 bytes