DevOps(Day-5) Advance Linux Scripting
Advance Linux Scripting
Write a bash script createDirectories.sh that when the script is executed with three given arguments (one is directory name and second is start number of directories and third is the end number of directories ) it creates specified number of directories with a dynamic directory name.
Scenario 1: When the script is executed as
./
createDirectories.sh
day 1 90
then it creates 90 directories as
day1 day2 day3 .... day90
Scenario 2: When the script is executed as
./
createDirectories.sh
Movie 20 50
then it creates 50 directories asMovie20 Movie21 Movie23 ...Movie50
Create a Script to backup all your work done till now.
Read About Cron and Crontab, to automate the backup Script
Crontab is used to automate the scripts that will run in a set time interval. The format of setting the rules is as shown in the above picture.
How to Add/Edit Crontab
Crontab files are typically stored in the /etc/cron.d/ directory on Linux systems. The crontab command can be used to edit the crontab file.
crontab -e
By default, it will edit the crontab entries of the currently logged-in user. To edit other user crontab use the command below:
crontab -u username -e
How to List Crontab
To view the crontab entries of current users use the following command.
crontab -l
Use -u followed by the username to view the crontab entries of the specified user.
crontab -u username -l
Automating the backup script through crontab.
The script will run 1st of every month.
User management in Linux
root - It is the superuser that can perform all the actions in a server. This privilege is given at the time of server spin-up.
With useradd commands, you can add a user.
Syntax:
useradd -c "comment" username
To delete a user account userdel command is used.
Syntax:
userdel -r <userName>
The command usermod is used to modify the properties of an existing user.
Syntax:
usermod -c <'newName'> <oldName>
/etc/passwd - This file contains the detailed information of all the users created in a server.
Create 2 users and just display their Usernames.
Subscribe to my newsletter
Read articles from directly inside your inbox. Subscribe to
WRITTEN BY Biswaraj Sahoo --AWS Community Builder | DevOps Engineer | Docker | Linux | Jenkins | AWS | Git | Terraform | Docker | kubernetes
Empowering communities via open source and education.
Connect with me over linktrr: https://linktr.ee/biswaraj333