Table of Contents
- Introduction
- What is Shell Scripting?
- Types of Shells
- Real-World Scenario: Shell Scripting
- Conclusion
- Let's Connect
Introduction
Welcome back to Day 27 of this practical Linux challenge!
If you have been following my articles and practicing your commands on RHEL 9, then you are already using the shell!
Now, imagine having the shell perform multiple tasks for you automatically. That is what shell scripting is all about.
What is Shell Scripting?
A shell is a command-line interpreter that lets you interact with the operating system. Shell scripting is the process of writing a series of shell (command-line) instructions in a file that can be executed like a program.
Think of it like creating your own little tool to automate boring or repetitive tasks!
With it, you can:
- Automate backups
- Monitor system performance
- Create users
- Set scheduled tasks
- Parse logs
- Deploy services
Types of Shells
Linux systems support several types of shells. The most commonly used ones include:
Shell | Description |
---|---|
sh |
The original Bourne shell. Simple, but limited. |
bash |
Bourne Again Shell – the most widely used and powerful shell on Linux (and the default on RHEL). |
zsh |
Z shell – known for features like auto-completion and customization. |
ksh |
Korn shell – used in enterprise environments. |
fish |
Friendly interactive shell – user-friendly and great for beginners. |
For this tutorial, we will use bash
, as it is the default on RHEL 9.
Real-World Scenario: Shell Scripting
Let's create and run our first shell script.
- Open your terminal, create a file and this line into it
vim hello.sh # note that script files end with a .sh
#!/bin/bash # this is called shebang /bin/bash must always start the line in every script you are writing
echo "Hello, world! This is Amanda's first shell script in RHEL 9!" # echo prints the message as an output on your terminal.
# Save and exit using:wq!
- Now, give the script permission to run
chmod +x hello.sh # this enables it to be executable
- Verify the file has the execute permissions
ls -ltr hello.sh
- Run the script on your terminal
./hello.sh
Conclusion
Shell scripting might sound scary at first, but once you try it, you will wonder why you didn’t start sooner. Even with just 3 commands, you can automate tasks that make your life easier.
In RHEL 9, this is one of the most useful beginner skills. Just remember: start simple, run often, and break things (on purpose lol).
See you in the next article, where we dive deeper into shell scripting!
If this is helpful to you, feel free to bookmark, comment, like and follow me for Day 28!
Let's Connect!
If you want to connect or share your journey, feel free to reach out on LinkedIn.
I am always happy to learn and build with others in the tech space.
#30DaysLinuxChallenge #Redhat#RHCSA #RHCE #CloudWhistler #Linux #Rhel #Ansible #Vim #CloudComputing #DevOps #LinuxAutomation #IaC #SysAdmin#CloudEngineer
Top comments (2)
been cool seeing steady progress - it adds up. you think the consistency or just the daily practice is what actually sticks long run?
I think both the daily practice and consistency works hand in hand. Personally, both gave me good habits.