Skip to main content

Command Palette

Search for a command to run...

"Linux Insights" !!! Blog 4

Published
•4 min read•View as Markdown
"Linux Insights" !!! Blog 4

Hey, hi, and hello! As you know, I am Suyash Gawde. Today, I attended the third day of the Linux workshop at DBATU, Lonere, conducted by Pranav Jambare, as mentioned in my previous blog.

TODAY'S TOPICS ARE:

FIND AND LOCATE

SSH

FIND AND LOCATE

Find

The "find" command allows you to search for files and directories based on various criteria such as name, type, size, permissions, and more. The basic syntax of the "find" command is as follows:

For example, to find all files and directories named "example.txt" in the current directory and its subdirectories, you can run:

find . -name "example.txt"

This command will start the search from the current directory (represented by ".") and recursively search for files and directories with the specified name.

SYNTAX:

find / -name [filename]

Locate

The "locate" command allows you to quickly find files and directories based on their names. It relies on a pre-built database called "locatedb," which needs to be updated periodically. To search for files or directories using "locate," follow these steps:

Step 1: Update the "locatedb" database by running the following command as the root user or with sudo privileges:

sudo updatedb

Step 2: Once the database is updated, you can use the "locate" command to search for files. For example, to find all files and directories named "example.txt" in the entire system, you can run:

locate example.txt

Note that the "locate" command searches for files and directories based on their names, so it's generally faster than "find" but may not give real-time results if the database is not up to date.

Both "find" and "locate" have numerous options and can be customized to suit your specific search requirements. You can refer to their respective manual pages ("man find" and "man locate") for more information on their usage and available options.

SSH

Secure Shell (SSH) is a widely used network protocol that provides secure remote access and secure communication between two devices. It is commonly used in Linux systems for secure remote administration and secure file transfers.

Syntax: ssh [user]@[ip]

SSH uses public-key cryptography to establish secure connections between devices. Public and private key pairs are a fundamental part of SSH authentication. Here's an explanation of public and private keys in SSH:

Public Key: A public key is derived from a private key and is meant to be shared freely. It is used to authenticate the user or device on the remote server. The public key is stored on the remote server in a file called "authorized_keys" in the user's ".ssh" directory. When the user tries to connect to the server, the server checks if the corresponding private key can decrypt the challenge sent using the public key. If successful, the user is granted access.

Private Key: The private key is kept secret and should never be shared. It is used for authentication and to encrypt the communication between the client and the server. The private key is stored on the local machine in a file typically named "id_rsa" in the ".ssh" directory. The private key should be kept secure and protected with a passphrase for an additional layer of security.

SSH provides a secure encrypted connection for remote login and command execution. Here's how you can use SSH in Linux:

Install OpenSSH: Ensure that OpenSSH is installed on your Linux system. Most Linux distributions come with OpenSSH pre-installed. If not, you can install it using your distribution package manager. For example, on Ubuntu or Debian-based systems, you can use the following command:

sudo apt install openssh-server

Connect to a remote server: To connect to a remote server via SSH, you need the IP address or hostname of the remote server, as well as valid credentials (username and password or SSH key).

ssh username@remote_server_ip

SETUP SSH ON THE SERVER:

PACKAGE INSTALLATION-

yum install [package name] -y

CHECK PORT-

netstat -tunlp | grep 22

CHECK SERVICE STATUS-

systemctl status [service name]

SSH CONFIGURATION FILE-

vi /etc/ssh/sshd_config

ALLOW/DENY-

vi /etc/host.allow

vi /etc/host.deny

I hope you find this blog interesting!

Thanks for reading!