Linux Shell Scripting Advanced : Automation with the power of Shell Scripting.

Linux Shell Scripting Advanced : Automation with the power of Shell Scripting.

  • Creating n number of directories using a script

  • Create a Script to back up all your work done till now

  • Cron and Crontab, to automate the backup Script

  • User Management

  • Creating n number of directories using a script.

  • Two ways of creating a directory one is the normal method which is described below

  • Another method is using iteration method

  • Create a script to backup all your work done till now.

  • Taking backup of /root under /home fs

Cron and Crontab, to automate the backup Script

Crontab stands for “cron table“. The word cron has been taken from the Greek word Chronos meaning time. Crontab is a system daemon process that will automatically perform some tasks and jobs as per the scheduled time.

Crontab is useful for performing various operations such as handling automated backups, rotating log files, syncing files between remote machines and clearing out temporary folders, etc. Crontab can be used for any kind of work, but it becomes especially useful when we start dealing with system administration type of work.

Using cron, an administrator can schedule a job to run on a specific time and day.

To execute a list of commands, the cron utility reads the configuration files. To interpret the lines in the Crontab configuration tables, it follow a Crontab syntax. Crontab has six fields, and the first five(1-5) fields define the date and time of execution. The last field, i.e., the 6th field, could be a username and/or task /job/command/script to be executed.

Crontab fields

*    *    *   *    *  Command_to_execute
|    |    |    |   |       
|    |    |    |    Day of the Week ( 0 - 6 ) ( Sunday = 0 )
|    |    |    |
|    |    |    Month ( 1 - 12 )
|    |    |
|    |    Day of Month ( 1 - 31 )
|    |
|    Hour ( 0 - 23 )
|
Min ( 0 - 59 )

User Management

User Administration is the process of managing different user accounts and their respective permissions in an operating system.

In Linux or Unix-based operating systems, we can create different user accounts, sort them into groups, change their set of permissions or delete them

User accounts

In Linux, a single-user account generally belongs to a single user. The permissions for this user account determine the level of access the user will have while using the system.

User accounts are discussed in detail below.

Types of user accounts

  1. Super User: This account is also known as the root account. It has all the permissions and can run all the commands without any restrictions. The keyword sudo is often used to run a command as the root user.

  2. Normal User: The general users of the system are assigned this account. This account has restricted access to the commands and files of the system. The root user can create such an account, modify its permissions or delete it.

  3. System User: This is the type of account that is created only for a specific purpose or software. For example, a mail account.

Groups

In Linux or Unix-based operating systems, we can form groups of users’ accounts. Groups are used to manage the user accounts collectively. We can manage the access permissions for the entire group.

A single user can be a part of multiple groups, and a group can have multiple users.

Create 2 users and just display their Usernames