Self-Reflection: Shell Scripting Workshop

Arjun Singh
2 min readApr 26, 2021
Photo by Sai Kiran Anagani on Unsplash

In this post, I’m going to mention what concepts I learned and what use cases I became aware of after attending a workshop by LinuxWorld on Shell Scripting.

Introduction to Shell Scripting

Although we have advanced tools for Automation, sometimes requirements are solved by Shell Scripting. The program that takes input or command from the user and passes it on to the kernel, is called Shell Program. Shell is a concept. Lots of shell programs available in the market. One of the popular ones is BASH.

A Shell Script is a document containing commands to be executed in a procedural pattern. It saves time when the procedure needs to be followed again and again manually, we can just run the script through one click and do the automation. It also saves humans from doing any errors.

Concepts I learned in the Workshop:

  • Right meaning of Shell, shell script, bash shell scripting.
  • Introduction to Automation.
  • Variables: User-defined and system variables.
  • PATH system variable
  • Shebang/Hashbang #!
  • Arguments in Shell Scripts
  • Loop/Iteration: For loop and While Loop
  • .bashrc file
  • conditions using if, elif, else
  • IO Redirection
  • test and [ ]
  • Difference between >, 1>, 2> and /dev/null
  • Exit codes
  • Delimiter and Field separator
  • grep, cut
  • Regex
  • Remote Execution of program: SSH
  • The difference in Functions and commands
  • Creating multiple files using {1..10}
  • AWK command and its options
  • Making program non-interactive for scripting or automation
  • SED command
  • Concept of ‘usage’ to guide the user of command to use the correct syntax
  • Debugging of script using option -xe

Use Cases that we solved:

Migration of users from one system to another using script

In this, we create new users on another system when we migrate. We can either take input as arguments or can give input using a CSV file.

Script for Handling malicious user

We lock the user account when we observe him doing malicious activities, then create a backup of his account using tar

Download something every 5 minutes and take backup in a scheduled way

This is done by while loop and sleep command

Analysis on Logfile of the remote server

We do the script of analysis on the log file of web server hosted on AWS instance, like finding IP addresses of visitors, find the pages accessed.

Change Shell for the user

We used the text processing command like grep, awk to change the default shell for a user

Thank You..

#shellscripting #bash #bashshellscripting #shellscriptingbyLW #righteducation #vimaldaga #worldrecordholder #shellscriptingworkshop #workshop #terminal

--

--