Bash

Linux Shell Programs


In the beginning was the Word
and the Word was with God
and the Word was God.
(John, 1:1)

The default Linux shell, bash, is an advanced command interpreter that allows a system administrator to program (or 'script') complex system administration tasks. Linux is pretty much a text oriented system, and lots (if not all) of the configuration is stored in text files. This allows for easy configuration with basic tools, such as a text editor.

The shell itself can read, interpret and execute text files that contain commands, so you can actually create programs with nothing but a text editor. This is very similar to MS DOS Batch files, except that, contrary to DOS Batch, Bash and other linux shells are complete programming languages that support all of the common control structures (assignment, iteration, conditional testing, ...), complex data structures (arrays), functions, inclusion of source code from other files (the 'source' command), string manipulation features, ... The shell was obviously designed with programming in mind, and it's trivial to test return values of other programs or string tools together with pipes and redirects ... When you get used to bash, MS batch scripting will feel like sculpting wood with a blunt pocket knife.

What follows is a list of shell scripts, mainly exercises and small 'just for fun' programs in Linux Bash. To create a script, just make a test file, make it executable (chmod +x name_of_file ), and run it (if it's not in the PATH, prepend ./ to denote 'current directory', eg ./myscript)


Words
generating words, eg for passwords, the "change one letter game", creating word lists for password cracking, ...
Bulk Text Processing
modify a large number of text files automatically - without having to open, modify, save them all one by one.
Poor Man's Web Master Tools
Applications of automated text processing in bash: generate sitemaps for Google or to add to your website, find hyperlinks, do bulk 'find and replace' operations over multiple html files, and so on.
Automatic uploads with ftp
Automatically upload multiple local files to an ftp server.
Scripts to send email
Send email by talking directly to an SMTP server of your choice. The script is an illustration of how SMTP works for sending mail. It also allows all sorts of funky stuff : sending mail from the command line, automatic mailing from scripts, bulk email, spoofing the sender address, ...
Automatic / brute force ssh login
proof of concept of a login password cracker
Arithmetic
Exploring shell Arithmetic, including a program to calculate interests on loans
Password Cracking
some examples of how seemingly strong passwords can be cracked within minutes using a few basic bash statements.

Koen Noens
April 2008