UNIX

From XPUB & Lens-Based wiki
Revision as of 08:43, 16 September 2019 by Andre Castro (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Brian W. Kernighan & Rob Pike, The Unix Programming Environment, Prentice-Hall, 1984


Beginnings of Unix

After being withdrawn from project Multics Ken Thompson and Dennis Richie started writing UNIX in 1969 at AT&T Bell Labs.

Thompson&Richie.jpg

Ken Thompson and Dennis Richie found themselves at the Bell Labs without much hardware or funding.

Having to resort to discarded hardware and influenced by their experience of Multics, they start developing UNIX, a super slim operating system, that could run in hardware available and yet include some of appealing features of Multics.

Features of UNIX

Some of the features of UNIX were influenced from Multics,

  • it was time-sharing system, allowing for mutiples users to login to the machine ssh username@machineIP
  • included the shell: a program which performs command line interpretation ** whoaim
    • pwd print working directory - where am I?
    • date
    • users print the user names of users currently logged in to the current host
    • history commands' history
  • tree-structured file system
    • tree ~/ list contents of home (~ == /home/username ) in a tree-like format
    • ls ~ list files and directories in your user home ( ~ == /home/username )
    • ls . list files and directories in current directory ( . == current dir )
    • ls ../ list files and directories in parent directory ( . == current dir )
    • ls foo/ list files and directories in child foo/ directory
    • ls / list files and directories in root ( / == root )
  • every thing is a file
    • ls -R / > /dev/dsp file-system as sound

Others emerged from the development and use of the system and crystallized into the Unix Philosophy:

  • Write programs that do one thing and one thing well
    • ls lists files in a directory
    • cat outputs content of file
    • wc counts number of words in file
  • Write programs that work together
    • echo "hello UNIX world" | sed 's/o/0/g' | sed 's/e/3/g' | sed 's/l/1/g' | figlet
  • Write programs that handle text streams, because that is a universal interface
    • man -a intro | espeak Linux introduction to user commands.


command arguments

Arguments are like option and or switch of a command-line program.

Some times they have values to them other times they don't.

Some times indicate with one "-" sometimes with two "--"

In man -a intro -a is an argument.

In cowsay --e '@@' -T 'jj' 'What are the arguments doing?'

Figure out what each argument does in these two commands?

Distribution of UNIX

Although UNIX was property of Bell Labs and AT&T it was not commercialized.

As AT&T was a state owned monopoly that controlled the US phone service it was legally forbidden to get into the software market.

Instead of making into a market, UNIX remained more of non-commercial. For a low price UNIX could be installed and changed to create derivatives. Yet UNIX's and its derivatives could only be distributed by AT&T. (How was Minix distributed???)

Source code

Rather than distributing UNIX and its tools only as binary files, its source code was an integral part of distribution.

Given the lack of documentation in its early years, the availability of source code made possible for users to study and understand undocumented parts of the system.

In Linux distributions download the source code is also possible, by instructing the package manager apt-get to --download-only the source code for cowsay program or any other program sudo apt-get --download-only source cowsay

 _______________________________________
( apt-get --download-only source cowsay )
 ---------------------------------------
        o    ,-^-.
         o   !oYo!
          o /./=\.\______
               ##        )\/\
                ||-----w||
                ||      ||

               Cowth Vader

Modifications & Distribution

The availability of the source code also allowed users to modify, fix and improve parts of the system, by changing its source code.

These changes constituted a significant development contribution to official distribution of UNIX, and Thompson and Richie eagerly integrated them into the official distribution.

What constituted a technical development brought unclarity to the ownership of UNIX. With code written by several users mingling with code written at Bell Labs was UNIX still the property of AT&T?

To go with the unclear ownership informal distribution where a tape with changes was circulated informally outside AT&T control.

man pages

Man(ual) pages - online documentation found on a Unix or Unix-like operating system - began to be written in 1971.

Combined with the availability of the source code, the documentation of the system and its tools made UNIX a popular teaching tool.

Currently, nearly all applications come with a man page, which can be called with man application_name. But also components of the operating system have man pages, such as files, system overview.

An extensive list Linux of man pages can be found in https://www.kernel.org/doc/man-pages/

Forking UNIX: Minix

Given its success and possible commercial viability UNIX Version 7 (1979) was released with a license that prohibited its source code from being studied.

UNIX had been for years a learning tool in computer science departments, as it allowed students to first hand study, modify and get to understand the inner-workings of the operating system.

University were now being asked to drop UNIX.

Andrew Tanenbaum who was teaching and using UNIX as a teaching tool at the Vrije Universiteit in Amsterdam, instead of complying decide to write a new UNIX like operating system called Minix. He did so without using a single line from the UNIX source code, but writing it from scratch, so that he and his students could continuing using it a learning tool.

Although conceptually close to UNIX, Minix was a different legal object, outside the control of AT&T.

Forking Minix: Linux

Like UNIX had spread through computer science departments, so did Minix.

In 1991 a Helsinki computer science student named Linus Troval sent an email to the comp.os.minix user group

    From: torvalds@klaava.Helsinki.FI (Linus Benedict Torvalds)
    Newsgroups: comp.os.minix
    Subject: What would you like to see most in minix?
    Summary: small poll for my new operating system
    Message-ID: <1991Aug25.205708.9541@klaava.Helsinki.FI>
    Date: 25 Aug 91 20:57:08 GMT
    Organization: University of Helsinki

    Hello everybody out there using minix –

    I’m doing a (free) operating system (just a hobby, won’t be big and
    professional like gnu) for 386(486) AT clones. This has been brewing
    since april, and is starting to get ready. I’d like any feedback on
    things people like/dislike in minix, as my OS resembles it somewhat
    (same physical layout of the file-system (due to practical reasons)
    among other things).

    I’ve currently ported bash(1.08) and gcc(1.40), and things seem to work.
    This implies that I’ll get something practical within a few months, and
    I’d like to know what features most people would want. Any suggestions
    are welcome, but I won’t promise I’ll implement them 🙂

    Linus (torvalds@kruuna.helsinki.fi)

    PS. Yes – it’s free of any minix code, and it has a multi-threaded fs.
    It is NOT protable (uses 386 task switching etc), and it probably never
    will support anything other than AT-harddisks, as that’s all I have :-(.

Yet again another fork of Unix: basing his design on Minix.

The result was the development of the Linux Kernel

GNU Project

Stallman.png

Across the Atlantic, Richard Stallman, was working on the GNU(Not Unix) project - an free Unix like operating system. and license a copyright license, the GNU General Public License, that would guarantee its freedoms.

According to Stallman's Free Software definition:

  • The freedom to run the program as you wish, for any purpose (freedom 0).
  • The freedom to study how the program works, and change it so it does your computing as you wish (freedom 1). Access to the source code is a precondition for this.
  • The freedom to redistribute copies so you can help your neighbor (freedom 2).
  • The freedom to distribute copies of your modified versions to others (freedom 3). By doing this you can give the whole community a chance to benefit from your changes. Access to the source code is a precondition for this.

Stallman began writing

  • a C compiler: gcc gccegg-65.png
  • a shell: bash
  • a text editor: emacs gnu-emacs.png

And a number of other tools.

However a working kernel was a major missing piece in Stallman's effort to create free Unix-like operating system.

Linus decided to release his kernel Linux under the GPL license, since the compiler - gcc - which he has been using and porting was was released under the GPL license.

Stallman and his colleagues sized the opportunity and integrated Linux as the kernel of this new Unix-like operating system, that became known as GNU/Linux. Although for Stallman annoyance Linux became the popular.



Tux-gnu-dynamic-duo.png

Unix and Unix-like operating systems

https://upload.wikimedia.org/wikipedia/commons/7/77/Unix_history-simple.svg


package managers

  • Linux:
    • aptitude
    • apt-get (lower level)
    • synaptic (graphic)
  • Mac OsX

Reading List

  • Brian W. Kernighan & Rob Pike, The Unix Programming Environment, Prentice-Hall, 1984
  • Peek, Jerry D., Tim Reilly, and Michael K. Loukides. UNIX Power Tools. Sebastopol, CA: Published in the United States by O'Reilly & Associates, 1997.
  • Stephenson, Neal. In the beginning ... was the command line. New York: Avon Books, 1999. PDF