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. To run a shell, see Fedora: A First View.

For example, to see who’s logged in, you could execute this command in a shell:

$ who
barrett      :0    Sep 23 20:44
byrnes    pts/0    Sep 15 13:51
silver    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.[7] 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 the Fedora Linux default.

[7] Actually, how many interactive shells those users are running. If a user has several shells running, like the user silver in our example, they’ll have that many lines of output in who.

Get Linux Pocket Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.