Skip to Content
The Linux Command Line
book

The Linux Command Line

by William E. Shotts Jr.
January 2012
Beginner content levelBeginner
480 pages
17h 46m
English
No Starch Press
Content preview from The Linux Command Line

Chapter 13. Customizing the Prompt

In this chapter we will look at a seemingly trivial detail: our shell prompt. This examination will reveal some of the inner workings of the shell and the terminal emulator program itself.

Like so many things in Linux, the shell prompt is highly configurable, and while we have pretty much taken it for granted, the prompt is a really useful device once we learn how to control it.

Anatomy of a Prompt

Our default prompt looks something like this:

[me@linuxbox ˜]$

Notice that it contains our username, our hostname, and our current working directory, but how did it get that way? Very simply, it turns out. The prompt is defined by an environment variable named PS1 (short for prompt string 1). We can view the contents of ...

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

The Linux Command Line, 2nd Edition

The Linux Command Line, 2nd Edition

William E. Shotts
Linux Fundamentals

Linux Fundamentals

Sander van Vugt

Publisher Resources

ISBN: 9781593273897Errata Page