Day 5 of #90DaysOfDevOps

Day 5 of #90DaysOfDevOps

Write Shell script to create directories with names starting with dir1 to dir90.

What is a cron?

Cron is a job scheduling utility present in Unix/linux like systems. The cron daemon enables cron functionality and runs in background. The cron reads the crontab (cron tables) for running predefined scripts.

What are cron jobs in Linux?

Any task that you schedule through crons is called a cron job. Cron jobs help us automate our routine tasks, whether they're hourly, daily, monthly, or yearly.

What is crontab?

Crontab, which is short for cron table, is a file containing the schedule of various cron entries that should be run at specified times. Another way of describing crontab is as a utility that enables tasks to run automatically at regular intervals in the background by the cron daemon.

The crontab file contains simple instructions for the daemon that mean "Run this command at this time on this date". These instructions specify which command will be executed, on which date and at what time.

Crontab Commands

crontab -e -- To create or edit crontab

crontab -l -- To view the cronjobs/crontab

crontab -r -- To remove the crontab

User Management in Linux

What are Users in Linux?

In a Linux system, users refer to individuals or entities that interact with the operating system by logging in and performing various tasks.

A user in Linux is associated with a user account, which consists of several properties defining their identity and privileges within the system. These properties are a username, UID (User ID), GID (Group ID), home directory, default shell, and password.

User Management Commands

useradd - creates a user account.

  • useradd <userName> - creates user account without home & mail spool directories.

  • useradd -m <userName> - creates user account with home & mail spool directories.

passwd <userName> - creates a password for the user and stores it in /etc/shadow file.

userdel - user delete.

  • userdel <userName> - deletes the user from the system.

  • userdel -r <userName> - deletes the user from the system along with home and mail spool directories (-r remove).

/etc/passwd - stores information about user accounts.

  • cat /etc/passwd - displays the complete list of users on that machine.

/etc/shadow - stores the password for users in an encrypted format.

  • cat /etc/shadow - displays the complete list of user passwords on that machine.

su - switch user

  • su <userName> - switches to the user mentioned.

  • exit - to logout from that user.

usermod - modify user

  • usermod -aG <groupName> <userName> - adds the user to another group (-aG append the user to the group without removing from other groups).

Create 2 users and just display their Usernames