From the course: Learning Linux Command Line

The Unix philosophy

- [Instructor] As we start exploring command line tools, it's important to understand the principle behind many of the programs we'll be looking at. That principle often called the UNIX Philosophy, says that a tool or program should do one thing and do it well. In this case, doing something well means being a well-behaved citizen of the ecosystem of tools that operate using text interfaces, which means that the tool should expect to take in standard text from a file or stream and output text in a reasonable format once it's done processing or doing whatever action that particular tool does. This philosophy suggests that we shouldn't have tools that try to do too much. We don't want one single tool or program that reads files and separates the text into another file, and renames the file and compresses it into an archive when it's done or one that tries to do everything anyone could possibly want to do. We want one tool to do each of those tasks so we can use those specialized tools in any way we want to. Of course, there are applications that include many features, including the ones I've mentioned before and that's fine. We often find those in graphical environments. So those applications, aren't the ones we're talking about here. What we are talking about, is the standard set of command line tools that can be configured to work together in an incredible number of ways. We want to think of these tools, not as multifunction Swiss Army Knives, but as a well-stocked kitchen of chef's tools. Sure, we can open a can with a little Swiss Army Knife attachment, or try to chop a tomato with a tiny blade but none of those multi-function tools does anything particularly well. Certainly not well enough to prepare a meal we're proud of. To get real work done, we want quality dedicated tools that can work together easily and can be used in different combinations to do whatever we need. Think of an assembly line where one machine does one task and then passes the product on to the next specialized machine, rather than one single robot doing many different tasks on the same item. Having separate dedicated tools allows us to pick appropriate tools from our toolbox to do exactly what we need to do. We want to be able to incorporate the right tools into doing a task as flexibly as possible. As we'll see in a little bit, this philosophy underlies a lot of how we'll work at the command line. For example, we might use one program to read text from a file, then send that text to a program that filters certain text. Then the output of that program gets processed so that it doesn't have duplicate lines and then the result will get written back to a file. Modularity and flexibility are features not limitations of working at the command line.

Contents