Skip to Main Content
Linux Pocket Guide
book

Linux Pocket Guide

by Daniel J. Barrett
February 2004
Beginner content levelBeginner
200 pages
5h 40m
English
O'Reilly Media, Inc.
Content preview from Linux Pocket Guide

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.

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.
Start your free trial

You might also like

Linux Pocket Guide, 2nd Edition

Linux Pocket Guide, 2nd Edition

Daniel J. Barrett
Linux in a Nutshell, 6th Edition

Linux in a Nutshell, 6th Edition

Ellen Siever, Stephen Figgins, Robert Love, Arnold Robbins

Publisher Resources

ISBN: 9780596806347Errata Page