18.10.2024

What is Linux Bash and How to use It?

In Linux it is quite common to use the command line or terminal to work with the space and components of the OS. And in articles and conversations you can often hear such phrases as: terminal, Bash, Zash, commands and utilities. But why is it all and what is the sense in it? Let's try to briefly but succinctly explain their relationship and consider the basic commands and what to do if you do not know them!

What is the principle of operation?

A terminal (or terminal program) is software that allows the user to interact with the system through an interpreter. Examples of such programs are gnome-terminal, xterm, konsole, and others. When you start a terminal, it launches a shell, which is a command interpreter. The most popular shells in Linux are bash, zsh, sh, fish, and others. The shell interprets the commands you enter and executes them.

Screenshot №1 — Schema of work

Let's imagine we send a command to an open terminal and what happens inside?

  1. You enter commands from the keyboard;
  2. The terminal sends the entered commands to the shell;
  3. The shell interprets the commands and decides what to do. If it is an inbuilt shell command (e.g. cd), it is executed directly in the shell. If it is an external command (e.g., ls), the shell calls the appropriate executable;
  4. If it is an external command, the shell runs the appropriate executable, creating a new process.
  5. The new process interacts with the operating system kernel to make the necessary system calls (e.g., to read directory contents or display data on the screen);
  6. Output: The results of command execution (stdout and stderr) are passed back through the shell to the terminal, which displays them to the user.

Thus, the interaction structure is as follows:

User → Terminal → Shell → OS kernel.

The terminal is just an interface for entering commands and displaying output, and the real work is done by the operating system shell and kernel.

Where to find bash commands?

Indeed, it is necessary to know the basic commands that will allow the user to perform tasks efficiently. For this purpose, there are utility directories that contain information about most of the existing utilities and their commands. Let's install one of them:

dnf update && dfn upgrade \
dnf install info -y

If you are using the apt manager, then use the command:

apt update && apt upgrade \
apt install info -y

After installation, check that everything has installed correctly and the directory is working:

info

Screenshot №2 — Installation software

All steps in the tutorial can be performed on powerful cloud servers. Serverspace provides isolated VPS / VDS servers for common and virtualize usage.

Screenshot №3 — Create Server

It will take some time to deploy server capacity. After that you can connect in any of the convenient ways!
To search for a command, you must type the key syntax and select the appropriate section. For example, we need to move between directories and for this we need a command, enter the following:

info

Since we're looking for a list of commands for bash, we'll go to the appropriate section and enable regular expression search using the / button. After that we will enter a keyword and search for different occurrences via the S button!

Screenshot №4 — Search pattern

As you can see in the screenshot above the search has completed and highlighted the desired command line, there are times when there is no suitable one in the directory and you need to use our Linux command navigator list!