Skip to main content

Command Palette

Search for a command to run...

Basic Linux Shell Scripting for DevOps Engineers

Published
3 min read
Basic Linux Shell Scripting for DevOps Engineers
S

I have 10+ years of experience in Project Management across a range of industries including Oil & Gas, IT, Retail, and Rail Transportation, I have developed a proven track record in delivering results while maintaining a positive and proactive approach to work responsibilities.

As I look to the future, I am excited to pivot my career towards the field of Technology as a Scrum Master with a DevOps Engineer skill-set. To achieve this goal, I am committed to acquiring a range of key skills, knowledge, and certifications including SAFe Scrum Master, SAFe DevOps Practitioner, and expertise in a variety of DevOps tools such as Linux, Git & GitHub, Networking, CI/CD (Jenkins), Docker, AWS, Terraform, Kubernetes, Prometheus, Grafana, Go, and Python. I am eager to bring my experience and passion to a new role as a DevOps Engineer and to make a valuable contribution to any team.

I am excited about the opportunities ahead and look forward to bringing my expertise, enthusiasm, and positive attitude to a new role. Thank you for taking the time to learn more about me, and I welcome the opportunity to connect and explore potential collaborations.

What is Shell Scripting for DevOps

Shell Scripting is a commonly used tool for automating and managing various tasks and processes. The benefits of shell scripting include increased efficiency, reduced errors, improved consistency, and the ability to quickly respond to changing requirements. Shell scripting also helps DevOps practitioners scale their operations as needed.

What is #!/bin/bash? Can we write #!/bin/sh as well?

#!/bin/bash is called a "shebang" AKA "hashbang" line. It is the 1st line of a shell script. This declares to the system that this is a "script".

#!/bin/bash (Bourne Again Shell) states that this script is running on a Bash Shell interpreter. It is commonly used on Linux and MacOS. #!/bin/sh (Bourne Shell) is a commonly used shell in Unix-based operating systems.

Shell Script which Prints my 90 days of DevOps Challenge statement

A file 1st needs to be created. You can either use "touch" or directly create a new file by accessing the VIM editor. Once created & saved, I will change the file property via chmod command for executing permission before running the file using the ./ command.

In VIM Editor "shebang" was declared. I used "i" to edit, echo for my challenge statement, and ":wq" used to write & quit the file.

I used the chmod command to change the file permission to make sure it's executable. Once a file is executable, the color changes to green. In a future blog, I will share more information on file permissions. ./ was used to run the script file "devops_challenge.sh".

Shell Script to take user input, input from arguments and print the variable

I created this script file "user_input.sh". User will be prompted to enter their name in a variable, which will then display the variable with the statement - keeping it simple.

If else-if & else in Shell Scripting by comparing 2 numbers

When first coming across this, it took a bit of time to understand this, but what made it easier was to write out what I'm looking to achieve. After that, I reviewed my notes, and see some examples of understanding how if-else works and this task became much easier to complete. I used if, else-if, & else to compare 2 numbers entered by the user. I used "-eq" for equality check and "-lt" for less than. There are several ways how this script could have been written.


I appreciate your busy time reading this short blog. As I continue with my journey to learn and acquire the skill set of a DevOps Engineer, I will share what I learn. Thank you.

Happy Learning!


Sam Samarullah

LinkedIn

Previous Blog

Instagram

More from this blog

Sam's blog - Learning DevOps

15 posts

I am a results-oriented professional with 10+ years experience in Project Management. I am committed to become a Technical Scrum Master with a DevOps Engineer skill-set.