Unix command line
Exhaustive command line interface is a legacy part of Unix. Get yourself familiar with the philosophy of Unix.
The operating systems you should be running are GNU/Linux, which inherit from Unix and add a great deal of other features. Even if you are running Mac OS X, you are on a Unix-type OS, but you are tied into it more firmly. But you shouldn’t ever be using Windows, because Windows are evil and dumb.
See why Linux is better.
So… Unix. Every Unix has a command line, a terminal console window (or no window)
with a prompt, e.g. user@machine:/current/dir $
, after which you type in commands.
The $
usually denotes a regular-user terminal session, and if the prompt
ends with #
, the user is root
(e.g. highest-permission super-admin).
The point of this command line is thus: You run a program with some space-separated arguments.
You can pass the program some input stream of bytes (called standard input), and
the program can output (e.g. print) some stream of bytes (called standard output).
You can chain several commands with a pipe (|
symbol), which means the standard output
of the previous program is passed as standard input into the next.
Example
$ grep -i 'error' /var/log/some-program.log | wc -l
237
In the above example, grep
is the name of the first program, which is passed
three arguments (-i
for case-insensitive matches of the string error
on any lines
of /var/log/some-program.log
file (some-program’s journal, diary). Normally, grep would output
all the lines that match, but in our case, the output of grep is passed as input to
the second program wc
with the argument -l
, which makes it count the number of lines (instead of words by default).
237 lines containing the word error
, in this case.
You can always get the help on some program by typing man
before, or --help
after, its name.
That is, man grep
and wc --help
, for example.
The first will open grep
’s user’s manual, the latter wc
’s short help and usage.
Task
Follow through with the tutorial on one of these sites:
- first six UNIX tutorials for beginners,
- Learning the shell,
Below is a great tool for dissecting and learning about Shell commands (besides using -h or man).
After you’re done, skim through these pages very briefly:
- Learn Unix in 10 minutes — a refresher of the above,
- List of Unix Utilities — just a short reference of what is at your disposal at nearly any Unix machine,
- Filesystem Hierarchy Standard — the standard directory structure of Linux,
- Unix Toolbox.
If you are feeling masochistic yet, dive into these (optional but benefiting) tutorials as well:
- exhaustive Unix Tutorial for Beginners,
- Learn Linux the Hard Way — lots of practical exercises,
- Introduction to the OS X Unix Command Line — if you’re a Mac fag.
Remember
If you know the name of the program you need in order to solve your problem
(let’s call it program
) but you don’t know exactly how to use it, then
type man program
for the program’s manual or program --help
for its short help.
Remember
If you don’t know what program you need to accomplish something, type
apropos -s1 <keyword>
for a proposal of suitable installed programs
(from Section 1, Commands, and with <keyword>
in its short description).
Try it now.
man apropos # exit the manual by pressing Q
apropos -s1 game