Advanced Linux Shell Scripting for DevOps Engineers
#90daysdevops
#day05
- Write a shell script to create a specified number of directories with a dynamic directory name.
output:
- 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
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:
What is Cron and Cron Tab :
Cron 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.
Crontab 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 "crontab" 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.
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
- To check user account properties
sudo cat /etc/passwd
- To create a user account password
passwd user_name
- For switching user account
su username
- To delete a user account
userdel username
- To add a group account
groupadd devops
- To check group account property
sudo cat /etc/group
- To delete the group account
groupdel devops
Creating 2 users and just displaying their Usernames:
Thank you for reading!!
Great initiative by the #trainwithshubham community.