5 Shell Scripts for Linux Newbies to Learn Shell Programming – Part II

To Learn something you need to do it, without the fear of being unsuccessful. I believe in practicality and hence will be accompanying you to the practical world of Scripting Language.

Learn Basic Shell Scripting
Learn Basic Shell Scripting

This article is an extension of our First article Understand Linux Shell and Basic Shell Scripting – Part I, where we gave you a taste of Scripting, continuing that we won’t disappoint you in this article.

Script 1: Drawing a Special Pattern

#!/bin/bash
MAX_NO=0
echo -n "Enter Number between (5 to 9) : "
read MAX_NO
if ! [ $MAX_NO -ge 5 -a $MAX_NO -le 9 ] ; then
   echo "WTF... I ask to enter number between 5 and 9, Try Again"
   exit 1
fi
clear
for (( i=1; i<=MAX_NO; i++ )) do     for (( s=MAX_NO; s>=i; s-- ))
    do
       echo -n " "
    done
    for (( j=1; j<=i;  j++ ))     do      echo -n " ."      done     echo "" done ###### Second stage ###################### for (( i=MAX_NO; i>=1; i-- ))
do
    for (( s=i; s<=MAX_NO; s++ ))
    do
       echo -n " "
    done
    for (( j=1; j<=i;  j++ ))
    do
     echo -n " ."
    done
    echo ""
done
echo -e "\n\n\t\t\t Whenever you need help, Tecmint.com is always there"

Most of the above ‘key words‘ would be known to you and most of them are self explanatory. e.g., MAX sets the maximum value of the variable, for is a loop and anything within the loop gets on executing again and again till the loop is valid for given value of input.

Sample Output
[root@tecmint ~]# chmod 755 Special_Pattern.sh
[root@tecmint ~]# ./Special_Pattern.sh
Enter Number between (5 to 9) : 6
       .
      . .
     . . .
    . . . .
   . . . . .
  . . . . . .
  . . . . . .
   . . . . .
    . . . .
     . . .
      . .
       .

                         Whenever you need help, Tecmint.com is always there

If you are a little aware of any programming language, learning the above script is not difficult, even if you are new to computation, programming and Linux it is not going to be much difficult.

Download Special_Pattern.sh

Script 2: Creating Colorful Script

Who says, Linux is colorless and boring, save the codes below to anything [dot] sh, make it executable and Run it, don’t forget to tell me how it was, Think what you can achieve, implementing it somewhere.

#!/bin/bash
clear 
echo -e "33[1m Hello World"
# bold effect
echo -e "33[5m Blink"
# blink effect
echo -e "33[0m Hello World"
# back to normal
echo -e "33[31m Hello World"
# Red color
echo -e "33[32m Hello World"
# Green color
echo -e "33[33m Hello World"
# See remaining on screen
echo -e "33[34m Hello World"
echo -e "33[35m Hello World"
echo -e "33[36m Hello World"
echo -e -n "33[0m"
# back to normal
echo -e "33[41m Hello World"
echo -e "33[42m Hello World"
echo -e "33[43m Hello World"
echo -e "33[44m Hello World"
echo -e "33[45m Hello World"
echo -e "33[46m Hello World"
echo -e "33[0m Hello World"

Note: Don’t bother about the color code now, Those important to you will be at your tongue, gradually.

Warning: Your terminal might not have the facility of blinking.

Sample Output
[root@tecmint ~]# chmod 755 Colorfull.sh
[root@tecmint ~]# ./Colorfull.sh

Hello World
Blink
Hello World
Hello World
Hello World
Hello World
Hello World
Hello World
Hello World
Hello World
Hello World
Hello World
Hello World
Hello World
Hello World
Hello World

Download Colorfull.sh

Script 3: Encrypt a File/Directory

This script will encrypt a file (remember? directory/driver/…. everything is treated as file, in Linux). The current limitation of the above script is that it don’t support auto completion of name using TAB. Moreover, you need to place the script and file to be encrypted in the same folder. You may need to install “pinentry-gui”, using yum or apt the package, if required.

[root@midstage ~]# yum install pinentry-gui
[root@midstage ~]# apt-get install pinentry-gui

Crete a file called “Encrypt.sh” and place the following script, make it executable and run it as shown.

#!/bin/bash
echo "Welcome, I am ready to encrypt a file/folder for you"
echo "currently I have a limitation, Place me to thh same folder, where a file to be 
encrypted is present"
echo "Enter the Exact File Name with extension"
read file;
gpg -c $file
echo "I have encrypted the file successfully..."
echo "Now I will be removing the original file"
rm -rf $file

Sample Output

[root@tecmint ~]# chmod 755 Encrypt.sh
[root@tecmint ~]# ./Encrypt.sh

Welcome, I am ready to encrypt a file/folder for you
currently I have a limitation, Place me to the same folder, where a file to be

encrypted is present
Enter the Exact File Name with extension

package.xml

                                                   ┌─────────────────────────────────────────────────────┐
                                                   │ Enter passphrase                                    │
                                                   │                                                     │
                                                   │                                                     │
                                                   │ Passphrase *******_________________________________ │
                                                   │                                                     │
                                                   │       <OK>                             <Cancel>     │
                                                   └─────────────────────────────────────────────────────┘

Please re-enter this passphrase

                                                   ┌─────────────────────────────────────────────────────┐
                                                   │ Please re-enter this passphrase                     │
                                                   │                                                     │
                                                   │ Passphrase ********________________________________ │
                                                   │                                                     │
                                                   │       <OK>                             <Cancel>     │
                                                   └─────────────────────────────────────────────────────┘

I have encrypted the file successfully...
Now I will be removing the original file
</pre>

gpg -c : This will encrypt your file, using a passkey aka password. In this process of learning you would have never thought that the actual process of learning could be that much easy. So after encrypting a file what you need? Obviously! decrypting the file. And I want you – the learner, the reader to write the decryption script yourself, don’t worry I am not leaving you in the middle, I just want you to gain something out of this article.

Note: gpg -d filename.gpg > filename is what you need to implement in your decryption script. You may post you script in comment if successful, if not you may ask me to write it for you.

Download Encrypt.sh

Script 4: Checking Server Utilization

Checking the server utilization is one of the important task of an administrator, and a good administrator is one who knows how to automate his day to day task. Below is the script that will give many such information about your server. Check it yourself.

#!/bin/bash
    date;
    echo "uptime:"
    uptime
    echo "Currently connected:"
    w
    echo "--------------------"
    echo "Last logins:"
    last -a |head -3
    echo "--------------------"
    echo "Disk and memory usage:"
    df -h | xargs | awk '{print "Free/total disk: " $11 " / " $9}'
    free -m | xargs | awk '{print "Free/total memory: " $17 " / " $8 " MB"}'
    echo "--------------------"
    start_log=`head -1 /var/log/messages |cut -c 1-12`
    oom=`grep -ci kill /var/log/messages`
    echo -n "OOM errors since $start_log :" $oom
    echo ""
    echo "--------------------"
    echo "Utilization and most expensive processes:"
    top -b |head -3
    echo
	top -b |head -10 |tail -4
    echo "--------------------"
    echo "Open TCP ports:"
    nmap -p- -T4 127.0.0.1
    echo "--------------------"
    echo "Current connections:"
    ss -s
    echo "--------------------"
    echo "processes:"
    ps auxf --width=200
    echo "--------------------"
    echo "vmstat:"
    vmstat 1 5
Sample Output
[root@tecmint ~]# chmod 755 Server-Health.sh
[root@tecmint ~]# ./Server-Health.sh

Tue Jul 16 22:01:06 IST 2013
uptime:
 22:01:06 up 174 days,  4:42,  1 user,  load average: 0.36, 0.25, 0.18
Currently connected:
 22:01:06 up 174 days,  4:42,  1 user,  load average: 0.36, 0.25, 0.18
USER     TTY      FROM              LOGIN@   IDLE   JCPU   PCPU WHAT
tecmint   pts/0    116.72.134.162   21:48    0.00s  0.03s  0.03s sshd: tecmint [priv]
--------------------
Last logins:
tecmint   pts/0        Tue Jul 16 21:48   still logged in    116.72.134.162
tecmint   pts/0        Tue Jul 16 21:24 - 21:43  (00:19)     116.72.134.162
--------------------
Disk and memory usage:
Free/total disk: 292G / 457G
Free/total memory: 3510 / 3838 MB
--------------------
OOM errors since Jul 14 03:37 : 0
--------------------
Utilization and most expensive processes:
top - 22:01:07 up 174 days,  4:42,  1 user,  load average: 0.36, 0.25, 0.18
Tasks: 149 total,   1 running, 148 sleeping,   0 stopped,   0 zombie
Cpu(s):  0.1%us,  0.0%sy,  0.0%ni, 99.3%id,  0.6%wa,  0.0%hi,  0.0%si,  0.0%st

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
    1 root      20   0  3788 1128  932 S  0.0  0.0   0:32.94 init
    2 root      20   0     0    0    0 S  0.0  0.0   0:00.00 kthreadd
    3 root      RT   0     0    0    0 S  0.0  0.0   0:14.07 migration/0

Note: I have given you the script that gives the output in the terminal itself, how about getting the output in a file for future reference. Implement it using redirect operator.

  1. >‘ : the redirection operator causes a file creation, and if it does exist, the contents are overwritten.
  2. >>‘ : when you use >>, you are adding information, rather than replacing it.
  3. >>‘ is safe, as compared to ‘>

Download Server-Health.sh

Script 5: Check Disk Space and Sends an Email Alert

How about getting an email when disk use in partition PART is bigger than Maximum allowed, it is a life saver script for web administrators with little modification.

MAX=95
[email protected]
PART=sda1
USE=`df -h |grep $PART | awk '{ print $5 }' | cut -d'%' -f1`
if [ $USE -gt $MAX ]; then
  echo "Percent used: $USE" | mail -s "Running out of disk space" $EMAIL
fi

Note: Remove “USER” with your user name. You can check mail using using ‘mail‘ command.

Download Check-Disk-Space.sh

Script writing and programming is beyond boundaries, anything and everything could be implemented as required. That’s all for now, In my very next article I will be giving your some different flavors of scripting. Till then stay cool and tuned, enjoy.

Avishek
A Passionate GNU/Linux Enthusiast and Software Developer with over a decade in the field of Linux and Open Source technologies.

Each tutorial at TecMint is created by a team of experienced Linux system administrators so that it meets our high-quality standards.

Join the TecMint Weekly Newsletter (More Than 156,129 Linux Enthusiasts Have Subscribed)
Was this article helpful? Please add a comment or buy me a coffee to show your appreciation.

91 thoughts on “5 Shell Scripts for Linux Newbies to Learn Shell Programming – Part II”

  1. This is my script. I am a beginner so I just used the old template. It was successful.

    #!/bin/bash
    echo "Welcome, now you want to decrypt a file/folder?"
    echo "Currently I have a limitation. Place me to the same folder, where a file to be decrypted is present"
    echo "Enter the Exact File Name with extension and the original filename before the encryption."
    read file;
    echo "Enter the exact file name before the encryption."
    read file2;
    gpg -d $file > $file2
    echo "I have decrypted the file successfully..."
    echo "Now removing the original encrypted file..."
    rm -rf $file
    
    Reply
  2. Hi! Thanks for this article. It is very useful. However, I have found that for Centos6 or Centos7, you have to add "\" into the command for the Colourful Script to activate the -e command.

    Reply
  3. ### Below is the decryption script####

    #!/bin/bash
    echo "Welcome, I am ready to decrypt a file/folder for you"
    echo "currently I have a limitation, Place me to the same folder, 
    where a file to be decrypt is present"
    echo "Enter the Exact File Name with extension"
    read file;
    gpg -d $file > decpt.txt
    echo "I have decrypt the file successfully..."
    echo "Please confirm should we remove the original file. Please answer in Y or N"
    read answer
    if [ "$answer" == Y ];
    then
     rm -rf $file
     echo " We have removed the file successfully..."
    else
     echo "Thank You."
    fi
    
    Reply
  4. Hello,

    Actually I tried file encrypt script but when I execute the code it gives me error. Can you please send me how to do it will really appreciate your help.

    Thank you

    Reply
  5. Hi.
    You can try this.

    #!/bin/bash
    #Creador Alfredo Pettengill – Rollout-IT

    df=”$(df -hP | egrep ‘^/dev/’ | awk ‘{ print $6 “_:_” $5 }’ )”
    hostname=”$HOSTNAME”
    CPU=”$(top -bn1 | grep load)”
    free=”$(free -mt | grep Mem: )”
    THRESHOLD=75
    user=”$(who)”
    if [[ “$df” > “$THRESHOLD” ]]
    then

    mail -s ‘Disk Alert ‘$hostname’ ‘ [email protected] << EOF
    Server Disk Space $hostname. Usado:

    $df

    —Server RAM Memory—

    Total Used Free Shared Buffer Cache
    $free

    —Server CPU usage—

    $CPU

    —Loggin Users—

    $user
    EOF
    fi

    Reply
  6. Hi, good article. Perhaps when you are searching for OOM messages it is better to search the string “Out of memory” as with “kill” you would find more output then required.
    Thanks

    Reply
  7. You all guys are the best….
    One request to all of you pls explain every field in script for more understanding to the readers.
    Thank you all.

    Reply
  8. Pls try and explain each script in details and can u give me the code to decrypt an encrypted script. Thanks guys

    Reply
  9. Can you hep me to write a bash script that change the passphrase in a *.gpg file which i created before. The situation is that I create a decrypted file with passphrase by follow you above. Now i want to change the passphrase of that decrypted file, is that possible?

    Reply
  10. Hello
    I have tried the script1, I got error “syntax error: unexpected end of file”. I search google, but still not be able fix it.
    Can you please advise?

    Reply
  11. I think for defining colors, it would be much easier if you do:

    red=$’\e[1;31m’
    grn=$’\e[1;32m’
    yel=$’\e[1;33m’
    blu=$’\e[1;34m’
    mag=$’\e[1;35m’
    cyn=$’\e[1;36m’
    bld=$’ \e[1m’
    end=$’\e[0m’

    Afte that:

    echo $red text $end

    “text” will be covered in red

    Reply
  12. Hi Avishek,
    Drawing a Special Pattern: Throwing an error
    ./pattern.sh: 19: ./pattern.sh: Syntax error: Bad for loop variable

    I have given 777 permission of the file.

    Reply
  13. HI Avishek,

    Nice blog , can you please guide me how to create one scripts it will check first memory utilazation if it is high then run command sh -c “sync; echo 1 > /proc/sys/vm/drop_caches”

    Reply
    • Hi,

      I am new to shell scripting, i hope below script helps

      #!/bin/bash
      limit=100 #minimum free memory you need
      free=`free -m | awk ‘{print $3}’ | xargs | awk ‘{print $2}’`

      if [ $free -ge $limit ]; then
      echo “memory is okay”
      exit 1
      fi
      echo “memeory usage high, cleaning cache”
      sh -c “sync; echo 1 > /proc/sys/vm/drop_caches”

      Reply
      • @Paresh,

        Thanks for the script, but you should tell us what this script all about, so that other users can aware of it..

        Reply
        • @Ravi: my bad :)

          We need free ram available on server, for that we can use free -m command:
          [root@srv ~]# free -m
          total used free shared buffers cached
          Mem: 996 579 417 0 8 171
          -/+ buffers/cache: 398 597
          Swap: 2015 0 2015

          now we will try to print only free ram cloumn:

          [root@srv ~]# free -m | awk ‘{print $3}’
          free
          579
          398
          0

          using xargs, we can get this data in single line and print only 2nd field:

          [root@srv ~]# free -m | awk ‘{print $3}’ | xargs
          free 579 399 0

          [root@srv ~]# free -m | awk ‘{print $3}’ | xargs | awk ‘{print $2}’
          579

          now we will store this value in free variable:
          free=`free -m | awk ‘{print $3}’ | xargs | awk ‘{print $2}’`

          you can define a variable “limit”, which will be the minimum amount of ram you want free in system.

          then check if free variable is greater than or equal to limit, if yes then everything is okay else clear cache:
          if [ $free -ge $limit ]; then
          echo “memory is okay”
          exit 1
          fi
          echo “memeory usage high, cleaning cache”
          sh -c “sync; echo 1 > /proc/sys/vm/drop_caches”

          Reply
          • @Paresh,

            Good nice script for checking free memory usage on Linux, but you’ve tested this script on all Linux distributions? If it works perfectly on all Linux OS, why not create a small 300 words article on this and publish at Tecmint?

            If you planning to write a article on this, here are the guidelines to follow:

            Introduce yourself, about script and explain each parameter used in this script and place the script in the article and show real time testing of scripts with screenshot and at the end add conclusion about script..

    • How do you get time stamp of one file?
      simply by executing of the below commans
      $ stat /path/to/file/file_name
      $ ls -l /path/to/file/file_name
      $ ls -lc /path/to/file/file_name
      $ ls -lu /path/to/file/file_name

      So how will you print time stamp of more than one file from different location
      $ stat /path/to/file/file_name /path/to/file2/file_name2
      $ ls -l /path/to/file/file_name /path/to/file2/file_name2
      $ ls -lc /path/to/file/file_name /path/to/file2/file_name2
      $ ls -lu /path/to/file/file_name /path/to/file2/file_name2

      Hope it helps!

      Reply
  14. Hi,

    I need a shell script that greps a pattern and return the count of each patterns.

    Contents of file:

    This is an Apple. Apple is good for health
    lemon is a fruit
    lemon is in yellow color
    This is a banana

    Just grep words: Apple, lemon, banana and return no of occurrences.preferably shell script.

    Reply
  15. Here is my Decription script:
    ——————————————–
    #!/bin/bash
    echo “Enter Encrypted File Name:”
    read file;
    gpg -d $file”.gpg” > $file
    rm -rf $file”.gpg”
    ——————————————–
    So, by an eof error I’ve lost contens of the encrypted file, ‘pattern.sh.gpg’, and now I’ve got only ‘pattern.sh’ with 0 byte. What did I miss?

    Reply
  16. Hello,

    this is how i wrote the decrypt script don’t know if thats the correct way though but it worked , the thing is that i couldn’t make the script to make the file to appear in its former name (the filename was hello.txt) so i give the option to make a newfilename.txt.

    Any help or advice is welcomed.
    Thanks for the tutorials it really helps.

    decrypt.sh script follows bellow
    #!/bin/bash
    echo “Welcome, I am ready to decrypt a file/folder for you”
    echo “currently I have a limitation, Place me to the same folder, where the file to be
    decrypted is present”
    echo “Enter the Exact File Name with extension”
    read file;
    gpg -d $file>hunter.txt
    echo “I have decrypted the file succesfully…”
    echo “Now I will be removing the encrypted file”
    rm -rf $file

    Reply
  17. How can I show in Linux when -d parameter is supplied the three user in the system that uses more disk space in their homes. Sort these three user by the disk usage and for each of them show their name, total space and home directory.

    Output should be like this:

    Disk usage:
    Jane 204816/users/Jane
    Joe 102420/home/joe
    sync 12584 /sbin

    Reply
  18. Hi Avishek,

    I am using Fedora 20 – Heisenberg. I wrote a script but the nested for loop is not working as intended. for the following variables I want to print:
    5 1 8 250 0 5180
    5 1 8 150 1 5181
    5 1 8 110 2 5182
    5 1 8 50 3 5183
    5 1 8 20 4 5184
    5 1 16 250 0 51165
    5 1 16 150 1 51166
    and so on…

    I keep getting the result:
    5 1 0 8 250 0 5180
    10 1 0 8 250 1 10181
    15 1 0 8 250 2 15182
    20 1 0 8 250 3 20183
    50 1 0 8 250 4 50184
    Can you tell me why the nested loop is not working? I would really appreciate your help.

    #!/bin/bash

    dist=(‘5′ ’10’ ’15’ ’20’ ’50’) #loop “i”
    retx=(‘1’ ‘3’ ‘5’) #loop “j”
    CWmin=0
    CWmax=(‘8′ ’16’ ’32’) #loop “k”
    numnodes=(‘250’ ‘150’ ‘110’ ’50’ ’20’) #loop “l”
    seed=0
    #seed=(‘0’)

    for(( i = 0; i < 5; i++ ))
    do
    for(( j = 0; i < 3; i++ ))
    do
    for(( k = 0; i < 3; i++ ))
    do
    for(( l = 0; i < 5; i++ ))
    do
    echo "$seed"
    echo ${dist[$i]} ${retx[$j]} $CWmin ${CWmax[$k]} ${numnodes[$l]} $seed ${dist[$i]}${retx[$j]}${CWmax[$k]}$seed
    ((seed=seed+1))
    done
    done
    done
    done

    Reply
      • Hi Avishek Kumar,

        Please help me .
        I want run one jar file, that jar file and input.property file Application team provided and run that jar weekly once, Before running need to take mysql DB dump backup.

        Thanks,
        Ram

        Reply
        • I didnt understand ur question.
          see if it helps

          Run Jar fie : java -jar filename.jar
          schedule the execution : you need to cron the job.

          Reply
  19. thnx for this series … am looking forward to working through it … however have struck an issue with the script

    Script 1: Drawing a Special Pattern

    there appears to be a syntax error (near the ‘Second Stage comment’) that prevents it from running in entirety … which makes it a bit frustrating for noobs … :)

    any chance of having a look at it :)

    cheers

    Geoff

    Reply
    • @Geoff:- It’s just identation errors. Even I faced same problem. Just place that line onto new one with single for loop in one line and the problem will be solved. Cheers :)

      ~ Dushyant

      Reply
  20. I need some assistance with creating the Decrypt script, this is what I have so far.

    #!/bin/bash
    echo “Welcome, I am ready to decrypt a file/folder for you”
    echo “currently I have a limitation, Place me to thh same folder, where a file to be
    decrypted is present”
    echo “Enter the Exact File Name with extension”
    read file;
    gpg -d $file > $file.txt
    echo “I have decrypted the file successfully…”
    echo “Now I will be removing the encrypted file”

    It decrypts the file, but doesn’t ask for password, and adds the .gpg and .txt at the end of the file.

    My other questions were how to take the output of a script and put i into a file or folder.

    Please e-mail me at [email protected]

    Reply
  21. Hi Avishek,

    I need one help regarding Linuc Shell scripting.

    Sample file content:
    10.101.194.32 – – [23/Oct/2014:10:49:14 -0500] “POST /IMN/maintain.do?methodName=handleSetSection HTTP/1.1” 200 280873 920181
    10.101.194.32 – – [23/Oct/2014:10:49:15 -0500] “GET /IMN/common/tablehighlighter.js HTTP/1.1” 404 41 50234
    10.101.194.32 – – [23/Oct/2014:10:49:15 -0500] “GET /IMN/common/images/slot_header_leftDark.gif HTTP/1.1” 304 – 1700
    10.101.194.32 – – [23/Oct/2014:10:49:15 -0500] “GET /IMN/common/images/slot_header_bodyDark.gif HTTP/1.1” 304 – 1413
    10.101.194.32 – – [23/Oct/2014:10:49:15 -0500] “GET /IMN/common/images/slot_header_rightDark.gif HTTP/1.1” 304 – 1546
    10.101.194.32 – – [23/Oct/2014:10:49:15 -0500] “GET /IMN/common/images/slot_body_repeat_narrow.gif HTTP/1.1” 304 – 1468
    10.101.194.32 – – [23/Oct/2014:10:49:15 -0500] “GET /IMN/common/images/slot_body_footer_narrow.gif HTTP/1.1” 304 – 5801
    10.101.194.32 – – [23/Oct/2014:10:49:15 -0500] “GET /IMN/common/images/slot_body_header_narrow.gif HTTP/1.1” 304 – 44407

    The last data coulmn having milli seconds. for example and from above sample data.

    My requriement:
    For above sample file, need to check if any of the request will takes more than 25 seconds need to send email alert to the team. How to write script for this scenario. Can you please help me on this .

    Thanks
    Gowri Shankar

    Reply
    • Dear saiba aka Vaibhav Choudhary.
      Shell scripting is a very powerful tool and it will surely help you getting a job.
      Good Luck.

      Reply
  22. hello Avishek,

    Thanks for this very helpful tips. can you help on decrypting script?
    I just changed the gpg -c to gpg -d but it seems not working, I can still see the file as .gpg

    Thank you in advance,
    Dodie

    Reply
  23. You are doing very good and understandable job. Keep going :)

    P.S Do you have an article, how to install O/S with LEMP or LAMP functions?

    Thanks in advance.

    Reply
      • Dear Avishek,
        Thank you very much… I had seen your articles about LEMP & LAMP and i had already use it, what i meant in my question above was if you have any article about O/S installation via scripting.
        i.e (i imagine that it will be very helpful to install O/S via scripting, if you have 10 machines and you need to make it simultaneously) or if you have any article with examples like these ones that you post it but with installation commands.
        Thanks again.

        Reply
        • Installing Linux via scripting on several machines at a time?

          I think you are talking about setting up of PXE Boot server.

          Reply
          • Something like that, is this the best way when you have to install new workstations? i’m asking because i really don’t know how to do it. I have in mind to minimize the time when i want to set up new machines, and i thought that it will be the best if i make a script and run it. I.E specific edition CentOS 6.5 or Ubuntu, create new user & pass with home directory, and the most important is to take backup from them i assume every two or three days so not to worry if someone do something.

            Thanks again for your help.

          • Also Avishek i would like to ask which is the best way to create a script with Lamp/Lemp installation? and if you have any similar article about it.

  24. Hi Avishek,
    could you please tell me if you are offering online linux scripting classes, and how much doest it costs.

    regrds

    Reply
    • Dear Lucky!
      we are offering location based training classes and currently we are having it in Mumbai.
      Free free to contact Tecmint.com about your needs and corresponding cost.

      Keep Connected.

      Reply
  25. Its really helpful for new learner .Share other scripts from where we get some tips and increase our productivity in our organization

    Thanks a lot for sharing your knowledge :)

    Reply
  26. how to run the shell programs i’m confuging about the path where it is being located the bin while running the program it will giving an error

    Reply
    • Dear Mallinath Swamy,
      we described above, in very simple words, how to execute a shell script.

      well once again,
      cd /path/to/folder
      chmod 755 script_name.sh
      ./script_name.sh

      Hope it helps.

      Reply
  27. To those who are confusing about the script 1, below is the actual formatted text

    #!/bin/bash

    MAX_NO=0

    echo -n “Enter Number between (5 to 9) : ”
    read MAX_NO

    if ! [ $MAX_NO -ge 5 -a $MAX_NO -le 9 ] ; then
    echo “WTF… I ask to enter number between 5 and 9, Try Again”
    exit 1
    fi

    clear

    for (( i=1; i=i; s– ))
    do
    echo -n ” ”
    done
    for (( j=1; j=1; i– ))
    do
    for (( s=i; s<=MAX_NO; s++ ))
    do
    echo -n " "
    done
    for (( j=1; j<=i; j++ ))
    do
    echo -n " ." # echo -n " ." , you should read it as space and a dot(.)
    done
    echo ""
    done

    echo -e "\n\n\t\t\t Whenever you need help, Tecmint.com is always there"

    Thank you very much Avishek Kumar…that was wonderfull lecture

    Reply
  28. I am getting error while running pattern sample script

    ./drawing2.sh: line 15: syntax error near unexpected token `do’
    ./drawing2.sh: line 15: `do’

    Reply
    • don’t copy and past from the site the scripts are missing characters and the formatting is messed up on some of them.

      Use the links – Download Special_Pattern.sh

      Reply
  29. Hello,
    the tips u r giving is very helpful for me, thanks a lot
    can u plz put debian based command for Ubuntu
    its main configuration file location etc….

    Reply
    • ThanKs Hari, for the good words about our Article, we will continue to provide you, valueable articles of this kind. However Your question was not clear, hence we are not able to understand your problem.

      Debain based command for ubuntu???

      Ubuntu is a derivative of Debian, and more or less all the programs will run on ubuntu as smooth as on Debian. Which Kind of Configuration File you Need to edit?
      Please Tell us your problem in details and be clear in language. We will be Happy to help you.

      Reply

Got something to say? Join the discussion.

Thank you for taking the time to share your thoughts with us. We appreciate your decision to leave a comment and value your contribution to the discussion. It's important to note that we moderate all comments in accordance with our comment policy to ensure a respectful and constructive conversation.

Rest assured that your email address will remain private and will not be published or shared with anyone. We prioritize the privacy and security of our users.