The Shell
In order to run commands on a Linux system, you’ll need somewhere to type them. That “somewhere” is called the shell, which is Linux’s command-line user interface: you type a command and press Enter, and the shell runs whatever program (or programs) you’ve requested. (See Running a Shell to learn how to open a shell window.)
For example, to see who’s logged in, you could execute this command in a shell:
$ who silver :0 Sep 23 20:44 byrnes pts/0 Sep 15 13:51 barrett pts/1 Sep 22 21:15 silver pts/2 Sep 22 21:18
(The dollar sign is the shell prompt, which means the shell is
ready to run a command.) A single command can also invoke several
programs at the same time, and even connect programs together so they
interact. Here’s a command that redirects the output of the who program to become the input of the
wc program, which counts lines of
text in a file; the result is the number of lines in the output of
who:
$ who | wc -l 4
telling you how many users are logged in.[5] The vertical bar, called a pipe,
makes the connection between who and
wc.
A shell is actually a program itself, and Linux has several. We focus on bash (the Bourne-Again Shell), located in /bin/bash, which is usually the default in Linux distros.
[5] Actually, how many interactive shells those users are running.
If a user has two shells running, like the user silver in our
example, he’ll have two lines of output from who.
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access