O'Reilly logo

Linux All-in-One For Dummies, 5th Edition by Emmett Dulaney

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 1

Introductory Shell Scripting

In This Chapter

arrow Trying some simple shell scripts

arrow Discovering the basics of shell scripting

arrow Exploring bash’s built-in commands

Linux gives you many small and specialized commands, along with the plumbing necessary to connect these commands. Take plumbing to mean the way in which one command’s output can be used as a second command’s input. bash (short for Bourne-Again Shell) — the default shell in most Linux systems — provides this plumbing in the form of I/O redirection and pipes. bash also includes features such as the if statement that you can use to run commands only when a specific condition is true, and the for statement that repeats commands a specified number of times. You can use these features of bash when writing programs called shell scripts — task-oriented collections of shell commands stored in a file.

This chapter shows you how to write simple shell scripts, which are used to automate various tasks. For example, when your Linux system boots, many shell scripts stored in various subdirectories in the /etc directory (for example, /etc/init.d) perform many initialization tasks.

Trying Out Simple Shell Scripts

If you’re not a programmer, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required