Chapter 3: Philosophy and Concepts of Linux

About Linux

  • open
  • flexible
  • stable
  • scalable
  • secure

Operating system

  • Bridges the gap between hardware and software
  • Tools to manage and monitor the system

OS layers

Note:

  • Manage and monitor the whole stack
  • Philosophy of the OS is relevant for the SysAdmin

A bit of history

UNIX

Inspiration and ancestor of Linux

Starting with UNICS MULTICS: Multiplexed Information and Computing Service UNIX

PDP-7

The Berkeley Software Distribution (BSD)

The Birth of Linux

  • 1991: Linus Torvalds uses Minix for school projects
  • Writes his own kernel for 80386 CPU
  • Announcement in August 1991
  • First public version of “Freax” in September 1991
  • GPLv2 in February 1992

Note:

  • Published as “Linux” by ftp sysadmin Ari Lemmke

comp.os.minix

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 [at] kruuna.helsinki.fi)

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

Proprietary vs. open source

Proprietary software

Free software

Copyleft

Note:

  • free license != no copyright

The Linux Truth

“Unix was not designed to stop its users from doing stupid things, as that would also stop them from doing clever things.” –Doug Gwyn

Note:

  • Trust the user
  • No restrictions on what you can do
  • Do stupid things, learn from them, do clever things

What Makes Linux Great

Knowledge

  • Open for inspection
  • Learning by doing

Note:

  • Compare with modern cars
  • Certifications

Flexibility

  • CPU architectures
  • SoC to Supercomputer
  • IoT
  • Old hardware

Stability

  • Reliable operation
  • Longevity
  • Does not apply to all apps, though

Note:

  • More on longevity later

Scalability

  • Vertical scaling
  • Imagine a Beowolf cluster of these
  • Supercomputers
  • Cloud computing

Security

  • Security is only becoming more critical
  • OS hardening
  • Open source allows inspection
  • Distribution updates
  • Security distributions

Note:

  • They are after you, too.
  • Long Term Support

Freedom

  • Free as in beer
  • Free as in freedom
  • FLOSS - Free/Libre and Open Source Software

Note:

  • Political and philosophical views

“Free software” means software that respects users’ freedom and community. Roughly, it means that the users have the freedom to run, copy, distribute, study, change and improve the software. Thus, “free software” is a matter of liberty, not price. –Richard Stallman

Note:

  • FSF

Our software rights

  • OSI licenses
  • “OSSwashing”

Longevity

  • Hardware lifetime
  • Open formats

Note:

  • “Planned obsolescence”
  • Lenovo ThinkPad T480

Resist malware

Should I be a sysadmin?

First, what is a sysadmin?

“a person who is responsible for the upkeep, configuration, and reliable operation of computer systems, especially multiuser computers, such as servers.” –Wikipedia

“Sysadmins are the unsung heroes of the modern age.” –Paul Graham

Note:

  • Learn Linux because you owe it to yourself

The changing profile of the SysAdmin

  • Server operator
  • DevOps
  • SRE

Terminology

  • “Computer” can be hardware or VM
  • Also: “machine”, “box”, “system”
  • “Node” or “host” is usually a computer in a network

Operating Systems

When we talk about Linux, we talk about operating systems. Linux is an operating system, after all. Depending on how narrow you define “operating system”, some might say the operating system is actually “GNU/Linux”, and we’ll discuss this later.

The first major piece of software that is executed on your computer when you switch it on is the operating system. Every computer requires an operating system, at least nowadays. In the early years of computing, computers would maybe launch directly into an application software for which the computer was bought, for example an accounting or bank management system. Actually, in some cases, the computer would not run anything at all when you switched it on, because it didn’t have any software built in that could allow it to start operating. For example, early models of the PDP-11, a minicomputer from Digital Equipment Corporation (DEC) on which the Unix operating system was developed in the early 1970s, required that, when powered on, an operator entered a bit of “bootstrapping” machine code[^bootstrap] via switches on its front panel. This tiny piece of code would, for example, provide the minimum logic required to access a paper tape reader from which the computer would then read another, more complex piece of software that would enable it to access a more sophisticated storage medium such as a tape drive, from which it would finally load the actual operating system. This problem was later solved by integrating this kind of basic system software into the computer hardware in the form of a pre-programmed ROM chip.

[^bootstrap] This term comes from the fact that any computer requires software to access software. It basically has to “pull itself up by its own bootstraps”.

On every computer, applications need to be loaded into memory, executed, and removed cleanly after they served their purpose. In order to interact with a user, applications need to access input and output devices such as a keyboard and a screen. They require additional memory to manage their own data; and to store that data persistently, they need to read and write files, or send it to external devices like a printer. In the early days, these and many other very basic functions might have been implemented for and delivered with each individual application, but it became clear quickly that reinventing the wheel all the time wasn’t economical. Today, it is the responsibility of the operating system to provide all the basic services and features needed and shared by applications. That’s why we say that applications “run on Operating System XYZ”.

Some would say that the operating system is the single most important choice you will make concerning your computer. But many people do not even know that there is a choice at all. For them, the operating system is what comes with the computer when you buy it. Windows computers come with Microsoft Windows, and Apple computers come with macOS. Oblivious to the fact that there are alternative operating systems that can run on the same hardware as Windows or macOS, and that they have the freedom to choose, they are missing a whole world of opportunities.

What is an operating system?

OS layers

Note:

  • Not the GUI that appears after booting

Hardware

Note:

  • SBC, PC, mainframe, supercomputer
  • Embedded systems (printer, IoT)

Motherboard

  • Processor
  • Memory
  • I/O interfaces
  • Bus system
  • Display adapter

Note:

  • Index

The processor

  • CPU/processor
  • Socket
  • Core
  • Thread

Note:

  • lscpu

Peripherals

The operating system

The definition

  • Kernel
  • API
  • Utilities

Typical operating system functions

  • Memory management
  • Multitasking
  • Managing users
  • Process management
  • Interprocess communication
  • Device management

Note:

  • Index

Memory management

  • RAM
  • Swap

Multitasking

Note:

  • htop
  • Updates in background (Silverblue)

Multiuser

Process management

  • Process scheduling
  • Process priority
  • Process blocking

Interprocess communication

  • Vital for multitasking
  • Shared memory
  • Named pipes

Device management

  • Input/output (I/O)
  • Access management

Utilities

Note:

  • User interface to the operating system

Philosophy of Linux

Linux philosophy hierarchy

The tenets

Data streams are a universal interface

“This is the Unix philosophy: Write programs that do one thing and do it well. Write programs to work together. Write programs to handle text streams, because that is a universal interface.”

Doug McIlroy, Basics of the Unix Philosophy

Note:

  • STDIO developed by Ken Thompson
  • Visualize

Transforming data streams

Note:

  • Visualize pipes
  • Redirect into file
  • “transformer” » “filter”

Everything is a file

“The whole point with “everything is a file” is … the fact that you can use common tools to operate on different things.” —Linus Torvalds

Note:

  • Boot record
  • Disk partition
  • Printer
  • Possible through “device special files”

Use the Linux FHS

https://refspecs.linuxfoundation.org/FHS_3.0/fhs/index.html

There’s also the XDG Base Directory Specification which is a more recent standard for where user specific configuration files should be stored.

Embrace the CLI

Be the lazy SysAdmin

Automate everything

Always use shell scripts

Test early test often

Use common sense naming

Store data in open formats

Use separate filesystems for data

Make programs portable

Use open source software

Strive for elegance

Find the simplicity

Use your favourite editor

Document everything

Back up everything – frequently

Follow your curiosity

There is no should

Mentor the young sysadmins

Support your favourite open source project

Reality bites

Linux Distributions