This document discusses the major tenets of the Linux philosophy. It explains that everything is treated as a file, there are small single-purpose programs, and programs can be chained together to perform complex tasks. Configuration data is stored in text files for easy editing and portability. Programs act as filters that take input, modify it, and output the results. The philosophy values portability over efficiency and uses software leverage through small reusable programs.
2. Everything is a file. ( Including hardware )
Small, single-purpose programs.
Ability to chain programs together to
perform complex tasks.
Avoid captive user interfaces.
Configuration data stored in text
3. Everything is a File : –
UNIX systems have many powerful utilities
designed to create and manipulate files. The
UNIX security model is based around the
security of files. By treating everything as a
file, a consistency emerges. You can secure
access to hardware in the same way as you
secure access to a document.
4. Small, single-purpose programs : –
UNIX provides many small utilities that
perform one task very well. When new
functionality is required, the general
philosophy is to create a separate program –
rather than to extend an existing utility with
new features.
5. Ability to chain programs together to
perform complex tasks :-
A core design feature of UNIX is that the
output of one program can be the input for
another. This gives the user the flexibility to
combine many small programs together to
perform a larger, more complex task.
6. Avoid captive user interfaces :-
Interactive commands are rare in UNIX. Most
commands expect their options and
arguments to be typed on the command line
when the command is launched. The
command completes normally, possibly
producing output, or generates an error
message and quits. Interactivity is reserved
for programs where it makes sense, for
example, text editors (of course, there are
non-interactive text editors too.)
7. Configuration data stored in text : –
Text is a universal interface, and many UNIX
utilities exist to manipulate text. Storing
configuration in text allows an administrator
to move a configuration from one machine to
another easily. There are several revision
control applications that enable an
administrator to track which change was
made on a particular day, and provide the
ability to roll back a system configuration to
a particular date and time.
8. There are nine major tenets to the Linux philosophy.
Small is Beautiful
Each Program Does One Thing Well
Prototype as Soon as Possible
Choose Portability Over Efficiency
Store Data in Flat Text Files
Use Software Leverage
Use Shell Scripts to Increase Leverage and Portability
Avoid Captive User Interfaces
Make Every Program a Filter
9. Make every program a filter
Each of the commands that make up this command line
program is a filter. That is each command will take an
input, usually from Standard Input, and “filters” the data
stream by making some change to it, then sends the
resulting data stream to Standard Output. Standard Input
and Standard Output are known collectively as STDIO.
The who command generates an initial stream of data.
Each following command changes that data stream in some
manner, taking the Standard Input and sending the
modified data to Standard Output for the next command to
manipulate.
10. Small is beautiful and Each program does one thing well
These two tenets go hand in hand. Each of the commands in this
program is fairly small, and each performs a specific task. The
sort command, for example does only one thing. It sorts the data
stream sent to it via Standard Input and sends the results to
Standard Output. It can perform numeric, alphabetic and
alphanumeric sorts in forward and reverse order. But it does
nothing else. It only sorts but it is very, very good at that.
Because it is very small, having only 2614 lines of code as shown
in the table below, it is also very fast.
11. Choose portability over efficiency and
Use shell scripts to increase leverage and
portability
The portability of shell scripts can be far
more efficient in the long run than the
perceived efficiency of writing a program in
a compiled language—not even considering
the time required to compile and test such a
program—because they can run on many
otherwise incompatible systems.
12. For example, I worked on the email system at the State of North
Carolina for several years. I was responsible for a collection of
Perl and BASH CGI programs that ran on a Red Hat Linux host.
These programs provided remote users in all of our 100 counties
and hundreds of large and small agencies to perform account
maintenance for their users. I was asked to test the possibility of
moving all of these programs to Red Hat running on an IBM Z-
series mainframe.
13. Use software leverage
Software leverage means a couple things to me. First, and
in the context of this example, it means that by using four
command line commands, we are leveraging the work of
the programmers who created those commands with over
7,000 lines of C code. That is code that we do not have to
create. We are leveraging the efforts of those other,
under-appreciated programmers to accomplish the task we
have set for ourselves.
14. Impact
This article is not meant to be a programming tutorial. Rather, it
is intended to illustrate how the Linux Philosophy impacts and
informs the daily work of system administrators and developers.
We are the beneficiaries of decades of code that was well-
designed, well-thought out, and well-written by people who had
a lot of skin in the game and actually knew what they were
doing. The best code on the planet was written using these
tenets.
15. Eric Raymond: The Art of Unix
Programminghttp://www.catb.org/~esr/writings
/taoup/html/index.html
Mike Gancarz: Linux and the Unix Philosophy;
Digital Press, 2003, ISBN 1-55558-273-7
Wikipedia: http://en.wikipedia.org/wiki/Unix_p
hilosophy
Oregon State
University:http://web.engr.oregonstate.edu/~tr
aylor/ece474/lecture_verilog/beamer/linux_phil
osophy.pdf