Chapter 3

Basic bash Shell Commands

In This Chapter

  • Starting the shell
  • The shell prompt
  • The bash manual
  • Filesystem navigation
  • File and directory listing
  • File handling
  • Directory handling
  • Viewing file contents

The default shell used in all Linux distributions is the GNU bash shell. This chapter describes the basic features available in the bash shell, and walks you through how to work with Linux files and directories using the basic commands provided by the bash shell. If you're already comfortable working with files and directories in the Linux environment, feel free to skip this chapter and continue with Chapter 4 to see more advanced commands.

Starting the Shell

The GNU bash shell is a program that provides interactive access to the Linux system. It runs as a regular program, normally started whenever a user logs in to a terminal. The shell that the system starts depends on your user ID configuration.

The /etc/passwd file contains a list of all the system user accounts, along with some basic configuration information about each user. Here's a sample entry from a /etc/passwd file:

 rich:x:501:501:Rich Blum:/home/rich:/bin/bash

Each entry has seven data fields, with each field separated by a colon. The system uses the data in these fields to assign specific features for the user. These fields are:

  • The username
  • The user's password (or a placeholder if the password is stored in another file)
  • The user's system user ID number
  • The user's system group ID number
  • The user's full name ...

Get Linux® Command Line and Shell Scripting Bible, Second Edition 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.