What is the Linux Command Line?

This article will cover what is the Linux command line or what we call today the command line interface (CLI). Before we had GUI interfaces, we had the CLI and it was the main way users interacted with computers until the late 1980s when GUIs were introduced. I will argue that CLI is still the main way system administrators do their work today. 

Linux is a family of open-source Unix-like operating systems. An operating is the interface between a computing device like a computer, a tablet, a mobile phone, and others, It handles the communication from the hardware to the user. There are two user interfaces to the Linux operating system either through a graphical user interface (GUI) or a command-line interface (CLI). 

But, before we dive into the Linux command line, let me provide some historical context of what Linux is. Linux was introduced by Linus Torvalds on September 17, 1991. Linux is typically packaged as a distribution. There are hundreds of Linux distributions in the marketplace today. Here is a list of distributions from Wikipedia

\"\"/

According to W3Techs, 38.8% of all Web sites are running Linux, as of December 20, 2021. Here is a graphic from their website. 
 
Their methodology is sound and I found it a lot different from what most sites say. Yet a lot of focus is on the desktop operating system market. I will go so far and say that Linux runs the Internet today and it is the plumbing for how the internet works. If you want to work in the world of computing, you need to know Linux today. 

Brief History of the Linux Command Line

The precursor to Linux was Multics which was developed by MIT, AT&T Bell Labs, and General Electric as a time-sharing operating system. In 1969, Ken Thompson, a programmer, who had worked on Multics decided to write his own operating system on the PDP-7 at Bell Labs. In 1969, the team who consisted of Thompson, Ritchie, and Canaday implemented a hierarchical file system, processes, device files, and a command-line interpreter. Also, utility programs were written modeled after Multics features but smaller. 

Eventually, the system became UNIX in the 1970s. In 1973, Unix v4 was rewritten in a new programming language called C which is still one of the most popular programming languages today because of its portability across different hardware architectures. Unix became available to educational institutions in 1973 and commercial licenses in 1975.  Unix continued to grow in the 1970s and 1980s. Fragmentation started with systems developed by Microsoft called Xenix and Santa Cruz Operations (SCO) called SCO Unix. Because of the courts and unfavorable licensing options, Berkley develop an alternative to System V called BSD which ended up as a precursor to BSD distributions we have today. Unix and BSD continued their march forward into the 2000s. Unix rights were sold to Novell corporation which turn over the rights to the X/Open consortium. Fights over UNIX and BSD continued with versions for different architectures. 

In 1991, Linux began as a personal project of Finnish student Linus Torvalds to create a free operating system in the C language.  Linux continued its upward trajectory in parallel to the Unix fragmentation that occurred and slowly but surely started squeezing out its UNIX competitors. 

 In 2018, Linux contained 23.3 million lines of open-source code. The X Window System (Graphical User Interface (GUI)) was ported to Linux in 1992 and credited with it making Linux a very popular option. Up until 1992, Linux was running using a command-line interface. 

Linux Architecture

From IBM Developer, the following graphic illustrates the Linux Architecture. I found this to be the best representation of the Linux architecture. Linux starts with a kernel that sits on top of the hardware and provides device drivers to interact with the hardware and is the interface between the operating system and the hardware. On top of the kernel, there is what is called a shell in Linux. A common shell is the bourne shell which is the original command interpreter for UNIX and ported over to Linux. There are other shells available and can be swapped out by users depending upon their preference. In Linux, the bourne shell is called BASH which is one of the original shells for Linux. On top of the shell is where the user programs and utilities reside in Linux. There are other shells available such as ksh, tcsh, and zsh.


Source:  IBM Developer

You can think of a shell as a command interpreter. A user types in a command and shell does work depending upon the command entered. Unless you boot directly into a CLI, most Linux systems boot into a graphical user interface (GUI).

To launch a CLI in Linux, you have to use a program called a terminal. Each distribution and GUI might use a slightly different way to get into the terminal which is the application that launches a shell in Linux. 

Linux Shell

A Linux shell is a command-line interface (CLI) that is used to accept user commands and run those commands. An example of a Linux shell is below using JS/LINUX. When you launch the shell, you are put into a command prompt. This is where you can run different Linux commands. 

NOTE: You can always click on JS/LINUX to play around with a Linux command line. In a future article, we will be providing an interactive shell to learn some basic Linux. 

In this case, the localhost is what Linux calls the local machine that you are running the command shell on. This prompt will vary depending upon the distribution you are using. 

\"\"/

Basic Linux Command Line Commands

As a novice Linux user, you will look at the command prompt and probably not know what to do but it is very easy with some simple commands to get you started. A Linux shell interacts with a hierarchical file system. A hierarchical file system is designed after a physical filing cabinet. In your filing cabinet, you have folders (directories in Linux speak) and files (also called files in Linux speak). You can nest folders inside of each other. You can think of these as branches on a tree with the file being a leaf of the tree. A file usually has a file name and an extension such as file.py. The file name is file and the extension is py which represents a Python script. 

Here is a list of basic Linux commands to get around.

  • clear – clears the screen. NOTE: Always hit enter to run the command.
  • ls – provides a basic directory listing of the current directory (think of a directory as a folder)

  • cd – cd stands for change directory and it allows you to navigate to another directory

  • mkdir – allows you to make a directory
  • rmdir – allows you to remove a directory so long it is empty

  • cd .. – allows you to move up one level of a directory

  • rm – allows you to delete a file
  • cat – displays the contents of a file

These are just a few examples to get you started. 

Conclusion

In this article, we explored a brief history of Unix and Linux, the Linux architecture, the Linux Shell, and a few commands of Linux. 

If you have any questions, please let me know in the comments. 

Dr. M

Dr. M

Leave a Reply

Your email address will not be published. Required fields are marked *