Linux Essentials 2.0: Command Line Basics and Practicing Efficiency

Master Linux command line basics with Linux Essentials 2.0. Learn shell commands, file management, and navigation to work more efficiently.

The point of learning Linux is not to boast about how cool you are or to join an arcane community of illuminati, but to get more work done. That is why Linux Professional Institute offers its series of certifications for Linux, and efficiency is the goal particularly behind Objective 012, Command Line Basics, which I’ll introduce in this article.

Yes (you might be thinking), the command line is what everybody had to use in order to interact with a computer from about the 1960s through the introduction of a graphical interface to an Apple computer in 1979. We can easily get devices with graphical interfaces today, so why go back to the command line?

Keyboard Skills

Now really, you don’t want to return to the days when (usually male) executives jotted down notes to hand to their (usually female) secretaries to type up, do you? The introduction of PCs in the 1980s led staff to type their own communications, and soon the formality of written letters was replaced by email and then text messaging. Women got better forms of job security.

In medicine, computing came much later, with many institutions waiting until the 2010s to install medical records. When they did so, the women on staff adapted much quicker than their male colleagues—so a female doctor tells me—because women were taught to type in high school while men learned workshop skills. I’m sure that workshop skills are also a valuable preparation for medicine, but typing is what you need to deal with modern computer systems.

The efficiency of typing powers the command line too. The Unix shell is the queen of command lines, designed to allow maximum productivity with minimal typing. And you’re likely to learn an even more powerful version of that shell, called Bash, which comes from the GNU project (one reason that Linux distributions are called GNU/Linux by some people). The commands covered by Linux Essentials, however, work in any shell used with Linux.

So what are the relative advantages of a graphical interface and a shell? Essentially, a graphical interface makes it easy to do one thing at a time—especially if it is something the designers built into the menus. But modern life requires complex tasks that call for a mix of many unrelated tools. You might think, nowadays, that you can ask an AI agent to put all those tasks together for you, but that requires a time investment too. The Linux shell is designed to combine many tasks quickly without fuss.

Overview of the Command-Line Skills in Linux Essentials

Now that I’ve tried to justify why you’ll benefit by learning the command line, let me introduce each of the major topics. The lists of commands appear in LPI’s objectives for this topic, and extensive documentation can be found in LPI’s Learning Materials.

Command Line Usage

First, this topic lays out the basic landscape. What are some of the different shells on Linux? What do you see when you open one, and what do the parts of the command mean? Why do commands take a variety of input as « options » and « arguments »? What is a variable, and (here we’re getting fancy) what is a variable’s scope?

So in this objective, you’re learning syntax. That sounds boring, but just think of when you have learned a foreign language. Syntax seemed arbitrary and confusing at first, but knowing the syntax is crucial to expressing yourself.

Documentation, Man Pages and Usage Information

As soon as you can move around using the information under Command Line Usage, you’re ready to learn how to get help using the system. Like nearly every type of software, the help on a Linux system is aimed at people with a bit of experience—someone who has gone through tutorials and played around with the software. At first glance, the online help might not seem useful to you. I don’t expect the readers of this article, for instance, to jump for joy when seeing the following help message from the mv command:

usage: mv [-f | -i | -n] [-hv] source target
       mv [-f | -i | -n] [-v] source ... directory

The message is there just to jog the memory of someone who has studied this command (and others that are similar).

Longer documentation is available in the form of man pages and info pages. (The word « man » is short for « manual » and is available to all genders!) These can be daunting at first too, particularly some of the sections near the end of each page. But each piece of information is there for a reason, and could be useful to you someday.

In addition to documentation, this topic helps you find files on the system. So we’ll look at how files are organized next.

Files, Directories and Paths

I’ve seen some computer users who just drag every file they use to their Desktop. Text files, pictures, spreadsheets, PDFs, and other wild creatures make up a chaotic rainforest that becomes increasingly hard to navigate.

Computer systems are organized in a hierarchy (tree-like structure) that contains many folders or directories. This topic helps you understand important directories and view the tree structure for yourself. Because the shell offers many sophisticated ways to move about in the hierarchy, the place held by each file is called a path.

For instance, I wrote a program using the shell to create an index of my articles; the place where I chose to store the program is a file I called script/keyword_index_generator/create_index.sh in my personal (home) directory. The slashes are separators, just as on the Web: First I created a directory called script, then created a subdirectory beneath it called keyword_index_generator, and finally created the program create_index.sh in the subdirectory.

This topic also tells you how to find out important information about a file, such as its size and when you last changed it.

File and Directory Management

In the last topic of the Command Line Basics objective, you learn some powerful tools for manipulating files on the command line: creating, deleting, copying, renaming, etc.

This topic, and the Command Line Basics objective, ends with one of the cleverest—and to my mind, most exciting—tools on the command line: ways to specify multiple files at once. If you need to delete several files related to a project, from a directory that contains other files as well, you might not need to issue a delete command for each file. Depending on the filenames, a single command might do the job.

And this power shows why mastering syntax is important. There’s a particular syntax called globbing that permits you to group files. It is used so often that you might encounter the syntax in the everyday talk of shell users. For instance, some people refer to different varieties of BSD systems (FreeBSD, NetBSD, etc.) as « *BSD »—the asterisk being borrowed from the syntax of shell globbing.

Giving Yourself a Language for Power Use

To summarize, Objective 012 of the Linux Essentials objectives, Command Line Basics, introduces the shell, along with the files and directories that you work with from the shell. The concepts, commands, and syntax you learn for this objective put you into a new, higher class of computer user: one who can carry out complex tasks quickly and repeatedly.

<< Read the previous part of this series | Start the series from the beginning >>

Author

  • Andrew Oram

    Andy is a writer and editor in the computer field. His editorial projects at O'Reilly Media ranged from a legal guide covering intellectual property to a graphic novel about teenage hackers. Andy also writes often on health IT, on policy issues related to the Internet, and on trends affecting technical innovation and its effects on society. Print publications where his work has appeared include The Economist, Communications of the ACM, Copyright World, the Journal of Information Technology & Politics, Vanguardia Dossier, and Internet Law and Business. Conferences where he has presented talks include O'Reilly's Open Source Convention, FISL (Brazil), FOSDEM (Brussels), DebConf, and LibrePlanet. Andy participates in the Association for Computing Machinery's policy organization, USTPC.

Laisser un commentaire

Votre adresse e-mail ne sera pas publiée. Les champs obligatoires sont indiqués avec *