How to Use Here Document (HereDoc) in Linux Shell Script

While writing shell script, you might get stuck in the situation where you want to redirect a block of lines from your script to interactive commands like sed, cat, ssh, or ftp. The purpose of this redirection might vary from situation to situation. For example,

What is Exit Status Code ($?) of Last Command in Linux

The “$?” is a built-in variable that your shell uses to store the exit status code of the last executed command in integer format and remains unchanged unless the next command is executed. Using this exit status code, you can debug the problem that occurred

Beginners Guide for Export Command in Linux

Whenever you start a new shell session (by opening a terminal), a set of environment variables is loaded from the shell configuration file into your current shell session. These environment variables determine different customizations in your shell, like the default editor using “$EDITOR“, or setting

Beginners Guide for PS Command in Linux

The PS, a.k.a. “process status”, is a native command-line utility for UNIX-based systems to monitor the currently running processes in your system. It reads the information from the virtual files in the /proc filesystem and gives the running processes information like memory consumption, CPU usage,

How to Run (.sh) Shell Script in Linux [for Beginners]

How do I write and run a shell script on Linux? Is there a way to run a shell script without executable permission, or can we run a shell script directly from a URL? Don’t worry; you are about to learn all those things in

What is Bash Shell on Linux?

Before understanding what is Bash shell, you must be familiar with the concepts of a command-line interpreter and Linux Shell (or sh). What is a Command-Line Interpreter? The term “command-line interpreter” refers to a program or text-based interface that sits between the user and the

Absolute vs Relative Path in UNIX/Linux

In Linux, you might already be navigating through different directories without knowing whether an absolute or relative path is being used. It becomes important for you to understand them when you are working with scripts, navigating through different user or root directories, or creating symbolic

How to Count String Occurrences in a Text File

The GUI text editor gives you a separate panel in the footer to inform you of the number of words, lines, and characters in your text file. Even though you can easily find the number of strings that occurred in your text file using this

Beginners Guide for Eval Command on Linux

The eval command is used to execute specified arguments as a single command in the current command-line processing and return its result. It will combine (or construct) the arguments into a single string and use it as input to the shell, which will execute the

Beginners Guide for Alias Command in Linux

In Linux, the alias command is used to create shortcuts for long commands that have the same functionality as if you were writing the whole command. This way, you can improve your productivity and save time by creating a few aliases for the long or

How to Shrink Long or Multiple Commands into a Single Short Command

Do you still type the long “sudo apt update && sudo apt upgrade -y” commands each time you want to update your Debian-based system? Or are you still navigating into directories (ex: “/var/www/html“) using the cd command each time you have to modify something there?