Found 2065 Articles for Operating System

Using sed With a Literal String Instead of an Input File

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

751 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

266 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

7K+ 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

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. 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

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 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

28K+ 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

What Does cd do on Linux

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 the "documents" folder located within the "user" folder in the root directory. If you use cd command without any argument it will take you to your home directory. The Meaning of – With cd The "-" (dash) symbol is a shortcut that can be used with the cd command to ... Read More

Anonymous and Named Pipes in Linux

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 in Linux and other Unix-like operating systems that allow the output of one command to be passed as input to another command. They are represented by the "|" symbol, and are often used to chain multiple commands together to perform complex tasks. For example, the command "ls -l | grep ... Read More

Sending Emails From Terminal In Linux

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

986 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 by using the -a option and specifying the path to the file you want to attach. echo "message body" | mail -s "subject" -a /path/to/attachment recipient@email.com You can also use other command line mail clients such as mutt, mailx, etc. Architecture of an Email System An email system consists ... Read More

Read the Source Code of Shell Commands on Linux

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 of the ls command, you can use the command − cat /bin/ls If you want to view the source code of a command that is installed from a package manager, you can use package manager command to find the location of the source code. For example, on a Debian-based ... Read More

Advertisements