I sometimes wonder at this simple questions: At what point did the command line get a not-so-friendly reputation? This is especially true when we know that in the beginning, there was the command line.
As a matter of fact, some people erroneously believe that switching to Linux will prove to be difficult because Linux runs on the command line. Really! Especially thinking of this twenty-two years into the twenty-first century, hmm.
Anyway, In this post I need to just outline some of the benefits of working on the command line instead of the GUI, if your primary means of interacting with a computer is with a screen-reader or a Braille display.
But what is the command line anyway?
To answer this question, we have to realise that there are two (or is it three?) main ways of interacting with your computer:
- The Graphical User Interface
- This is when one uses menus and graphical controls to issue commands. This is perhaps the most popular approach today. You use mouse and keyboard to click on icons to activate applications.
- The Command Line Interface
- This is when a user has to type in the name of a command he or she wishes to execute in a terminal. This is also related to the third method:
- The Text User Interface
- The TUI interface often works on the console but uses curses to display a selection of choices.
Regardless of which way one uses, the end result is that a user executes a command. For large programs, these commands are invocations to its builtin functions.
Invoking a function
Regardless of which programming language one uses, there are certain blocks of code that carry out specific tasks. These blocks are named so that it becomes easier to refer to them.
So any time we want to have a certain task executed, instead of repeatedly writing the code, we simply write the name of the block. This is function invocation.
Function invocation involves either naming a function on its own for the code to be run as it is, or naming the function along with its parameters. These parameters are known as arguments of the function.
The arguments to a function affect the behaviour of the function’s execution: if the function has to be sensitive to its environment, we pass in arguments that are appropriate.
We can think of simple mathematical operations we did in grade school as functions:
- The plus function for addition can only work because of two or more arguments for it to return the correct result;
- The same applies for the parentheses: they affect how numbers are grouped for downstream processing by other operations.
This is important to understand because functions and commands are the same.
Working with commands is like calling functions
You may have been wondering as to why we were talking of functions and how code works. It is because whether you like it or not, the moment you work with your computer, you are programming to some extent.
You want your computer to do something else: you have to know which command to issue. And the way to issue such a command depends on how competent you are with your own machine.
The beauty of the command line is that even if you do not like it, you will end up thinking like a programmer.
The command line interface on Linux is evident even when you launch it in the graphical desktop like Gnome or KDE desktop environments. You can launch the terminal by pressing
CTRL-ALT-T, for instance.
You can also work full-time on the command line by simply logging in using a text mode in any of the virtual console windows. From your desktop environment, just press
Ctrl-Alt-F#, where the hash sign could represent
To run commands, the syntax is simple: just type in the name of the command and you are done.
For example, typing
cd will change your current working directory to your home directory. Similarly, a command such as
pwd will show you your current directory.
Just like functions developed by programmers, some commands take in arguments. For example if a command such as
cd has to change the working directory to something else, then you need to pass in the destination directory as its argument.
Other commands can take more than one argument at a time. You separate these arguments with a space.
To change the behaviour of a command execution, you use options. An option is denoted by two dashes
(--) before its name. Some can be shortened and use one dash when they are shortened.
Anyway, as this post is not to teach you to use a command line, it is there to simply demonstrate the underlying attraction to this arrangement.
The benefits of running commands
The benefits for running commands has to do with just knowing which command you wish to run. Period. As long as you have a functional terminal or console, it is a matter of just entering the name of the command.
as compared to the graphical user interface, there are no accessibility woes to sing of. If you are using a good screen-reader1, you will be able to interact with your computer successfully.
Setbacks of the command line
The only real drawback that I see to working on the command line has to do with dozen, if not hundreds or thousands of commands you have to know. But on a closer look, it’s not as bad as that.
For most daily uses, people just work with a few commands at a time. For those commands they may not know, shell is their friend. Whether using a bash or zsh, there is a tool called completion you have to take advantage of. You just type in a few characters of the command you want, and the shell will complete it for you.
In any case, you still need to know how to use the command correctly. Typing
man followed by the name of the command will provide you with a user manual.
The command line is a tool worthy of exploration and exploitation for your productivity. Its beauty lies in how it mirrors the inner workings of function calls. This ability is what makes thinking of using command line utilities in a pipe to do great things.
This blog will hopefully help you answer some of the questions as how to use some of these tools for your benefit.
Of which almost all screen-readers that read textual