Found 1436 Articles for Linux

Why Should We Disable Root-login over SSH on Linux

Satish Kumar
Updated on 25-Jan-2023 10:58:59

1K+ Views

Root-login over SSH is a common method for gaining access to a Linux server, but it is not always the most secure option. In this article, we will explore the reasons why disabling root-login over SSH is a good idea, and provide examples of how to do so. What is Root-Login Over SSH? When a Linux server is set up, the root user is created by default. The root user is the most powerful user on the system, and has the ability to perform any task, including making changes to the system configuration, installing software, and creating new users. When ... Read More

How to Create a crontab Through a Script on Linux

Satish Kumar
Updated on 25-Jan-2023 10:58:05

188 Views

Creating a crontab through a script on Linux is a simple and efficient way to automate repetitive tasks and schedule them to run at specific intervals. In this article, we will take a closer look at how to create a crontab through a script on Linux, including examples and tips for troubleshooting. What is a Crontab? A crontab is a Linux feature that allows users to schedule tasks to run automatically at specific intervals. This can be useful for tasks such as running backups, sending email reminders, or performing maintenance tasks. The crontab is controlled by a daemon called cron, ... Read More

Difference Between .bashrc, .bash-profile, and .profile

Satish Kumar
Updated on 25-Jan-2023 10:57:20

7K+ Views

When working with the command line on a Unix or Linux operating system, there are three files that play an important role in setting up and configuring your shell environment: .bashrc, .bash_profile, and .profile. These files are used to customize your shell environment and set up different settings and configurations depending on your needs. In this article, we will take a closer look at each of these files and explore the differences between them, including examples of how they can be used to customize your shell environment. Bashrc The .bashrc file is a configuration file that is used to set ... Read More

Checking Host’s Network Availability in Linux

Satish Kumar
Updated on 25-Jan-2023 10:56:19

3K+ Views

When working with Linux systems, it is important to be able to check the network availability of a specific host. This can be useful for troubleshooting connectivity issues, monitoring network performance, or simply checking the status of a specific server or device. In this article, we will discuss several methods for checking the network availability of a host in Linux. Ping Command The most basic method for checking network availability is to use the ping command. This command sends an Internet Control Message Protocol (ICMP) echo request packet to the specified host and waits for a response. If the host ... Read More

Using sed With a Literal String Instead of an Input File

Satish Kumar
Updated on 25-Jan-2023 10:55:31

625 Views

Introduction Sed, short for Stream Editor, is a powerful command-line tool that is used to manipulate and transform text. It is commonly used to perform operations on input files, such as replacing text, deleting lines, and inserting new text. However, sed can also be used with a literal string instead of an input file, which can be useful in certain situations. In this article, we will discuss the different ways to use sed with a literal string and explore some examples of how to use this feature. Using the -e Option The most straightforward way to use sed with a ... Read More

When to Use an Alias vs Script vs a New Function in Bash

Satish Kumar
Updated on 25-Jan-2023 10:54:54

247 Views

When working with Bash, it's important to understand the differences between using an alias, a script, and a new function. Each has its own unique use case and can be used to accomplish different tasks. Aliases An alias is a way to create a shortcut for a command or series of commands. They are defined using the "alias" keyword followed by the desired shortcut and the command it should reference. For example, the following creates an alias for the "ls -la" command − alias ll='ls -la' This allows the user to type "ll" instead of "ls -la" to see ... Read More

Encrypting and Decrypting Directory in Linux

Satish Kumar
Updated on 25-Jan-2023 10:54:20

5K+ Views

There are several ways to encrypt and decrypt directories in Linux, but one popular method is to use the "ecryptfs" utility. This utility allows you to encrypt a directory using the user's login passphrase, and automatically decrypts the directory when the user logs in. Gpgtar gpgtar is a utility that allows you to encrypt and decrypt tar archives using the GNU Privacy Guard (GPG) encryption software. gpgtar uses GPG to encrypt the files in the tar archive, and then creates a new tar archive with the encrypted files. This allows you to easily encrypt a large number of files and ... Read More

Negate an if Condition in a Bash Script in Linux

Satish Kumar
Updated on 25-Jan-2023 10:53:21

7K+ Views

To negate an "if" condition in a Bash script in Linux, you can use the "!" operator. For example, if you have an "if" statement that checks if a variable "x" is equal to 5, you can negate that condition by using "if [ ! $x -eq 5 ]" instead. This will run the commands inside the "if" block if the condition is not true (i.e. if "x" is not equal to 5). Integer Comparison In Bash, you can use the following operators to compare integers − eq (equal to) ne (not equal to) gt (greater than) ge (greater ... Read More

Mapping Hostnames with Ports in /etc/hosts

Satish Kumar
Updated on 25-Jan-2023 10:52:37

7K+ Views

The /etc/hosts file is a simple text file used to map hostnames to IP addresses. It is used to resolve hostnames to IP addresses, bypassing the need for a DNS server. Each line in the file represents a single mapping, with the IP address followed by one or more hostnames separated by spaces. You can map hostnames with ports by specifying the hostname followed by the port number, separated by a colon. For example, to map the hostname "example.com" to the IP address "192.168.0.1" on port 80, you would add the following line to the /etc/hosts file − 192.168.0.1 example.com:80 ... Read More

Check if Directory is Mounted in Bash on Linux

Satish Kumar
Updated on 25-Jan-2023 10:51:49

25K+ Views

You can use the "mount" command to check if a directory is mounted on a Linux system. For example, to check if the directory "/mnt/data" is mounted, you can run − mount | grep "/mnt/data" If the directory is mounted, the command will return information about the mount point, including the file system type and the device it is mounted on. If the directory is not mounted, the command will return nothing. You can also check if a directory is a mount point using the findmnt command. findmnt -T /mnt/data This command will show all the mountpoints for ... Read More

Advertisements