What is Shell ? And Types of Shell ??
In Linux, the shell is a program that interprets commands entered by the user and executes them. It's like the interface between the user and the operating system. There are several types of shells available in Linux, but the most common ones are:
Bash (Bourne Again Shell): Bash is the default shell for most Linux distributions. It's powerful and versatile, with a wide range of features and capabilities. It's also backward-compatible with the original Unix shell, the Bourne Shell (sh).
Zsh (Z Shell): Zsh is another popular shell that offers many advanced features, such as advanced tab completion, spelling correction, and customizable prompts. It's highly customizable and often preferred by power users.
Fish (Friendly Interactive Shell): Fish is designed to be user-friendly with features like syntax highlighting, autosuggestions, and easy-to-read syntax. It's aimed at improving the interactive shell experience for beginners and experienced users alike.
Ksh (Korn Shell): Ksh is a powerful and feature-rich shell that is backward-compatible with the Bourne shell and includes many enhancements. It's commonly used in commercial Unix environments.
Create a Script to backup all your work done till now.
Creating a backup script, you can create a script like this:
#!/bin/bash
# Set the source directory
src_dir=/home/ubuntu/shell_scripting
# Set the backup directory
tgt_dir=/home/ubuntu/backups
# Create a timestamp to include in the backup folder name
current_timestamp=$(date "+%Y-%m-%d-%H-%M-%S")
echo "Taking Backup for Timestamp:" $current_timestamp
# Create the backup file with a timestamp
final_file=$tgt_dir/scripts-backup-$current_timestamp.tgz
# Create the backup
tar czf $final_file -C $src_dir .
echo "Backup Completed ..."
Save this script in a file, e.g., backupData.sh, make it executable using # chmod 777 backupData.sh
Read About Cron and Crontab, to automate the backup Script
Cron: Cron is a time-based job scheduler in Unix-like operating systems. It allows you to schedule tasks or commands to run automatically at specified intervals. Cron runs in the background and continuously checks its list of scheduled tasks, known as cron jobs, to execute them at the defined times.
Crontab: Crontab is a configuration file that holds the list of cron jobs for a particular user. Each user on a Linux system can have their own crontab file. The crontab file contains the schedule and commands for the cron jobs.
Create the backup script: First, create the backup script that you want to automate. For example, let's create a script called "backup. sh" that backs up a specific directory:
#!/bin/bash
src=/home/ubuntu/shell_scripting
tgt=/home/ubuntu/backups
tar -czvf $tgt/$1.tar.gz $src
echo "backup Complete"
file_name=$(date | xargs | awk '{print $3 "-" "$2" "-" "$6"}')
echo @filename.tar.gz
So, keep exploring, and don't forget to have fun with those Linux commands! ๐๐ง๐ป
Hope you like my blog...!
If you like the content follow me on LinkedIn: linkedin.com/in/aryankale