The command line is almost 50 years old, but not outdated. Text-based terminals are still the best way to do many tasks, even in the age of graphic desktops and touchscreen gadgets.
In fact, the command line is more respected than ever since Microsoft created a powerful new Windows Terminal application. The PowerShell environment of Windows 1
The command line was once the only option
If you wanted to interact with a computer, you typed. That was it's. Otherwise nothing was. This may sound restrictive and archaic, but as a novelty to the use of punched cards or perforated paper tapes, typing was radical and transformative. The switch from teletypewriters with their paper rolls to terminals with cathode ray tube screens (CRT screens) was another shift in human-computer interaction. Now you can send instructions to the computer and quickly display answers on your screen. No more clack-clack clack while you waited for your paper print to rattle off your Teletypewriter.
Good enough, but that was then, that is now. Computing is a different kind of ball game. Aside from the obvious limited cases, such as using a computer that does not have a graphical desktop environment installed, or using a remote computer over SSH over a low-bandwidth connection or controlling a headless or embedded system, why should the command line to be used over? A graphical desktop?
Terms such as command line, terminal window, and shell are used almost synonymously by some people. That's a wrong jargon. They are all very different. They are related, but not the same.
A terminal window is a window in a graphical desktop environment in which an emulation of a teletype terminal is performed.
The shell is the program that runs in the terminal window. Depending on what you have entered, you will try to interpret and execute the statements yourself, forward them to other operating system utilities, or find a script or program that matches your input. 19659003] RELATED: What is the difference between Bash, Zsh and other Linux shells?
At the command line type the following: This is the prompt that the shell displays when you wait for some statements to be entered. The term "command line" also refers to the actual content of your input. For example, if you're talking to another computer user about a difficulty you've been trying to get a program to run, you might be asked, "Which command line did you use?" You do not ask which shell you used. You want to know which command you have entered.
These together form the Command Line Interface (CLI).
Why use the command line in 2019?
The CLI may be unfamiliar to those who have entered it, it may be diminishing and confusing. Surely there is no place in such a modern operating system for such an outdated and geeky way to use a computer? Did not we give that up decades ago when windows, icons, and mice appeared and graphic desktop environments with graphical user interfaces (GUIs) became available?
Yes, the GUI has been around for decades. The first version of Microsoft Windows was released in 1985 and became PC desktop standard with the release of Windows 3.0 in 1990.
The X Window System used on Unix and Linux was introduced in 1984. This brought graphical desktop environments for Unix and its numerous derivatives, clones and off-shoots.
With the release of Unix, however, these events are being introduced by more than a decade. And because there was no other option, everything had to be possible via the command line. Every human interaction, configuration, and use of the computer had to be done through the modest keyboard.
So, ipso facto the CLI can do anything. A GUI still can not do everything the CLI can do. And even for the parts it can, the CLI is usually faster, more flexible, scriptable, and scalable.
And there is a standard.
Thanks to POSIX, they are standardized.
POSIX is a standard for Unix-like operating systems – basically anything that is not Windows. Even Windows has the Windows subsystem for Linux (WSL). Open a terminal window on a POSIX-compatible (or near-compatible) operating system, and you are in a shell. Although the shell or distribution provides its own enhancements and enhancements, you can use them immediately provided they provide core POSIX functionality. And your scripts are executed.
The command line is the lowest common denominator. Learn how to use it. Regardless of the Linux distribution and graphical desktop environment, you can perform all required tasks. Different desktops have their own way of working. Different Linux distributions contain different utilities and programs.
However, opening a terminal window will make you feel at home.
Commands have been developed for collaboration.
Each of the Linux commands was designed for a specific task and doing something well. The underlying design philosophy is to add more functionality by adding another utility that can be concatenated or concatenated with existing ones to achieve the desired result.
This is so useful that Microsoft has made every effort to add full support to Linux Command Line for Windows 10!
For example, the command
sort is used by other commands to sort text in alphabetical order. It is not necessary to include sorting functions in the other Linux commands. In general, GUI applications do not allow this type of collaboration.
Take a look at the following example. This uses the command
ls to list the files in the current directory. The results are passed to the command
sort and sorted into the fifth data column (the file size). The sorted list is then passed to the command
head which by default lists the first ten lines of its input.
ls -l | sort -nk5,5 | head
We get a clear listing of the smallest files in the current directory.
By modifying one With the command
tail instead of
head we can retrieve a list of the ten largest files in the current directory.
ls -l | sort -nk5,5 | Tail
This gives us, as expected, the list of the ten largest files.
The output of commands can be redirected and captured in files. The regular edition (
stdin ) and error messages (
stderr ) can be recorded separately.
RELATED: What are stdin, stdout and stderr on linux?
Commands can contain environment variables. The following command lists the contents of your home directory:
ls $ HOME
This works from any location where you are in the directory tree.
If you still bother the idea of all the typing, techniques like tab filling can reduce the overhead.
Enable Scripts Automation and Repeatability
People are prone to errors.
Scripts let you standardize a set of statements that you know will be executed in the same way every time you run the script. This brings consistency to system maintenance. The scripts can incorporate security checks that allow the script to determine if it should continue. As a result, the user does not have to have sufficient knowledge to make the decision himself.
Because you can automate tasks with
cron on Linux and other Unix-like systems, long, complicated, and repetitive tasks are required, can be simplified, or at least once found, and then automated for the future.
PowerShell scripts perform similarly on Windows, and you can schedule execution through the Task Scheduler. Why should you click 50 different options every time you set up a computer when you can run a command that automatically changes everything?
The Best of Both Worlds
To get the most out of Linux – or any operating system as the main user – you really need to use the CLI and GUI.
The GUI is unsurpassed for using applications. Even die-hard command-line advocates need to leave the terminal window, occasionally using Office productivity packages, development environments, and graphical manipulation programs.
Command line dependents do not hate the GUI. They only prefer the benefits of using the CLI – for the tasks involved. The CLI undoubtedly wins for the administration. With the CLI, you can make the same effort to make changes to a file, a directory, a selection of files and directories, or full global changes. To accomplish this with the GUI, tedious and repetitive keyboard and mouse actions are often required as the number of affected objects increases.
The command line provides the highest fidelity. Each option of each command is at your disposal. And many Linux commands have many options. To give just an example, consider the command
lsof . Take a look at the man page and think about how to integrate it into a GUI.
There are too many options to display to the user in an effective GUI. It would be overwhelming, unattractive and cumbersome to use. And that's just the opposite of what a graphical user interface should be.
They are horses for courses. Do not be afraid of the CLI horse. It is often the faster and more agile Ross. Earn your spurs and you will never regret it.