The Linux Command Line
Notes
Introduction
- What a way to start off a book, I pumped.
I want to tell you a story. No, not the story of how, in 1991, Linus Torvalds wrote the first version of the Linux kernal. You can read that story in lots of Linux books. Nor am I going to tell you the story of how, some years earlier, Richard Stallman began the GNU Project to create a free Unix-like operating system. That’s an important story too, but most other Linux books have that one as well. No, I want to tell you the story of how you take back control of your computer.
- Another one:
Many people speak of “freedom” with regard to Linux, but I don’t think most people know what this freedom really means. Freedom is the power to decide what your computer does, and the only way to have this freedom is to know what your computer is doing. Freedom is a computer that is without secrets, one where everything can be known if you care enough to find out.
- Shell: A program that takes keyboard commands and passes them to the operating system to carry out e.g.
bash
- Terminal Emulators: Program to interact with the shell
- Shell Prompt: A symbol or set of characters at the beginning of the command line that indicates the shell is ready to accept commands, e.g.,
$
for a standard user or#
for the root user. - Symbolic Link: Special kind of file that points to another file or directory. It acts as a shortcut, allowing you to access the target file or directory from a different location in the filesystem. Symbolic links can span across different filesystems and can link to directories as well as files.
Wildcards (Globbing)
Wildcard | Meaning |
---|---|
* |
Matches any number of characters |
? |
Matches any single character |
[characters] |
Matches any one character in the set |
[!characters] |
Matches any one character not in the set |
[[:class:]] |
Matches any character in the specified class |
Character Classes
Class | Meaning |
---|---|
[:alnum:] |
Alphanumeric characters |
[:alpha:] |
Alphabetic characters |
[:digit:] |
Digits (0-9) |
[:lower:] |
Lowercase letters |
[:upper:] |
Uppercase letters |
[:space:] |
Whitespace characters |
- I have always wondered what the difference between
rm -r dir
vsrm -rf dir
and it’s the same except thef
means ifdir
doesn’t exists,rm
will continue silently.f
or--force
ignores nonexistence files/dirs and does not prompt.
Redirection
>
will always overwrite a file and if you can use$ > file_name.txt
as a quick way to trunc a file>>
to append to a file
Processes
- daemon program: programs that sit in the background and do their thing without having any user interface
Review
This book covers a lot about the linux command line. Overall, I thought it was very good but I wouldn’t go into the book expecting to have all the command line memorized. Use it as an opportunity to expose yourself to what’s possible and then come back to it as a reference book. Let your curiosity drive you when exposed to new commands that you find useful to dive deeper in.