[StuCo 98008]
GNU/Linux for Beginners

Session 2

Operating Systems Fundamentals

Definitions of Important Terms

The GNU/Linux filesystem

By the end of this lecture you will know

What an operating system is

The main components of an OS

The history of GNU/Linux

What GNU, Linux, distribution all mean.

The filesystem structure of GNU/Linux

How to explore the filesystem

An Operating System...

Provides communication between machines and humans by:

Knowing how devices
work (drivers)

Managing memory and CPU
(to emulate multi-tasking)

Accepting commands from
humans (through a UI -
user interface)

Interpreting and passing commands to hardware.

Main Components of Operating Systems

Kernel – provides hardware management

User Interface

Command Line Interface (CLI)

Bourne Again Shell a.k.a. bash

DOS command line

Graphical User Interface (GUI)

XFree86

Mac OSX Quartz

userland n. Anywhere outside the kernel*

* (The Jargon File - http://www.jargon.org)

Source: ftp://ftp.oreilly.com/pub/poster/oreilly_linux_poster.pdf

The Linux kernel

Started as a fun project by Linus Torvalds in 1991

Linux 2.4.20: 17750 files, 3,100,000 lines of code

*Calculated using David A. Wheeler's 'SLOCCount'

Programming languages used in the Linux kernel *

ansic: 2920896 (94.36%)

asm: 164848 (5.33%)

sh: 3267 (0.11%)

perl: 2273 (0.07%)

yacc: 1575 (0.05%)

cpp: 794 (0.03%)

lex: 748 (0.02%)

tcl: 577 (0.02%)

awk: 251 (0.01%)

lisp: 218 (0.01%)

sed: 79 (0.00%)

User Interface

Command Line Interface

The basic input/output mechanism of any UNIX system.

Shell – the command interpreter (“command prompt” in other OSs) – bash, tcsh, csh etc.

Terminal – a local or remote mechanism that facilitates some kind of shell.

Console – the terminal that is provided to the user that has physical access (e.g. Ctrl-Alt-F1)

Graphical User Interface

One layer above the CLI.

GUI can only do what CLI can do, while the reverse is not necessarily true.

GUI is based on a “windowing” system, called X.

X draws basic shapes and handles fonts and colors only.

The rest is provided by a window manager, like KDE, GNOME, WindowMaker, BusyBox etc.

A graphical depiction

How a mouse click is received by the system...

Translated to a shell command...

Received by the kernel...

Executed by the network card

(Very brief) History of GNU/Linux

1970:
UNIX born in AT&T Labs

1984:

GNU Project
started

1991:

Linux kernel
created

2003:

GNU/Linux

maturity

Protecting Freedom – the GNU GPL

Project commencement 1984 – Richard Stallman

Free Software Foundation founded 1985

GNU General Public License (GPL)

Uses copyright law against itself

Grants complete freedom to users, with two restrictions:

This software may not be released with a different license.

This software may not be incorporated in non-free software.

Source: http://www.gnu.org/copyleft/gpl.html

The GNU General Public License

Free as in speech, not free as in beer.

Free to use the program

Free to study how the program works, and adapt it to your needs

Free to redistribute copies to anyone

Free to improve the program and release the improvements to the community

Source: http://www.gnu.org/philosophy/free-sw.html

The Free Software Definition

Important Terms

GNU: The free OS built as an alternative to UNIX

Linux: The kernel most commonly used with GNU

Distribution: A pre-packaged collection of software (e.g. Red Hat Linux, Debian GNU/Linux)

Kernel space: The memory space used by the kernel (inaccessible to user applications)

Userland (or user space): The memory space used by user applications

Filesystem: A system to organize the files of an Operating System

Reading for next week

“Is Open Source synonymous with Free Software?”
http://www.gnu.org/philosophy/free-software-for-freedom.html

“The Linux Cookbook” - Shell section
http://www.tldp.org/LDP/linuxcookbook/html/cookbook_5.html#SEC48

The application layer is considered the highest level of the software controlling a computer.

Working down the layers, the hardware-specific code managed by the kernel (usually referred to as “kernel modules” or “device drivers”) is considered to be the lowest level of software possible.

The Linux kernel accepts commands from the various user interfaces available, but is not directly accessible by the user.

E.g. I cannot send the text string “hello” directly to the kernel, without using some kind of interface.

Anything running in userland (hence, all applications), can be directly manipulated by the user.

E.g. I can send the “HANGUP” signal to a process, which will cause it to quit whatever it's doing and exit.

The periphery holds the most high-level applications, databases, servers.

As we move towards the center, we go down to protocol level (networking, file systems).

Next to the very core of the system (the kernel) lie the device drivers (lowest level software).

C is a fairly low-level language, that allows for high performance and doesn't need extra code to interface with the hardware.

Notice the absence of Java from the Linux kernel.

The reasons?

Java is not free

Java is a very high-level language that needs lots of additional software to work.

For application coding, Java is a fine choice. For kernel-level stuff, it is quite irrelevant (unless all computers/devices had JRE ROMs on hardware...)

Top – a file selector GUI

Bottom – a shell over X and the KDE window manager, provided by the application konsole

CLI (or GUI – knetfilter, smoothwall etc) instructs userland application (iptables) to query the filtering subsystem of the kernel (netfilter)

KNOPPIX (http://knoppix.org) might very well be the most impressive achievement the GNU/Linux world has to demonstrate.

If you want to make sure that no one will use your feeely code to create proprietary (non-free) software, consider releasing it under the GNU GPL.

The legal validity of the GNU GPL is extremely important, as it currently is the only means by which free software developers can protect themselves against corporations with more money and legal muscle then the Free Software community.

Freeware is not free software, because the public is not allowed access to the source code, and can therefore make no modifications.

Open Source simply means that you can see the source code – but that doesn't give you the right to change it, or resell it.

For example, Microsoft is trying to convinve the world that their “Shared Source” program will result in quality of software equivalent to that of Free Software. But you have to sign an NDA (non-disclosure agreement) to read their code, which clearly demonstrates that Shared Source has nothing to do with the original Open Source/Free Software development process.

More definitions can be found using the Jargon File, searchable at http://catb.org/~esr/jargon/jargoogle.html

This is a typical view of the filesystem of any UNIX derivative (GNU, BSD, Solaris, AIX etc). Standardisation means that application software can follow some rules and be compatible across platforms (e.g. Sendmail always delivers local email to /var/spool/mail/ )

This tree structure is important to visualise, otherwise some paths and commands won't make much sense.

This image shows only a small subset of files and folders of a GNU/Linux system – there are considerably more in a real system!

Attaching devices under GNU/Linux. Basically, any removable medium is accessible under a directory in the filesystem.

By convention, /mnt is used as the usual “mount point” (i.e. the point where stuff gets attached to the filesystem) for removable devices like floppy and CD/DVD drives.

So, in most systems, a CD's contents can be found under /mnt/cdrom. A floppy is usually mounted under /mnt/floppy

An extended scenario, this time with an extra hard drive.

This shows us that any storage device is attached to the filesystem under a directory. Microsoft's C: and D: don't have any meaning in UNIX derivatives.

One can easily make the contents of an entire hard drive accessible under (for instance)

/home/alex/backup, with no special configuration.

Don't worry about knowing everything mentioned in the “Shell” section of the Linux Cookbook. Just skim through the document, to get a feel of the things one can do with the shell (just about anything,, that is).

Session 2 - What is GNU/Linux?

[StuCo 98008] Introduction to GNU/Linux

gnu linux operating system history unix distribution filesystem

This lecture attempts to provide an overview of the background and present status of GNU/Linux. Since most people don't understand exactly what they're talking about, when they say that "I installed Linux 7.3", a clear definition will be provided for each component of the system.
This will make it easier to communicate with the class throughout the course, since we will be talking with a common language.
We will also go through the basic utilities necessary to explore our system:
+ ls
+ cd
+ pwd
+ less
+ file
...and then go on and explore it, while explaining its structure and purpose. We talk about regular files (text, binaries, directories etc) and special files (devices under /dev, kernel entries under /proc)

2003-08-31T14:14:50