The Shell - The Unknown Black Hole - TUXEDO Computers

  ATTENTION: To use our store you have to activate JavaScript and deactivate script blockers!  
Thank you for your understanding!

The Shell
The Unknown Black Hole

Shell, Bash, Terminal, Console? We clarify

Before there were graphical user interfaces, operating systems were operated via terminals. Those who still remember 10 kg displays with green or amber output know this. Even today, a terminal under Linux is an alternative method of operating computers, but it is no longer absolutely necessary. There are hardly any situations today where you can’t get around a terminal.

Overview

The shell

Terms like shell, terminal, or console are often used synonymously, which leads to some confusion of terms. In this article, we will disentangle the basic terms and their connection and give a brief introduction to how to interact with them.

In computer science, a shell is a software by which a user interacts with an operating system. It is a command-line interpreter that allows you to interact with the OS through textual commands. It takes your input, processes it, and communicates with the Linux kernel to execute the requested actions. Finally, it gives you an output. Linux knows different shells such as Bash, Dash, Fish or Z shell, among others. Distributions come with a default shell, usually Bash, but the user can switch to other shells. These work fundamentally the same, but differ slightly in their approach and included functionality

Shells or their command line interfaces in a graphical environment are used to execute scripts and commands that perform actions on the respective computer or via SSH on remote computers. Shells already bring plenty of built-in commands for these purposes.

A terminal, in simple terms, is the shell’s window. Here, you enter the commands to be processed. Synonymously, the terms console, command line or CLI (Command Line Interface) are also used. The proliferation of terms has grown historically and unfortunately, we have to live with it. But if you know the terms, it’s not so bad and nothing to be afraid of.
 

Terminal emulators

A terminal runs below the graphical layer. To have access to a text-based terminal in the graphical layer - in our case KDE Plasma - there are various terminal emulators. A terminal emulator shipped by default with all distributions that use the common X11 display server is xterm. The individual desktop environments bring their own customized emulators such as GNOME terminal, XFCE terminal or MATE terminal. Windows also has a terminal emulator with cmd.exe. In KDE Plasma and thus in TUXEDO OS the emulator is called Konsole.

 

You can find it in the main menu by simply typing the first two or three letters and then clicking Konsole. Alternatively, start it by keyboard with CTRL+ALT+T. You can also install the Yakuake drop down terminal, which unfolds from the top of the screen using a key combination (by default F12). If you don’t like the colour scheme, font size, or other default settings for Konsole or Yakuake, right-click to change them using Edit Current Profile. If necessary, you can also create multiple profiles with different configurations.

The practical part

Now that the terminology and its connections have hopefully been sufficiently clarified, we will explain some of the most important rules and commands in Konsole, which also apply to other terminal emulators and terminals in general. Firstly, it is essential to know where you are in the file system. The first thing you see in your terminal is the so-called prompt.

The prompt

Simply put, the prompt is an input field in the terminal emulator that allows you to input and output commands. The prompt also provides the user with some useful information:

The prompt can look different for you, you can also install individual designs. However, it always displays some basic information. First, it displays the name of the logged-in user and the host name of the installation in the format user@hostname. After the colon comes a wavy character, the tilde. It represents where you are currently located in the file system. The tilde always represents the home directory of the logged-in user and always represents the starting point. In our case, this is ft@tuxencrypt, the latter being the hostname we chose during installation. This means that the user ft is in his home directory.

To make this clear, let’s apply a first command right away. If you type the command pwd, which stands for print working directory, and press Enter, the terminal will return your location in the file system.

Executed commands always affect the respective location in the file system or the path entered with the command. More about this later. It is therefore always important to know where you are. Even in a graphical file manager, you have to be in the right folder to edit files. From experience, it is critical to mentally apply this principle to the terminal before you can work with it successfully.

Root - the SuperUser

You have just learned that as a logged-in user, at the beginning you are always in your personal home directory.

Before we dive further into the file system, one more significant point: By default, the files in your Home belong to the user who is logged in at the time. You can read them and write to them. The rest of the file tree belongs to root, the superuser account in Unix and Linux.

This is a user account for administrative purposes and has more restrictive access rights. Suppose you want to look at what files and directories are in /etc. You can do this without root privileges. However, to save changes, you need these extended privileges.

Most Linux distributions use the sudo command to temporarily grant root privileges to the user. To achieve this, a command is preceded by sudo, after which the root password is requested. An example is updating the repositories using sudo apt update.

Frequently used commands

Assuming you want to look at which files are in the /etc directory, there are two ways to get there. which is used here as an example of how to send commands to the right place. First the somewhat more complex way via the command cd (change directory). To achieve this, give the cd command the folder you want to change to, like cd /etc in our example. If you now call pwd again, the prompt shows that you have changed to the /etc directory.

You have given the cd command the path to another directory. In our case, the path is simple and short, but it can also include many subdirectories, as in cd /etc/apt/sources.list.d.

But let's first continue in our example: So you are now in the directory /etc and want to view its contents. Since you are already in the directory, the command ls (list) is sufficient for that. This lists the directories and files without further information in different colours. The output becomes more detailed by using options by typing ls -l. If you also want to show the hidden files, the option -a is added. The commands are then either ls -a or more detailed ls -la

The detailed output shows the permissions, the owner in terms of user and group, the size and the creation date of a directory or file.

The direct way

However, there is also an easier way to display the contents without changing the directory first. Here you give the command directly the path to which the command should affect. So you can achieve the same thing from your home by using ls -l /etc. This expresses that you want to see a listing of the contents of /etc.

Next, you may want to look at the contents of one of the files displayed there. To do this, you can use the cat (concatenate) command, as in cat /etc/apt/sources.list.d/tuxedo-plasma.list. If you are already in /etc the command is cat apt/sources.list.d/tuxedo-plasma.list. Since you are only looking at something here, your user rights are sufficient for this, although the content does not belong to your user, but to root.

It’s different, if you want to edit a file, that succeeds apart from in Home only with root privileges. Let’s assume you want to change the file tuxedo-computers.list. For this, we use the nano editor with SuperUser privileges as in sudo nano /etc/apt/sources.list.d/tuxedo-plasma.list. With this you open the file in write mode and can edit it if necessary. Save changes made with CTRL+O and then close Nano with CTRL+X.

Note: A useful function of the shell is the auto-completion for commands. This allows even long paths to be entered quickly. For example, type /etc/apt/so and press the Tab key. This completes so to sources.list. Proceed in this way until the desired path is entered.

Commonly used commands include those for creating, copying, renaming, and deleting files and directories. Use commands such as mkdir (create directory), cp (copy), mv (rename or move), and rm (delete). If, for example, a zip archive cannot be unpacked, the command file filename helps to clarify whether it is really the specified file type or whether someone is trying to foist something on you.

Use the up and down arrow keys to access previously entered commands from the command history. Press the Enter key to re-execute a command from the history.

You can also combine multiple commands. The characters between the commands determine how execution is handled. With sudo apt update ; sudo apt upgrade, the semicolon conditions both commands to be executed unconditionally in succession, even if the first command fails. In contrast, sudo apt update && sudo apt upgrade executes the second command only if the first one completes successfully. Conversely, mount /cdrom || eject /cdrom executes the second command only if the first fails.

If you are unsure what a command does that you found on the Internet, please be careful, especially if it requires root privileges. The Explainshell website breaks down commands into their components and explains them.

A good start to get to know more commands is this command overview Clicking on the individual commands leads to a detailed explanation of what a command is used for and what options it offers.

Why use the terminal at all?

There are several valid answers to this, and they apply to different user groups. If you are the type that feels most comfortable in the graphical environment and would like to work mostly with a mouse or touchpad, there are still situations where the terminal is helpful. For example, when something is not working as it should, and you can read the logs using the journalctl command. A detailed explanation of this powerful command can be found in the article Using Journalctl. Our experience also teaches that updates to the system are more informatively mapped in the terminal and thus safer to execute than in graphical applications.

However, if you are one of those users who are generally annoyed by graphical applications and cannot identify yourself as a mouse pusher, if you find graphical applications slow and confusing, then you should probably dive deeper into the topics of shell and terminal. Once you get involved with the terminal, over time a workflow will emerge that probably combines both paradigms of operation, graphical and textual. Advantages of the terminal include a faster workflow, better error messages, and a more profound understanding of Linux in general.

The criticism often heard in the past that Linux was backward-looking and complicated because the use of the shell was mandatory no longer applies today, if it did at all in the last ten years. You can use TUXEDO OS without a shell throughout today, but it is not always the best way. Of course, the decision is entirely up to you.

Complementary to this article is the YouTube series Linux Crash Course by the fabulous Jay LaCroix.