Linux System Administration

Here is a small bash script to test a hard drive transfer speed. It should be take as an approximation. The speed value is taken from Linux dd command output. One way to test your hard drive speed is to use hdparm command:

# hdparm -Tt /dev/sda


Timing cached reads: 7216 MB in 2.00 seconds = 3615.89 MB/sec
Timing buffered disk reads: 288 MB in 3.00 seconds = 95.87 MB/sec

However, in this case the hdparm command is accessing raw hard drive, disregarding all partitions and file systems. The weakness of the following script is that it does not take source hard drive reading speed into consideration, however it is accurate when measuring transfer speed between two hard drives or speed between two nodes over the network using NFS or samba. Run the script with 3 arguments, source file, destination file and number of runs to make an average:

NOTE: If you do not have a file to copy simply create one by running a following command for couple seconds and interrupt with CTRL+C:

$ cat /dev/zero > :


# ./ /path/to/my/file /path/to/destination number_of_tests

for i in$(seq 1 $NUM_TESTs); do

REC=`ddif=$1 of=$22>some_random_file_ ; catsome_random_file_|cut -d " " -f8 |tail -1`

SUM=`echo$SUM + $REC|bc`


RESULT=`echo$SUM / $NUM_TESTs|bc|awk'{ str1=str1 $0 }END{ print str1 }'`

echo$RESULT MB/s

#clean up

./ /mnt/sdb1/ubuntu.iso /mnt/sda1/ubuntu.dd 3


57 MB/s
Free BASH scripting guide DOWNLOAD
Free BASH scripting guide DOWNLOAD
This bash script tutorial assumes no previous knowledge of bash scripting.As you will soon discover in this quick comprehensive bash scripting guide, learning the bash shell scripting is very easy task. However, if you do not find an answer to your questions by reading this bash tutorial or you need extra help, feel free to ask us on our new Linux Forum. We will be more than happy to help you with your bash questions there.

Lets begin this bash scripting tutorial with a simple "Hello World" script. Let's start with Learning the bash Shell: Unix Shell Programming

Bash Scripting Beginners Guide

Bash Scripting Advanced Guide

Hello World Bash Shell Script

First you need to find out where is your bash interpreter located. Enter the following into your command line:

$ which bash

bash interpreter location: /bin/bash

Open up you favorite text editor and a create file called Insert the following lines to a file:

NOTE:Every bash shell script in this tutorial starts with shebang:"#!" which is not read as a comment. First line is also a place where you put your interpreter which is in this case: /bin/bash.

Here is our first bash shell script example:

# declare STRING variable
STRING="Hello World"
#print variable on a screen
echo $STRING

Navigate to a directory where your is located and make the file executable:

$ chmod +x 

Make bash shell script executable

Now you are ready to execute your first bash script:


Example of simple bash shell script

Read more ...

This article provides few simple scripts to scan and monitor network using combination of bash and ping command. Obviously, these scripts are no match to a full monitoring dedicated software like nagios but they could be useful for a small home brand networks, where implementing sophisticated monitoring system can become an overhead.

Scan network subnet

In this example the bash script will scan network for hosts attached to an IP address - 255. The script will print message Node with IP: IP-address is up if ping command was successful. Feel free to modify the script to scan your hosts range.


  ping -c 1 $1 > /dev/null
  [ $? -eq 0 ] && echo Node with IP: $i is up.

for i in 10.1.1.{1..255} 
is_alive_ping $i & disown




Node with IP: is up.
Node with IP: is up.
Node with IP: is up.
Read more ...

Page 8 of 72

Go to top