Day 5 : Advanced Shell Scripting for DevOps Engineers with User management

Day 5 : Advanced Shell Scripting for DevOps Engineers with User management

Shell Scripting Tasks

✒Introduction:

Shell scripting holds significant importance in the world of technology. Shell Scripting serves as a fundamental pillar in modern IT operations and development practices. Its automation capabilities, adaptability, and integration with DevOps workflows make it an invaluable tool for improving efficiency and achieving successful software delivery.🚚

📝Tasks:

💠Task 1: Create a script that makes multiple directories when passing start and end arguments.

To complete this task, we need to loop the arguments to the mkdir command one by one which will create multiple directories as per input.

To run: ./Task.sh file_name start_num end_num

Refer to this to understand easily:

javatpoint.com/bash-for-loop

linuxhandbook.com/bash-arguments


💠Task 2: Create a Script to back up all your work done till now and automate the backup script using Crontab.

First, create a Dir. called backupfolder in the root folder

sudo su
cd /
mkdir backupfolder

Create a .sh file and give permissions.

# Create .sh file
nano backup-script.sh
# Give permissions to execute
chmod +x backup-script.sh

Then, write the script to automate the backup process.

After executing, the backup will be stored in the backupfolder.

Now we just need to automate the backup using 'Crontab'

To automate, open the crontab in edit mode by crontab -e

Go to the end of the Crontab and enter the command.

0 12 * * * ./backup-script.sh

The crontab executes the backup-script.sh file every day of the year at 12:00 pm.

Refer this:

iq.opengenus.org/automated-backup-in-linux-..


👥User Management

In Linux, users are organized into groups, forming a team or squad. Among these users, the "root" user holds exceptional authority, much like a master key 🔑 to the system. Root has unrestricted access and control over all aspects of the Linux environment. However, using the root account requires utmost caution, as it can make significant changes that affect the entire system.

User management in Linux empowers administrators to create a structured and secure environment, effectively controlling user access and permissions. 👨‍💻

☑To display the current username

whoami

☑To create a user,

sudo useradd <username>

☑To remove a user,

sudo userdel <username>

☑To change the password,

passwd <username>

💠Task 3: Create 2 users and just display their Usernames.

As shown above, we would use the useradd command to create a user.

# Creating user
sudo useradd USER1
sudo useradd USER2

Then, to show users.

sudo /etc/passwd

✉Endcard:

🎉 Thank you for joining me on this insightful journey into the world of DevOps!

❤ If you found this blog helpful and informative, don't forget to give it a like!

🔄 Share this valuable knowledge with your friends and colleagues, so they can also benefit from understanding the power of DevOps!

👉 Stay updated with my latest posts and never miss out on exciting content! Click that Follow button to join and stay in the loop!

Follow me on Linkedin --> abdallah-qamar 👔

Stay tuned for Day 6...👋

#DevOps #SoftwareDevelopment #Technology #FollowUs #LikeAndShare #StayInformed #90daysofdevops #linux 📚🔍🌈