The Linux Philosophy



Linux has a philosophy that underlies the entire operating system and which strongly affects the way in which administrators — and advanced users — interact with it. This philosophy is very similar to that of its Unix parenthood. It is called “The Linux Way.”

The basic tenets of the Linux way are listed below along with a short explanation. In various places in the text of the DataBook I will refer to one or more of these.

The GNU utilities is an Open Source collection of the basic administrative programs required by any Unix or Linux operating system. These include programs to copy, move and delete files, manage disks, write text documents and programs and many other day to day operational activities that must be performed by a user or administrator.

The Main Tenets

The following are the ten main tenets of the Linux Philosophy.

Small is Beautiful

Each program should do one thing well.  This makes for efficient usage of system resources and it makes the programs easy to understand. Link many small programs together in ways that perform tasks unforeseen by the original programmers if each of the small programs.

Large monolithic programs get feature bloat and lack flexibility

Write programs that do one thing and do it well

The programs that make up the GNU utilities, as well as many other Linux utility programs are almost invariably written to perform a single task; and each performs its assigned task very well. Large programs that perform many tasks cannot be written to cover every possibility that a user or administrator might want or need to perform. Using the capabilities of many small, functionally targeted programs and stringing them together with pipes and redirection allows for an amazing array of possibilities, far more creative and diverse than the original programmers could conceive.

Prototype as Soon as Possible

Change is inevitable, so when creating new code use high level languages, i.e., scripting languages like BASH and Perl. Get regular feedback from the customer to verify correct functioning of the program.

It may never need to use compiled language to write code when following these guidelines. Thus your code is Open and Discoverable to others.

“Open” means that the code can be read by a human being. “Discoverable” means that the logic and the functioning of the code is easily apparent.

Choose Portability Over Efficiency

Efficiency requires OS and hardware explicit hacks and is rarely portable because of that. If the code  runs fast enough it meets your needs. In any event Next Month’s hardware will run faster.

Portable code runs anywhere so why spend time porting compiled code to other platforms?

Store Data in Flat Text Files

Text is the Universal Interface. It is Portable and it is Open and Discoverable. Special tools are not required to manage Linux configuration files, your favorite text editor will do fine.

All binary formats are by their very nature obscure and proprietary, for example the Windows registry.

Use Software Leverage

Good programmers write good code. Great programmers borrow good code. Open Source makes it easy to borrow good code.

Take advantage of others’ code and share your own code. Most companies not good at this either internally or externally.


Use Shell Scripts to Increase Leverage and Portability

One shell command can equal thousands or tens of thousands of C instructions. There are a huge number of very powerful shell commands available. There is no need to write and compile low level language programs; it takes far too much time to do so.

Shell scripts are far more portable than C.

Resist the urge to rewrite shell scripts in C or any other compiled language

Avoid Captive User Interfaces

GUI or TUI programs can both be captive interfaces, allowing actions that only the designers decided were acceptable. Captive interfaces also assume user is human which means they cannot be combined with programs using STDIO.

Captive interfaces are generally big and ugly and do not scale well. They provide limited choices and do not leverage software.

Make Every Program a Filter

All programs are filters. Yup, even GUI programs. Programs don’t create data – people do. Computer programs convert data from one form to another. Properly written programs filter data without imprisoning it.


The Lesser Tenets

These lesser tenets explain and extend the ten main tenets.

Write programs to work together

Programs should work together. The output of one program should be usable as the input to the next program. This again means that stringing together a series of small programs that each perform a single task well results in a far more flexible working environment than a single, huge, monolithic program that does nothing well. I have seen way too many of those.

Write programs to handle text streams

Text is the universal format for data. Proprietary binary formats are not usable outside the large, proprietary programs that create them. Text can be used by any well-written Linux command line program. In addition, users and administrators can read text and verify that the output is what is to be expected.

The idea of programs working together is totally bound up in the interchangeability of the data involved. Text data can be easily used by almost every Linux utility because they were intentionally written that way.

Universal interface

Always use the universal interface, STDIO. There are three STDIO data streams; STDOUT is output to the display; STDIN is input from the keyboard; STDERR is error messages which are also sent to the display, but which use a different file handle. The powerful functions of piping and redirection work on these STDIO data streams.

Don’t be chatty

Silence is golden. If there is nothing to say a program should say nothing. Many Linux utility programs simply do their work and return to the command line with no messages of any kind. Only if there is an error should most programs have anything to say. There are exceptions, but be sure that it is truly necessary.

Use Regular Expressions (RegEx)

Regular expressions are a very powerful tool that allows for flexible manipulation of text data streams. They make it possible to perform operations on text that are impossible in any other way.

Let someone else do the hard part

Don’t write a new program unless you have to. There are already many programs out there to do 95% of what you need done. If necessary only write a program when you need to handle the other 5%.

Important Concepts

There is one particular concept that makes Linux and Unix especially flexible and powerful.

Everything is a file

Linux handles everything as a file. This has some interesting and amazing implications. This makes it possible to copy an entire hard drive, boot record included, because the entire hard drive is a file, just as are the individual partitions. Printers are files and so are serial ports and USB mass storage devices.

If you remember this as you work with Linux, you will see many ways in which this concept is already used. You will also discern may ways in which you can use it.

The Tao of Linux

Keep It Simple Stupid

There are books and articles that document the Linux Way as well as the Unix Way. See the Bibliography for a list.



Sub Pages: