# Advanced Linux Shell Scripting for DevOps Engineers

#90daysdevops

#day05

1. Write a shell script to create a specified number of directories with a dynamic directory name.
    

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1680347599265/c4f79380-8434-4f05-832a-5c2a75ba56ee.png align="center")

output:

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1680347995041/aa347ecf-8c7f-47a0-8c29-1dc0ade999fe.png align="center")

1. **A Script to backup all your work done till now :**
    

To tar and zip together we use : `tar -zcvf name.tar.gz file_path`

`-c` **:** Creates Archive   
`-x` **:** Extract the archive   
`-f` **:** creates an archive with the given filename. `-z` **:** zip, tells tar command that creates tar file using gzip

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1680354606679/d79d6f32-9e13-4f1c-be8b-758e00f53e4b.png align="center")

Instead of `--absolute-name` we can also use `-C`. The backup file will be created at `tgt_dir` location having the name `$curr_timestamp`.

output:

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1680355060018/ef68de89-2e00-4100-80e9-a8bd8799e2da.png align="center")

1. What is Cron and Cron Tab :
    
    **<mark>Cron </mark>** is a time-based job scheduler that allows users to schedule tasks to run automatically at specific times or intervals without needing manual intervention. These scheduled tasks are known as cron jobs.
    
    **<mark>Crontab</mark>** is a file that stores the list of commands or scripts scheduled to run at specific times using the Cron utility.
    
    To create or edit the crontab file, you can use the "**<mark>crontab</mark>**" command followed by specific options and arguments, such as:
    
    * "`crontab -e"` to edit the current user's crontab file.
        
    * "`crontab -l`" to list the current user's crontab file.
        
    * "`crontab -r`" to remove the current user's crontab file.
        
    * "`crontab -u`" to modify the crontab file for a specific user.
        

![](https://tse4.mm.bing.net/th?id=OIP.LRuOj8z4XfQv5Okxh9Zw5gHaEK&pid=Api&P=0 align="center")

### **What is User management?**

User management in Linux refers to the process of creating, modifying, and deleting user accounts on a Linux system. It also involves setting user permissions and access controls and managing user passwords.

Make sure to use sudo command to get the permission .

* ***To create a user account***
    

useradd User\_name

* **<mark>To check user account properties</mark>**
    

sudo cat /etc/passwd

* **<mark>To create a user account password</mark>**
    

passwd user\_name

* **<mark>For switching user account</mark>**
    

su username

* **<mark>To delete a user account</mark>**
    

userdel username

* **<mark>To add a group account</mark>**
    

groupadd devops

* **<mark>To check group account property</mark>**
    

sudo cat /etc/group

* **<mark>To delete the group account</mark>**
    

groupdel devops

**Creating 2 users and just displaying their Usernames:**

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1680356244333/902ed1da-09f5-4fce-9d69-35367a780a25.png align="center")

***Thank you for reading!!***

[**~Sujata Kumari**](https://www.linkedin.com/in/sujata-kumari-673374194/)

Great initiative by the #trainwithshubham community.
