Table of contents
- Tasks:
- ./createDirectories.sh day 1 90
- 2.When the script is executed as/createDirectories.sh Movie 20 50 then it creates 50 directories as Movie20 Movie21 Movie23 ...Movie50
- 3.Create 2 users and just display their Usernames
- 4.Taking backup script:
- Cron and Crontab, to automate the backup Script:
- Linux Crontab Syntax
- User Management:
All 90 directories within seconds using a simple command.
mkdir day{1..90}
Tasks:
You have to do the same using Shell Script i.e using either Loops or command with start day and end day variables using arguments -
So 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.
Example 1: When the script is executed as
./
createDirectories.sh
day 1 90
then it creates 90 directories as day1 day2 day3 .... day90
Example 2: When the script is executed as
./
createDirectories.sh
Movie 20 50
then it creates 50 directories as Movie20 Movie21 Movie23 ...Movie50
Notes: You may need to use loops or commands (or both), based on your preference . Check out this reference: https://www.geeksforgeeks.org/bash-scripting-for-loop/
Create a Script to backup all your work done till now.
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 and hence the ids for local user begins from 1000 onwards.
1.When the script is executed as
./
createDirectories.sh
day 1 90
./
createDirectories.sh
day 1 90
it creates 90 directories as day1 day2 day3 .... day90
2.
When the script is executed as/
createDirectories.sh
Movie 20 50
then it creates 50 directories as Movie20 Movie21 Movie23 ...Movie50
3.Create 2 users and just display their Usernames
4.Taking backup script:
Cron and Crontab, to automate the backup Script:
Cron is an effective and popular command-line utility used to schedule tasks at a specified time and day without user interaction. The scheduled tasks are known as cron jobs while the crontab is the list of the file containing the cron jobs. Crontab is useful to perform various operations such as handling automated backups, rotating log files, syncing files between remote machines and clearing out temporary folders, etc. The crond daemon is the background service that enables cron functionality.
Linux Crontab Syntax
- USER_NAME COMMAND/SCRIPT-TO-EXECUTE │ │ │ │ │ │ │ │ │ │ │ │ │ │ |_________ Day of Week (0 – 6) (0 is Sunday, or use names) │ │ │ |____________ Month (1 – 12),* means every month │ │ |______________ Day of Month (1 – 31),* means every day │ |________________ Hour (0 – 23),* means every hour |___________________ Minute (0 – 59), * means every minute
crontab -e: Edit crontab file, or create one if it doesn’t already exist.
crontab -l: Display crontab file contents.
crontab -r: Remove your current crontab file.
crontab -i: Remove your current crontab file with a prompt before removal.
crontab -u : Edit other user crontab files. This option needs system administrator privileges.
User Management:
User management in Linux is the process of creating, modifying, and deleting user accounts on a Linux system. In Linux, each user has a unique username and password, which are used to log in and access the system.
adduser: add a user to the system.
passwd: set password fro user userdel: delete a user account and related files.
addgroup: add a group to the system.
delgroup: remove a group from the system. usermod: modify a user account.
sudo: run one or more commands as superuser permissions.
Chage:change user password expiry information.
Relevant files: /etc/passwd (user information), /etc/shadow (encrypted passwords), /etc/group (group information) and /etc/sudoers (configuration for sudo).
Thank you for reading!! Hope you find this helpful.
#day05challenge#90daysofdevops
Always open for suggestions..!!
Thankyou Shubham Londhe !!