Satish Kumar has Published 1040 Articles

Negate an if Condition in a Bash Script in Linux

Satish Kumar

Satish Kumar

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

8K+ 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. ... Read More

Mapping Hostnames with Ports in /etc/hosts

Satish Kumar

Satish Kumar

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

8K+ 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 ... Read More

Check if Directory is Mounted in Bash on Linux

Satish Kumar

Satish Kumar

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

27K+ 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, ... Read More

What Does cd do on Linux

Satish Kumar

Satish Kumar

Updated on 25-Jan-2023 10:49:50

2K+ Views

cd stands for "change directory" and is used to navigate the file system on a Linux computer. When used with a specific directory path as an argument, cd will change the current working directory to that location. For example, the command cd /home/user/documents will change the current working directory to ... Read More

Anonymous and Named Pipes in Linux

Satish Kumar

Satish Kumar

Updated on 25-Jan-2023 10:49:10

1K+ Views

In Linux, a pipe is a mechanism that allows the output of one command to be used as the input for another command. Pipes allow for powerful command line operations by allowing the output of one command to be used as input for another command. Pipes Pipes are a feature ... Read More

Sending Emails From Terminal In Linux

Satish Kumar

Satish Kumar

Updated on 25-Jan-2023 10:48:14

984 Views

You can send emails from the terminal in Linux by using the command line tool called "mail." This tool is typically pre-installed on most Linux distributions. To send an email, you would use the syntax − echo "message body" | mail -s "subject" recipient@email.com You can also include attachments ... Read More

Read the Source Code of Shell Commands on Linux

Satish Kumar

Satish Kumar

Updated on 25-Jan-2023 10:46:51

3K+ Views

To read the source code of shell commands on Linux, you can use the command line utility cat or less to view the file. You can also use a text editor such as vi, nano, or emacs to open and edit the code. For example, to view the source code ... Read More

Search Within Specific File Types Using grep on Linux

Satish Kumar

Satish Kumar

Updated on 25-Jan-2023 10:43:23

5K+ Views

To search for a specific pattern within a specific file type using the grep command in Linux, you can use the -r option to search recursively through a directory and the -E option to specify the file extension. For example, to search for the word "example" within all text files ... Read More

fd An Alternative to the Linux find Command

Satish Kumar

Satish Kumar

Updated on 25-Jan-2023 10:30:32

2K+ Views

The fd command is a popular alternative to the find command in Linux. It is a faster and more user-friendly version of find, and is written in Rust for performance. Some of the key features of fd include the ability to search using regular expressions, a more natural syntax for ... Read More

Guide to Generate Random Numbers in Linux

Satish Kumar

Satish Kumar

Updated on 25-Jan-2023 10:24:42

10K+ Views

In Linux, you can generate random numbers using the random or urandom files in the /dev directory, which are special files that generate random data. To generate a random number between 0 and 32767, you can use the command echo $((RANDOM)). To generate a random number within a specific range, ... Read More

Advertisements