Day 5 Task: Advanced Linux Shell Scripting for DevOps Engineers with User management
Table of contents
No headings in the article.
What do you think if you have to create 90 directories at a time, how will create it one by one or using script or command.
Here Linux shell scripting comes into the picture. There are two different ways, we can create directories at a time using command and script.
Method 1 using command:
Method 2 using scripting:
Method 2 is called command line argument method while the time command execution we can give the input and execute it.
Create a Script to backup all your work done till now.
bash
#!/bin/bashbackup_dir="/path/to/backup/directory"
timestamp=$(date +"%Y%m%d_%H%M%S")tar -czvf "$backup_dir/backup_$timestamp.tar.gz" /path/to/source/directory
```User Management:
Dive into the world of user management in Linux. Users are the backbone of operations. Create two users and display their usernames:
```bash
#!/bin/bashuser1="user1"
user2="user2"# Create user1
sudo useradd -m -s /bin/bash "$user1"# Create user2
sudo useradd -m -s /bin/bash "$user2"echo "Users created successfully: $user1, $user2"