Day 5 Task - Advanced Linux Shell Scripting for DevOps Engineers with User management
Empowering DevOps: Advanced Shell Scripting and Efficient User Management
Tasks
✦ Write a bash script createDirectories.sh that when the script is executed with three given arguments (one is directory name and the second is the start number of directories and the third is the end number of directories ) it creates a specified number of directories with a dynamic directory name.
Example 1: When the script is executed as
./
createDirectories.sh
day 1 90
then it creates 90 directories as day1 day2 day3 .... day90
nano createDirectories.sh
Example 2: When the script is executed as
./
createDirectories.sh
Movie 20 50
then creates 50 directories as Movie20 Movie21 Movie23 ...Movie50
✦ Create a Script to backup all your work done till now.
nano backup.sh
✦ Read About Cron and Crontab, to automate the backup Script.
Cron is one of the most useful utilities that you can find in any Linux and Unix-like operating system. Cron is used to scheduling commands at a specific time. These scheduled commands or tasks are known as "Cron Jobs". Cron is generally used for running scheduled backups, monitoring disk space, deleting files periodically which are no longer required, running system maintenance tasks and a lot more.
CronTab we can define multiple jobs, for their scheduled time and the account under which the job should run.
◽️ Commands for the Corntab are as follows:
crontab -e = To select an editor and open corntabEdits a copy of the user's crontab file.
crontab -l \= Lists the user's crontab file.
crontab -r = Removes the user's crontab file from the crontab directory.
◽️ To automate the backup script
create a new crontab using crontab -e
let defined a cron job to run every second of every minute of every hour of every day of every week for every month
✦ Read about User Management and Let me know on Linkedin if you're ready for Day 6.
A user is an entity, in a Linux operating system, that can manipulate files and perform several other operations. Each user is assigned an ID that is unique for each user in the operating system. In this post, we will learn about users and commands which are used to get information about the users. After installation of the operating system, the ID 0 is assigned to the root user and the IDs 1 to 999 (both inclusive) are assigned to the system users hence the ids for local user begins from 1000 onwards.
The important command for user management
#To add new user
useradd username
#To check user configuration File
cat/etc/passwd
#To print all the user in linux
awk -F ':' '{print $1}' /etc/passwd
✦ Create 2 users and just display their Usernames
Stay in the loop with my latest insights and articles on cloud ☁️ and DevOps ♾️ by following me on Hashnode, LinkedIn (https://www.linkedin.com/in/chandreshpatle28/), and GitHub (https://github.com/Chandreshpatle28).
Thank you for reading! Your support means the world to me. Let's keep learning, growing, and making a positive impact in the tech world together.