Grasping the basics of Bash
Even experts forget the fundamentals. Learn more about – or get a refresher on – the basics of Bash.
One disadvantage of the modern emphasis on the desktop is that people learn about the command line only when they need it. As a result, their knowledge of is often haphazard and full of gaps. For example, for years I've been using the su - command several times a day to log in as root from a virtual terminal on the desktop of my everyday account. I always thought that when you were finished as root, you couldn't return to the everyday account in the same terminal; instead, you had to close the window and open another one. Then I learned, purely by accident, that all I really needed to do was type exit.
Since then, I've discovered that, if pressed, even experts would confess to a similar gap in their knowledge at one time or the other.
Back to the Basics
In this article, I'll discuss a topic I should have covered months ago: the basics of Bash, the command line used by most GNU/Linux distributions. I'll discuss the basic tools and sources for information, as well as the basics of navigation. Even if you know some of this information, a systematic discussion might fill in gaps in your knowledge. If not, you can always pass on the information to a desktop user to further their education.
The command line is one of the most basic interfaces ever invented. All you have to do is enter the correct string of characters to get the results you need. Right?
Well, not entirely.
This approach works if you approach the command line like a series of magical spells, each of which you must carefully copy before pressing the Enter key; however, if you add any of your own input, even the name to call a saved file, you frequently need to know more.
For one thing, you need to know that, unlike the Windows command line, Bash is case sensitive, treating uppercase letters differently from lowercase letters. For this reason, experienced users tend to avoid capitalizing anything; they don't want to bother dealing with the extra keystrokes.
More importantly, this also means that a file called taxsummary is not the same as one called Taxsummary; if you forget this basic fact, you can waste time trying to locate a file.
Additionally, certain characters are not allowed in the command line in order to avoid confusion. Prohibited characters include a space, which separates out parts of a command; the forward slash, which separates out directory names in a file path (not a backward slash, as in Windows); and characters such as a question mark or asterisk, which are used in regular expressions or wild cards.
These restrictions can cause some conflicts with the desktop, which has more relaxed rules, especially about the use of spaces in file names. However, you can get around these restrictions in several ways. The easiest way is simply to avoid using anything more exotic than a period in the file name and to use an underscore or hyphen instead of a space, the way that old Unix hands do. Almost as easily, you can use single or double quotation marks around file names with spaces or restricted characters in them as a signal that the names should not be read as they normally would.
Or, if you prefer, you can do what is called escaping and place a forward slash in front of a character. The forward slash is a signal that the next character – and only the next character – is not to be read normally. For instance, if you entered Grocery\ list, you would be telling Bash to read the space between the two words as part of a continuous file name. Without the forward slash, Bash would read your entry as two files, Grocery and list.
Read full article as PDF:
The Raspberry Pi Foundation has announced an even smaller version of the tiny computer that will fit into a DIMM slot.
A new class of problems lets a malicious app pre-configure an invisible privilege update.
New Hack language adds static typing and other conveniences.
New crypto policy system will offer easier configuration and more uniform security.
Ubuntu founder denounces insecurity in proprietary, close-source software blobs.
Vulnerability affects many Linux web servers
The Bavarian capital shuns Microsoft, Google, and other alternatives to implement an open source groupware solution.
Phone vendor partnerships bring Mark Shuttleworth's dream of Ubuntu on a phone a step closer to reality.
Donors will get to vote on new features for the free video editor.
Debian project puts init out to pasture and says no to Ubuntu's Upstart.