Sending Emails from Terminal in Linux

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

1K+ 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 Source Code of Shell Commands on Linux

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

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

Search Within Specific File Types Using Grep on Linux

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

9K+ 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 in the directory "test", you would use the command − grep -r -E 'example' --include='*.txt' test/ This command searches recursively through the "test" directory and its subdirectories, looking for files that have the ".txt" extension and contain the word "example". You can also use find command with -type and ... Read More

Move All Files Including Hidden Files into Parent Directory in Linux

Pradeep Jhuriya
Updated on 25-Jan-2023 10:41:57

9K+ Views

Introduction In Linux, hidden files, also known as dotfiles, are files whose names begin with a dot (.) character. These files are often used to store configuration data or other important information that should not be changed or deleted by the user. If you have a directory with a large number of hidden files and you want to move them all to the root directory, there are several ways to do this. In this tutorial, we will discuss two methods for moving all files, including hidden files, from a directory to its home directory in Linux: the mv command and ... Read More

Run Cron Job Only If It Isn't Already Running in Linux

Pradeep Jhuriya
Updated on 25-Jan-2023 10:40:53

2K+ Views

Introduction Cron is a utility in Linux that allows users to schedule commands or scripts to run automatically at a specific date and time. However, sometimes it may be necessary to ensure that a cron job does not run more than once at a time. In this article, we will discuss two ways to prevent overlapping cron tasks: using process tracking and using a “.pid” file. Locate running instances by process One way to avoid overlapping a cron task run is to check for the presence of the task's process before running it. This can be done using the pgrep ... Read More

Find Current Working Directory of a Running Process in Linux

Pradeep Jhuriya
Updated on 25-Jan-2023 10:38:29

9K+ Views

Introduction One of the basic tasks when working with processes on a Linux system is determining the current working directory of a process. The current working directory, also known as the "current directory" or "current working folder, " is the directory in which a process runs and interacts with files. Knowing the current working directory of a process can be useful for a variety of purposes, such as debugging, understanding the environment in which a process is running, or simply monitoring the activity of a process. In this article, we will discuss how to find the current working directory of ... Read More

Remove the Last N Lines of a File in Linux

Pradeep Jhuriya
Updated on 25-Jan-2023 10:37:16

12K+ Views

Introduction There may be times when you need to remove the last few lines of a file on Linux. For example, you may have a log file that is constantly being added and you want to keep only the most recent entries. In this tutorial, we'll explore a few different methods to remove the last N lines of a file on Linux. Use the head and tail commands The head and tail commands are two very useful utilities for displaying the beginning and end of a file, respectively. By combining these commands, we can easily remove the last N lines ... Read More

Extract WAR File in Linux

Pradeep Jhuriya
Updated on 25-Jan-2023 10:33:04

13K+ Views

Introduction WAR (Web ARchive) files are a type of archive file used to package web applications into a single file. They are similar to Java ARchive (JAR) files and are typically used to deploy web applications in a Java environment. In this article, we will learn how to extract a WAR file on Linux using the command line. A WAR file is essentially a ZIP file that contains all the files needed for a web application, including HTML, CSS, JavaScript, and Java files. Checking out a WAR file allows you to access the individual files it contains and make changes ... Read More

Displaying Files Side by Side in Linux

Pradeep Jhuriya
Updated on 25-Jan-2023 10:31:53

18K+ Views

Introduction Working with files on Linux can often involve comparing or analyzing multiple files at once. A useful way to do this is to view the files side by side in the terminal, allowing for easy comparison and analysis. In this article, we'll explore various ways to view files side-by-side on Linux, including using the diff and sdiff commands, as well as using the text editors vim and emacs. Using the diff command The diff command is a standard Linux utility that compares two files and displays the differences between them. It can be used to view files side by ... Read More

fd: An Alternative to the Linux Find Command

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

3K+ 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 specifying search parameters, and the ability to search using a specific file extension or name. Installation The fd command can be installed on Linux and macOS using the package manager of your distribution. On Debian based distributions − sudo apt-get install fd-find On Fedora and Centos − sudo yum ... Read More

Advertisements