You are on page 1of 9

BCCS 199

Module 01
An Introduction to Linux
Lecture Notes

1. What is Linux and what is it used for?

Linux is an Operating System (OS) used by computers to all users to interact with software.
The Operating System allows users to run this software.
Linux Features include:

- Detects and prepares your computer hardware:


When the machine is switched on, the operating system automatically starts.
One of its first jobs is to detect the hardware (CPU, memory, HDD, network, etc.)
It then loads the appropriate drivers to all the OS to interact with these devices.

- Manages the computer processes:


Many processes can be allowed to run at (seemingly) the same time.
The OS is responsible for scheduling when each process executes, and for how long.
An important task of the OS is to start, stop, kill, and suspend the processes.

- Manages the computer memory:


For a program to run, it must first be placed into Random Access Memory (RAM).
The OS allocates memory to programs and ensures that no other program interferes.
When the program is finished, the OS cleans up by releasing the memory.
The OS also has to manage the swap space.
This is a method of tricking the software into believing that theres more RAM.

- Creates an environment for the user to interact with the machine:


This is typically using a graphical or command line interface (called a shell).

- Provides access to a File system:


The OS will create a file hierarchy and allow access to files and folders.

- Manages User Authentication:


This involves creating user accounts and storing associated passwords.
Before a user can access the machine, they need to provide this information.
The OS then separates each users files and folders from other users.
It also allows the administrator to create groups that define multiple users.
These groups can be given permission to share resources.

- Provides Administration Utilities:


If a user authenticates as root (superuser access), additional utilities are available.
The OS provides this user with application that allow for:
- Creation, deletion and modification of users and groups.
- Manage disk space and partitions.
- Manage the configuration of the OS (Network adapters, etc.)
- Install and configure applications, etc, etc.

BCCS199 Page 1 of 9 Module 01


- Automatically starts specific services:
When the machine boots, processes (called daemons) run in the background.
These are programs that are waiting to receive and service any requests.
E.g.: A web server is waiting for a client request, and returns web pages.
E.g.: A print server is waiting for a print job, and send it to the printer.
E.g.: A DHCP server is waiting for a Discover, and sends back an Offer, etc.

- Allows software applications to be installed and run:


These applications provide services such as word processing, database management,
etc.

These features can be controlled via a Graphical User Interface (GUI), or the Command Line
Interface (CLI). Your task is to learn how to wield the tools needed to configure the system.

2. How Linux differs from other Operating Systems:

Other Operating Systems like Microsoft Windows and Apple OS X are proprietary.
As such, you cannot:
- See the source code used to create the OS.
- Change the OS in any way.
- Build your own OS using this as a base.
- Check the source code to find bugs or vulnerabilities.
- Write your own software to use the OS unless the vendor exposes APIs.

For this reason, many vendors have chosen to work with Linux instead.
This includes:
- Mobile Phone vendors (Android OS).
- Speciality hardware (TiVo, etc.)
- Companies who create routers, switches, Firewalls, APs, etc.

Large companies (Google, Facebook, and yes, Microsoft) use Linux in their day-to-day
operations. They require staff to maintain and manage their Linux systems.

3. The Linux Evolution:

When people say Linux, they mean the kernel of the computer system.
A hardware platform is said to run Linux if it supports the OS.
The Linux kernel and tools are collectively called a Distribution.

Please note - UNIX is not Linux.


UNIX was developed by AT&T Bell Labs in the 1970s.
It was modified and forked, and today, there are many different variants of UNIX.
UNIX is a trademark (owned by an industry consortium called the Open Group).
Only software certified by this group can call itself UNIX.
Thus, UNIX is also a specification.
Linux isnt certified, so it isnt UNIX.

BCCS199 Page 2 of 9 Module 01


3.1 Role of the Kernel

This is a vital part of the Operating System.


It dictates which program (or daemon) gets what memory and CPU time.
It is responsible for starting and killing these programs.
It manages the overall computer resources.
When allocating CPU time, this task is called pre-emptive multi-tasking.

The boot loader is started when the PC starts up; it loads the kernel and transfers control to it.
The kernel then loads the necessary parts of the operating system and runs it.

3.2 Applications

The kernel controls the running of applications.


It allocates resources (as required) to the applications.
This includes: memory, CPU, disk, etc.
It abstracts details from the programs.
That is, the application doesnt need to know if the HDD is an SSD, or a file share.
Applications just use the kernels Application Programming Interface (API) to access it.
The API abstracts out the details of the resources being requested.

The kernel runs many programs (or processes):


- User facing applications.
- Internal applications (tasks).
- Remote machine facing services.
Some processes require child processes to run.
The kernel will start and stop these sub-processes as necessary (try pstree).

3.3 Role of Open Source

Linux was created in 1991 by Linus Torvalds.


This, he made freely available for others to use.
It was modelled on UNIX, arguably without the mistakes.
The source code (human readable form) was written in C.
This is the same language used to write UNIX.
The source code is first compiled and then linked to libraries.
Typically, non-Linux operating systems have a Closed Source license.
The purchaser gets the rights to run the executable, not manipulate the source code.
Generally, youre not even allowed to see the source code, let alone reverse engineer it.

With Linux, you are allowed access to the source code.


You can change it, and share these changes (free of charge) with others in the community.
The GNU (GNU is not UNIX) project creates another UNIX-like OS.
Created in 1983 by Richard Stallman, he wanted software to be free.
Alongside this, it also created many programs.
No stable release of a GNU OS exists yet (2015).
The Linux kernel can be used with the GNU software.
Examples of GNU software include: GCC, GNU Debugger, bash shell, GNOME, etc.
BCCS199 Page 3 of 9 Module 01
3.4 Linux Distributions

The Linux kernel, GNU tools, and programs are bundled into a particular Distribution.
The distribution sets up the HDD, installs the Kernel, and the programs.
It also includes tools to manage the system (called a Package Manager).
This is a collection of software tools that automates the process of installing, upgrading,
configuring, and removing computer programs for a computer's operating system in a
consistent manner.

There are many different distributions of Linux available.


Some are designed for servers, others for desktops, and still others for embedded systems.
The major players are Red Hat, and Debian.
They have different package managers (RPM vs. DEB), and different file locations.

Red Hat started out with a distribution method called the Red Hat Package Manager (RPM).
It also has a dependency resolution tool, called YUM.
This distribution focusses on server applications (web / file / etc.)
Red Hat Enterprise Linux (RHEL) is released as a paid support service model.
It has a long release cycle (how often the software is upgraded).
Businesses favour long release cycles, whilst enthusiasts prefer short release cycles.
Red Hat sponsors Fedora for the personal desktop which sports the latest software.
CentOS recompiled all the RHEL packages and gave them away for free.
They simply ripped off all the Red Hat badging, and dont supply the paid support model.

Debian is the result of a community effort.


It has its own package management system called dpkg which uses the .deb file format.
Debian was the first to create a widely known dependency resolution tool, called APT.
Red Hat only supports Intel and AMD processors.
Debian supports many other types as well.
Ubuntu (by Canonical) is a popular Debian derived distribution.
This company provides paid support of the product.

3.5 Hardware Platforms

Linux started out only running on an Intel 80386 processor with a specific HDD controller.
Others helped support Linux by building drivers for other hardware components.
Today, it even supports embedded devices.
It is now easier to build hardware using supporting components that support Linux than it is
to build custom hardware and write your own Operating System.

New mobile phones and tablets can run Linux.


Google build the Android platform which is Linux and software packages.
Companies can now use Android instead of having to write their own Operating System.

Linux is also found in other consumer devices, such as TiVo, ZigBee gateways, routers, etc.

BCCS199 Page 4 of 9 Module 01


4 Choosing an Operating System
Microsoft Windows is a non-UNIX Operating System.
Linux is a UNIX-like Operating System that hasnt passed UNIX certification.
Because of this, it cant carry the UNIX trademark.
Alternatives Operating Systems exist that have been UNIX certified.
When choosing an OS, first ask: What will this machine be asked to do?

4.1 Decision Points

Are there specific tasks for this machine (specific software)?


This requirement will be the first one to consider when purchasing a machine.

What is the role of the machine?


- Desktop web browsing, or running applications?
- Web server or file server, offering services to other machine?

Servers typically sit in a rack, and one connects to it using the SSH protocol.
These machines typically run using a non-graphical user interface.
All the resources are used for services, not flashy graphics.

Does your team have the skill sets to manage these machines?

What is the lifetime and risk tolerance of the server?


Operating system upgrades come on a periodic release cycle.
The Maintenance cycle defines how long a release is supported for.
Fedora Linux has a 6 month release cycle.
Versions are considered End of Life (EoL) after two major versions, plus one month.
Therefore, support is only for 7 to 13 months.
Commercial Red Hat (RHEL) can go up to 14 years before needing to upgrade.

Use Red Hat if your machine is being used as a server.


It only requires a new version to be installed infrequently which can be very time consuming.
Use Fedora if your machine is a desktop.
A short release cycle implies you will have the latest beta software.

Backward compatibility is another issue to consider.


Here, a later OS is designed to support software written for earlier OS versions.

Cost is another factor.


Linux may be free however you may need to pay for support.
Microsoft OS has server licence costs, and may have additional support costs.

BCCS199 Page 5 of 9 Module 01


4.2 Microsoft Windows

Microsoft has both Server and Desktop OS variants.


Currently, the desktop edition is up to version 10 (29th July, 2015).
New versions are typically released every three to five years.
Backward compatibility is a priority for Microsoft Operating Systems.
The Server option is currently at Windows Server 2012 Release 2 (2013).
This Server runs a GUI, but now has strong scripting abilities through PowerShell.
The server can look like a desktop with the optional Desktop Experience package.

4.3 Apple OS X

This OS has undergone UNIX certification.


It is partially based on software from the FreeBSD project.

OS X is a desktop OS that is very popular with creative industries such as video production.
(This is pronounced OS-ten, not OS-Ex).

Here, applications drive the decision on hardware.


If you want to run specific software, you must choose Apple hardware.
This is the only hardware that runs this OS.

4.4 BSD

Berkeley Software Distribution (BSD) is another UNIX-like variant.


There are several open-source BSD projects:
- OpenBSD (very secure)
- FreeBSD (easiest to use)
- NetBSD (available on most computer hardware platforms)

These Operating Systems are alternatives to Linux.


Apple Inc. iOS and OS X are forks of BSD.

BSD is typically used in the server role.


They can, however, run GNOME and KDE as desktop machines.

The difference between BSD and Linux is surprisingly small.


Both are UNIX like operating systems.
Both are developed by non-commercial projects.
Approximately 80% of all BSD installations is using FreeBSD.
Other distributions include NetBSD, OpenBSD and DragonFlyBSD.

Linux is available under the GNU General Public License (GPL).


This is designed to eliminate closed source software.
Any derivative work of a product released under the GPL must also be supplied with source
code if requested.

BCCS199 Page 6 of 9 Module 01


By contrast, the BSD license is less restrictive.
Binary-only distributions are allowed.
This is particularly attractive for embedded applications.
The BSD code can be used by vendors to make proprietary applications.

4.5 Other Commercial UNIXes

Popular commercial UNIXes include:


- Oracle Solaris
- IBM AIX
- HP-UX

Each runs on hardware that is proprietary to the vendor.


This hardware is typically very large and powerful.
Users tend to choose this OS because theyre already locked into their hardware.

4.6 Linux

If you choose to install Linux, then you still need to choose a distribution.
A distribution packages the Linux kernel, utilities, management tools and update manager.

If you choose OS X, Windows, or OpenBSD, then thats what you get.


With Linux, you can then choose a distribution suitable for servers or desktops.
You can even choose a distribution of embedded hardware.
One version is designed to turn an old PC into a firewall.

You may wish to choose a distribution that offers paid support.


This is typical for companies running mission critical server hardware.

5 Understanding Open Source Software and Licencing


There are three entities to consider when purchasing software:
1. Ownership Who owns the IP behind the S/W?
2. Money transfer does money change hands, and if so, how?
3. Licencing What do you get? How many PCs can it run on? Can you give it away?

Generally, ownership remains with the company that owns the product.
Users are only granted the right to run the software.

Money transfer depends upon the business model.


It may be a one-off payment, a leasing arrangement, or just payment for support.

Licencing is what differentiates Open Source software from Closed Source software.

With Microsoft Windows, Microsoft owns the Intellectual Property (IP) rights.
The purchaser must accept a EULA to install the software.
BCCS199 Page 7 of 9 Module 01
Microsoft owns and retains the source code the purchaser only gets the run-time code.
Typically, you can only install the software on a single machine.
You are not allowed to reverse engineer the software.
You are given minor updates, but you have to pay for major upgrades.

Linux is owned by Linus Torvalds.


He placed the code under GNU Public Licence version 2 (GPLv2).
The source code is available to anyone who asks for it.
Anyone can change the source code.
Any changes can be distributed, but only under the same GPLv2 licencing.
You cannot charge for distributing the altered source code (except for actual costs).

The Free and Open Source Software (FOSS) is a licencing method.


Anyone is freely licenced to use, copy, study, and change the software.
The source code is openly shared so people are encouraged to improve on its design.
This is the opposite of proprietary software, which is licenced under restrictive copyright.

5.1 The Free Software Foundation and the Open Source Initiative

Two groups have been influential to the world of open source software:
- Free Software Foundation (FSF).
- Open Source Initiative (OSI).

1. Free Software Foundation:

This is Free as in the ability to share study and modify the source code, not free as in cost.
FSF believes that proprietary software is bad.
If you modify free software, you should be required to share your changes.
This is known as copyleft.

FSF oppose software patents, and acts as a watchdog for standards organisations.
They oppose the Digital Rights Management (DRM) technology.
DRM controls the use of digital content after sale by using copy protection.

FSF has developed its own sets of licences, including GPLv2 and GPLv3.
They also have Lesser GPLv2 and Lesser GPLv3.
Under GPLv3, you cant redistribute S/W that uses a closed source library (e.g. H/W driver).
Under Lesser GPLv2, you can.

2. Open Source Initiative:

This believes that FSF is too politically charged.


A less extreme measure is required with licencing (particularly around copyleft).
OSI doesnt have a set of licences; it has a set of principles.
Software holding to this principle is known as Open Source Software.

Basically, OSI states you can do what you like with the S/W, just dont say you wrote it.
Specifically, you have to acknowledge the creator and maintain the copyright notices.
BCCS199 Page 8 of 9 Module 01
5.2 More Terms for the Same Thing

Both FSF and OSI are referred to as Free and Open Source Software (FOSS).
The word Free is ambiguous. Is it:
- Free as in free beer?
- Free as in free speech?

As such, the word Libre is used to refer to the later definition (free speech).
Libre is French for Liberty or having freedom.
As such, the acronym is now Free/Libre/Open Source Software (FLOSS).

When youre using FOSS software, you dont have to pay for it, and you can redistribute it as
you wish.

5.3 Other Licencing Schemes

FOSS licences are mostly related to software.

A Public Domain Licence means the author relinquishes all rights, including copyright.
This is the default in some countries when the work is performed by a government agency.
Copyrighted work becomes public domain some time after the author has died.

The Creative Commons (CC) organisation has created the Creative Commons Licences.
This tries to exert FOSS on non-software entities.

5.4 Open Source Business Models

If you give away your software, how do you make money on it?
The easiest way is to sell support / warranty around the software.
Users pay when they need help, or want bugs fixing.

Another way is to charge for a service, or subscription that enhances the software.
An example is the freemium model.

Another option is to package hardware alongside the software.


An example is to sell a consumer firewall using Linux running your service.

Another example is you could be working on the software for you job.
When completed, your company may be persuaded to release the software using the FOSS
model.
Wireshark was written and released in this manner.

BCCS199 Page 9 of 9 Module 01