If you want to find out all the parameters for a particular command,
you can read the user manual with the man command (or you can
often use the --help option):
pi@raspberrypi ~ $ man curl
pi@raspberrypi ~ $ rm --help
To make a new directory, use mkdir. To bundle all of the files in a
directory into a single file, use the tar command, originally created
for tape archives.
You’ll find a lot of bundles of files or source code are distributed as
tar files, and they’re usually also compressed using the gzip com-
mand. Try this:
pi@raspberrypi ~ $ mkdir myDir
pi@raspberrypi ~ $ cdmy Dir
pi@raspberrypi ~ $ touch foo bar baz
pi@raspberrypi ~ $ cd ..
pi@raspberrypi ~ $ tar -cf myDir.tar myDir
pi@raspberrypi ~ $ gzip myDir.tar
You’ll now have a .tar.gz archive of that directory that can be distrib-
uted via email or the internet.
More Linux Commands
One of the reasons that Linux (and Unix) is so successful is that the
main design goal was to build a very complicated system out of small,
simple modular parts that can be chained together. You’ll need to
know a little bit about two pieces of this puzzle:
pipes
and
redirection
.
Pipes are simply a way of chaining two programs together so the out-
put of one can serve as the input to another. All Linux programs can
read data from
standard input
(often referred to as
stdin
), write data
to
standard output
(
stdout
), and throw error messages to
standard
error
(
stderr
). A pipe lets you hook up stdout from one program to
stdin of another (Figure 2-4). Use the | operator, as in this example:
pi@raspberrypi ~ $ ls -la | less
In the above example, the output of the ls command is sent to
the input of the less program, which prints data one screenful at
a time. (Press q to exit the
less program.)
Getting Around Linux on the Raspberry Pi 39
GSW_RASPI_4ED_FIN.indd 39GSW_RASPI_4ED_FIN.indd 39 10/28/21 10:54 AM10/28/21 10:54 AM