Advaned Linux Used In Devoops

Advaned Linux Used In Devoops

What is SSH? Why it is needed?

SSH stands for Secure Shell. It is a network protocol that provides a secure and encrypted way to access and manage remote systems. The primary purpose of SSH is to establish a secure channel over an unsecured network, such as the Internet, allowing users to securely connect to and manage remote systems. It provides strong authentication mechanisms, data encryption, and integrity checking to protect the confidentiality and integrity of the data being transmitted.

SSH is needed because of the following reason?

  • Secure Remote Access

  • Secure File Transfer

  • Secure Remote Command Execution

  • Security and Encryption

How to SSH in any particular server?

To SSH into a server, you'll need the following information:

  1. Server IP Address or Domain Name: This is the network address of the server you want to connect to.

  2. SSH Username: The username you will use to authenticate yourself on the server.

Then, open the terminal and run the below command

ssh username@server_ip_adrress_or_domain_name

let's say the username is "Anish" and the IP address of the server that I want to connect to is 192.168.1.100

ssh anish@192.168.1.100

let's say the username is "Anish" and the domain name of the server that I want to connect to is stapp01 then

ssh anish@stapp01

What is SCP and How to copy the file from local to remote and vice versa using SCP?

SCP stands for Secure Copy, and it is a command-line tool used for securely transferring files between local and remote systems. It is based on the SSH protocol and provides encryption and authentication to ensure secure file transfers.

  1. Copy a file from local to remote:

     scp local_file.txt username@remote_ip_address:destination_directory/
    

    This command copies the file local_file.txt from the local system to the remote system specified by remote_ip_address. It is copied to the destination_directory on the remote system. You will be prompted for the SSH password of the remote system.

Copy a file from remote to local:

scp username@remote_ip_address:remote_file.txt destination_directory/

This command copies the file remote_file.txt from the remote system to the local system. It is copied to the destination_directory on the local system. You will be prompted for the SSH password of the remote system.

What is Shell scripting and writing the easiest Script using variable and user input?

Shell scripting refers to the process of creating and running scripts written in a shell language. A shell script is a sequence of commands written in a shell programming language (such as Bash, sh, or PowerShell) that can be executed directly by the operating system's shell interpreter.

Every script starts with #!//bin/bash Where #! is known as Shebang in Linux.

./script_name is used to run your script as an executable file.

Crone job and Crone tab

A cron job in Linux is a time-based job scheduling feature that allows you to automate the execution of commands or scripts at specified intervals. It is a built-in utility in most Linux distributions and is commonly used for repetitive tasks, periodic maintenance, or scheduled jobs.

The crone tab refers to the configuration file that contains the schedule and commands for cron jobs.

Crontab syntax

The crontab file uses a specific syntax to define the schedule and commands for the jobs. Each line in the crontab file represents a single cron job and consists of six fields separated by spaces. The fields specify the minute, hour, day of the month, month, day of the week, and the command to be executed

* * * * * command
  1. The asterisks field can be replaced by the specified value

  2. Schedule Expressions: In addition to specific values and asterisks, you can use special characters and expressions to define complex schedules. Some examples include:

    • */5 means every 5 units (e.g., */5 in the minute field represents every 5 minutes).

    • 0-10 means a range of values (e.g., 0-10 in the hour field represents from 0 to 10).

    • */2 in the hour field combined with 1,3 in the day of the week field means every 2 hours on Mondays and Wednesdays.

  3. Managing Crontab: To create, edit, or view your crontab file, you can use the crontab command with appropriate options. For example:

    • crontab -e opens the crontab file for editing.

    • crontab -l lists the contents of the crontab file.

    • crontab -r removes the crontab file.