What Is the Linux Command Line and How Do You Use It? - Android Tricks 4 All
News Update
Loading...

Sunday, September 26, 2021

What Is the Linux Command Line and How Do You Use It?

On most Linux computers, you have the option to open a window and type commands that tell your machine to do things. Sometimes, as your computer is booting up or if something crashes, this text-based interface occupies your entire screen.

This is the Linux command line. It’s older than the various desktop interfaces, but there’s a reason it’s still around and widely used. Many people swear by it.

A Brief History of the Command Line

The interface you use to view and interact with an operating system, whether text-based or graphical, is known as a shell. The first shells were text-based. This is because the earliest electronic computers were not household devices. Instead, they were giant mainframes that occupied entire rooms.

Back then, computing power was pretty low and network connections were slow. You can store very many files, and many users can sign into a system simultaneously over a very slow connection when you’re only working with text.

In 1969, Dennis Ritchie and Ken Thompson at Bell Labs developed the Unix operating system, one of the first mainframe operating systems to gain widespread adoption.

Unix operated on mainframes as a shared system, with people interacting with the computer from individual terminals consisting of only a keyboard and a screen. Users did everything from creating and navigating files to transmitting data by typing commands using a shell, which the mainframe then interpreted.

If anything went wrong, a system administrator could check via a console, a dedicated text-entry, and display device used for system-related messages such as those concerning the BIOS, bootloader, or kernel. Linux is a Unix-like system that replicates much of the functionalities of Unix, but as free software available to all.

The Thompson shell (written by Ken Thompson) was the initial shell for Unix, but a replacement came from Stephen Bourne in 1979 known as the Bourne shell. In 1989, Brian Fox create the Bourne Again shell (bash for short) as a free software replacement of the Bourne shell as part of the GNU Project. This is the default shell for most Linux operating systems.

Thus we have several of the names that are still commonly used for the command line today: command line, shell, terminal, console, and bash.

How to Use the Linux Command Line

To get started, you simply need to click on your Linux distribution’s command-line app. For many, the name is simply “Terminal.” That’s because the apps are essentially modern virtual versions of the early Unix terminal.

An empty terminal window doesn’t appear to show much, but it does provide you with three bits of information: your username, the hostname (either your local PC or a remote server), and your current directory (by default, your home folder, indicated by a ~). The $ marks the end of the prompt.

When you type a command into the terminal and hit Enter, the results often appear instantly. Many core commands are short, such as the cd command for changing a directory, ls for listing files in the current directory, or rm for deleting a file.

Most commands follow a standard syntax. The formula goes like this:

command option target

The target is often a file or a folder. Here is an example using the ls command:

ls -a Downloads

In the aforementioned snippet, ls is the command, -a is the option, and Downloads is the folder that your command is targeting.

So what does this command do? Well, by default, ls lists all of the visible files in your current directory. The -a option tells ls to display hidden files or folders as well. The target directory Downloads tells ls to list the files in the Downloads folder rather than the folder you’re currently working in.

There are innumerable command-line programs out there, with many preinstalled by default. If you’re ready to dive in, check out our Linux command line cheat sheet.

Why Might You Use the Command Line Today?

Some tasks are simply faster in the command line. One use case many long-time Linux users share is managing software. If you know the exact name of an app you want, it’s faster to type the installation command into a terminal than to open a Linux app store. That’s not to say that Linux app stores are slow.

Typing an apt or dnf command is quicker than using any app store, including those on Windows, macOS, Android, or iOS. The command line also tends to provide more information in the process.

The command line offers fast ways to do very specific tasks that you repeat periodically, such as cloning a hard drive or renaming large numbers of photos. There are graphical apps that do these things, but if you’re performing the task in an identical way every time, just entering a single command can feel like such a time saver. You can even automate these tasks by writing a script.

Some commands launch what feels like full apps that run inside the terminal, such as the top command that can replace your graphical system monitor tool.

Knowing your way around a terminal also expands the type of hardware you know how to use. For example, you can set up your own server, either at home or remotely. Maybe you decide to turn a Raspberry Pi or an old laptop you have lying around into a home media server or your own cloud storage device.

And if for whatever reason you find yourself staring at a computer that won’t boot, knowledge of the command line increases the chance that you can repair your system yourself without having to reinstall your OS.

Does Linux Require the Command Line?

At this point in time, you no longer need to know your way around the command line to use Linux. Due to the available desktop environments and apps, Linux is as easy to use as any other operating system, if not easier.

But while learning the command line isn’t necessary, it has its benefits. And if you deeply fall in love with the terminal, you can install a program such as Tmux that lets you run and view multiple commands simultaneously.



Comments


EmoticonEmoticon

Notification
This is just an example, you can fill it later with your own note.
Done