Rotating cog with hands around it symbolizing the inner workings of the Linux command line such as the terminal, shell and kernel.

Linux Shells, Terminals & Kernels – Explained In-Depth

Hey There! Welcome!

In this lesson we’ll dive deep into the inner workings of our operating system and uncover the various components within. Are you ready? Let’s go!

Understanding the Linux Command Line Interface:

Over the past few lessons, we’ve become familiar with various commands we can use within our terminal to accomplish a variety of tasks.

But have you ever stopped to wonder how the text we enter into our command line gets translated into specific actions performed by our operating system?

To better understand this, let’s zoom in on the nuts and bolts of the Linux operating system!

				
					Welcome to Ubuntu 22.04 LTS (Jammy Jellyfish)

* Documentation: https://help.ubuntu.com
* Management:    https://landscape.canonical.com
* Support:       https://ubuntu.com/advantage

* Ubuntu Pro delivers the most comprehensive open source security and compliance features.

This message is shown once a day. To disable it please create the /home/ubuntu/.hushlogin file.
username@hostname:~$
				
			

At the very surface, we have the Linux terminal. It may come as a surprise, but what we are looking at here is merely an interface that accepts and displays text.

The processing and decision-making, is managed by several other components, which we’ll talk about in just a bit.

There's more than one command line Interface!

The Linux terminal interface comes in many different flavors depending on the distribution of Linux we’re using. Just as there are many web browsers to choose from in a Windows system, like Chrome or Firefox, Linux offers a multitude of terminal interfaces.

So how do we figure out which linux terminal we’re currently using? All we need to do is use the following command:

				
					ubuntu@ip-172-31-45-72:~$ echo $TERM
xterm-256color
ubuntu@ip-172-31-45-72:~$
				
			

Don’t worry too much about what this command is and how it works. All you need to know for now is that it prints the value of a variable which contains the information we’re looking for. (More about the echo command here) Let’s give it a try!

The output of this command reveals the terminal interface we’re currently using. In our case, we’re working with an “xterm” terminal, which is one of the most popular terminal interfaces. Different distributions might come with different terminal interfaces.

Try accessing a linux terminal on a mobile phone, a video game console, or even a smart fridge and type in the above command to see what terminal you end up with. Have fun!

Understanding Linux Shells:

Once you are done playing around, let’s continue our journey into the Linux operating system by going one level deeper.

As we mentioned earlier, the command line interface is simply a tool for accepting input and displaying output. The brains behind this operation are handled by something called the shell.

Think of the Linux shell as an interpreter between us and the operating system. It takes our commands and translates them into actions for our operating system.

For example, when we execute a command such as ps, the Linux shell locates the corresponding file within the /bin directory and runs it on our behalf.

This allows us to communicate with our operating system by using simple commands instead of dealing with the complexities of our operating system directly.

But that’s not all! The Linux shell also serves as a safeguard by limiting our ability to perform certain actions. This helps reduce the risk of users accidentally compromising the system’s security or exposing it to potential threats.

Hence why it’s called a shell; it acts as a protective layer between the user and the operating system. How cool is that?

Command Line vs graphical shells:

Shells designed to work with a command line interface are known as command line shells. These shells are specifically made to interpret the commands we enter into our interface and translate them into actions for our operating system.

However, some Linux distributions come with a graphical user interface instead of a command line interface. For these systems, a different type of shell is employed, known as a graphical shell.

Instead of interpreting commands, graphical shells interpret user actions on the graphical interface, such as clicking a button, into tasks for the operating system.

For instance, you might have heard of Ubuntu Desktop, which comes with a graphical interface and, consequently, a graphical shell.

On the other hand, Ubuntu Server, which we are using for throughout this tutorial, features a command line interface and employs a command line shell.

There is more than one Linux shell!

Speaking of our shell, it’s important to note, that just like there are numerous terminal interfaces, there’s also a variety of shells developed by different developers. To identify the one we’re using, we need type the following command:

				
					ubuntu@ip-172-31-45-72:~$ echo $0
-bash
ubuntu@ip-172-31-45-72:~$
				
			

Once again, don’t sweat the details of this command. We’ll get into that in a future lesson. From the output we can see that in this case we are using a bash shell, which is among the most popular command line shells.

Just like most other applications, the code for our Linux shell is stored within the /bin directory. Let’s use the ls command to take a peek:

				
					ls /bin
 aa-enabled                           ntfsls
 aa-exec                              ntfsmove
 aa-features-abi                      ntfsrecover
 acpi_listen                          ntfssecaudit
 add-apt-repository                   ntfstruncate
 addpart                              ntfsusermap
 addr2line                            ntfswipe
 ...
 bash                                 perlbug
 ...
 ubuntu@ip-172-31-45-72:~$
				
			

And there it is! This is where all the code that makes up our Linux shell resides. Fascinating, right?

Understanding the Linux Kernel:

We’ve uncovered the secrets of Linux terminals and shells, but now it’s time to dive even deeper. To carry out various tasks, the software within our system needs to harness the power of our computer’s hardware.

For example, for the ps command to generate a list of all the processes in our computer, it needs to employ our computer’s CPU, memory, and other components. This process is facilitated by a crucial component called the Linux kernel.

The Linux kernel is the core or the brain of our operating system, acting as the middleman between the hardware and the software within our system.

The Linux kernel’s responsibilities include allocating resources like CPU time and memory to various processes in our computer, as well as managing requests from the Linux shell or other applications.

In essence, it ensures that all the hardware in our computer is effectively utilized to accomplish any task required by our commands or applications.

The Linux kernel is a fairly advanced concept, so don’t worry about mastering it just yet. For now, all you need to know is that our commands and applications work hand-in-hand with the Linux kernel to make use of the hardware in our system and perform various tasks.

Final Thoughts:

Don’t worry about memorizing every detail from today’s lesson. Remember, the true beauty of learning Linux is in the journey itself, not just the destination.

As you continue to spend time on the command line, you’ll gradually become more familiar with its intricacies. Aim to grasp the general purpose of terminals, shells, and kernels—that’s your key takeaway.

To aid with this, remember to try out the exercise we mentioned earlier. Access a command line on diverse devices like a phone, game console, or even a smart fridge, and explore what type of terminal each uses.

If accessing these terminals isn’t immediately possible, no stress; remember, we’re here to learn and have fun.

Fun Facts to brighten your day:

  • You can find terminals in the most unexpected places, like your gaming console or a smart fridge!

  • The shell is named for its role in protecting the OS, but it’s also great at shell-tering you from the complexities of direct system interaction. How shell-tastic!

  • Finding your shell with echo $0 feels like asking your digital assistant which language it speaks.

  • Think of the kernel as the mysterious overlord of your computer, silently pulling the strings and making sure everything runs smoothly while remaining hidden in the shadows.

  • In the Linux universe, using a graphical shell is like driving an automatic car, while a command-line shell is more like a manual – it requires more effort, but purists swear by the control it offers.

Test Your Knowledge (Practice Quiz):

There has been error loading this quiz, please refresh the page or enable JavaScript to continue.

0/5

Take your Knowledge to the next level!

Learn the Linux command line with our interactive course!

Animated Rocket symbolizing how awesome our Linux command line course is.

Welcome back!

Don't have an account? Select the register button to create one!

First time around?

You're in the right place! Fill out the form to create your account: