Our Computer Consultancy Services

Essential Linux Scripts

One of the huge powers of Linux is it's built-in scripting language.

We work frequently in the Linux terminal screen, equivalent to the Windows Command Line (Start->Run->cmd)

We know that linux scripting takes some practice. There are thousands of Linux scripts available on the internet. Here are some of ours.

If you have a request for a new script, then use our Contact Us form (link at bottom of every page) and just ask. We will do it, for free of course.

You can type in any script manually. However, for 'long' scripts, like 5 lines or more, you can use a text editor to type in the commands and save the file as something like runme3.sh. Make sure you know which directory you are saving the file in - your home directory is best because it will be easier to find later.
Run this command to make the text file an executable text file :
chmod +x runme.sh, and then run it using
./runme3.sh
The ./ at the front is essential - it tells linux not to search your path environment variable to find out where runme3.sh is, but to run it directly from the current directory.


We use this script to check the Title and Description of our website, of which we have a copy (of course) on our hard disk.

You can easily modify this script to suit your own requirements.
It works like this :
The find command finds files.
find ./ means find ALL files from the current directory and all subdirectories.
find ./ -name '*.php' means find all files from the current directory and all subdirectories with a name like *.php (note the wildcard *, which means match any characters)
find ./ -name '*.php' | NOTE the PIPE character at the end. The pipe character should be on your keyboard somewhere. It means : take the output of the previous command and send it to the next command.
find ./ -name '*.php' | while read a_line
do
...
done
means create a 'while' loop. 'do' MUST be on the next line on its own, 'done' must also be on it's own line at the end of the loop. The output from the 'find' command is piped into a while loop - for every value read into a variable 'a_line', the commands between the do and the done are executed. Note that there is no $ character in front of this variable. echo means output something to the screen.
echo $a_line means output the variable a_line (set above) to the screen.
grep means search something for a string.
grep -i means search something for a string, ignoring lower/upper case.
grep -i description $a_line means search the file referenced in $a_line for the word 'description'.
It's as simple as that.