diff options
| Commit | 01dec6fd77ccf732ea9cf6f7468699347d285ada (patch) | |
|---|---|---|
| Author | 2023-01-21 23:06:34 +0200 | |
| Committer | 2023-01-21 23:06:34 +0200 | |
| Files | 9f98cf334f216e32ece8080c1fa2ea1928a143f3 | |
| syndamia.com-01dec6fd77ccf732ea9cf6f7468699347d285ada.tar syndamia.com-01dec6fd77ccf732ea9cf6f7468699347d285ada.tar.gz syndamia.com-01dec6fd77ccf732ea9cf6f7468699347d285ada.zip | ||
| Parent | 1ac3528ba6acceb7f3c4ea579f9698da13101f10 (diff) | |
[talks/lbs] Finished writing second "chapter"
3 files changed, 202 insertions, 5 deletions
| -rw-r--r-- | src/talks/linuxgraphy-by-strabo/img/unix-dir-tree.png | bin | 0 -> 4457 bytes | |||
| -rw-r--r-- | src/talks/linuxgraphy-by-strabo/img/unix-layers.png | bin | 0 -> 8473 bytes | |||
| -rw-r--r-- | src/talks/linuxgraphy-by-strabo/index.md | 207 |
diff --git a/src/talks/linuxgraphy-by-strabo/img/unix-dir-tree.png b/src/talks/linuxgraphy-by-strabo/img/unix-dir-tree.png Binary files differnew file mode 100644 index 0000000..ad1bebb --- /dev/null +++ b/src/talks/linuxgraphy-by-strabo/img/unix-dir-tree.png diff --git a/src/talks/linuxgraphy-by-strabo/img/unix-layers.png b/src/talks/linuxgraphy-by-strabo/img/unix-layers.png Binary files differnew file mode 100644 index 0000000..77ea8f9 --- /dev/null +++ b/src/talks/linuxgraphy-by-strabo/img/unix-layers.png diff --git a/src/talks/linuxgraphy-by-strabo/index.md b/src/talks/linuxgraphy-by-strabo/index.md index 8a24c01..edb7797 100644 --- a/src/talks/linuxgraphy-by-strabo/index.md +++ b/src/talks/linuxgraphy-by-strabo/index.md @@ -2,6 +2,8 @@ &&presentation + + &&clide &&font35 @@ -9,14 +11,15 @@ &&/font <br> -&&frcen +&¢ered &&frow &&flexer -2000 years ago [Strabo](https://en.wikipedia.org/wiki/Strabo) created [Geography](https://en.wikipedia.org/wiki/Geography), in which he laid out the world as it was known to the Romans and Greeks. +2000 years ago [Strabo](https://en.wikipedia.org/wiki/Strabo) published [Geography](https://en.wikipedia.org/wiki/Geography), in which he laid out the world as it was known to the Romans and Greeks. <br><br> Today, I'll lay out Linux as it is known to me. -&&fright  &&/fright -&&/frcen + + +&&flexer &&/frow &&/centered &&/centered &&flexer @@ -170,14 +173,208 @@ Programming was done mostly in [Bell Labs](TODO), who pulled pretty quickly from *Ken Thompson and Dennis Ritchie in 1973* &&/font -&&cont +&&fccen &&expand + [Ken Thompson](TODO), one of the programmers that worked on it, still had some desire to work on operating systems. After Bell Labs left Multics, he made a program for maximizing the throughput of a disk on a PDP-7. To test it, he wrote some programs over time and eventually realised an operating system could easily be made. This marked the birth of UNIX, an operating system, based and expanded on many of Multic's ideas (except the "grow too large" one). + +&&/expand &&/fccen + +&&/frow +&&flexer +&&/slide &&/font + + + +&&font30 &&slide + +# 2. Structure of UNIX-likes + +Ignoring [standards](https://unix.stackexchange.com/questions/14368/difference-between-posix-single-unix-specification-and-open-group-base-specifi/14415) and [specifications](https://unix.stackexchange.com/questions/87686/what-makes-an-operating-system-unix-like), in my opinion, from the point of a user, a UNIX-like OS has the following components: + +&&flexer + +1. **shell**: A programmable replaceable command-line interpreter, with utilities for managing the whole system and support for pipelines and I/O redirection +2. **UNIX-style file system**: [Filesystem](https://en.wikipedia.org/wiki/Unix_filesystem) as a rooted tree (even for all seperate volumes), objects (nodes) in the file system are [inodes](TODO) and an inode can be [(at least)](https://en.wikipedia.org/wiki/Unix_file_types) either a regular file, directory or devices. Permissions are set per owner, group members and other users. +3. **kernel**: Program that manages all communication and operations between the hardware and software + +&&flexer + +&&font20 *For now we'll generally just look over some of the common stuff and go into detail later, while in Linux.* &&/font + +&&/slide &&/font + + + +&&font35 &&slide + +## 2.1. shell + +&&flexer &&frow + +&&cont +Our operating system is divided into layers, [like an onion](https://youtu.be/-FtCTW2rVFM?t=57). +Only the kernel has access to the hardware. +shells and executables (binaries) have access to the kernel. + +shells provide user interfaces, [both](http://en.wikipedia.org/wiki/Shell_%28computing%29) command-line and graphical. +While on the topic of UNIX, we'll only discuss the former. &&/cont + + +&&/frow &&flexer &&/slide &&/font + + + +&&font27 &&slide + +Command-line shells operate solely with text, preferrably without too fancy formatting (there are very modern ones that can handle images, but these are an exception, rather than the norm). + +&&flexer +&&frow + +Historically, video displays (at first [CRT](TODO) ones) became widely available in the late 1970s, but before that the "mainstream" way to access a computer was with a teleprinter (commonly known as teletype): effectively a (typewriter) keyboard and a fast text priner, connected to a computer. + +&&font18 &&fright + +*Teletype Model 33 by [Arnold Reinhold](https://commons.wikimedia.org/wiki/User:ArnoldReinhold)* +&&/fright &&/font &&/frow + &&flexer + +&&frow + +&&font18 + +*DEC VT100 by [Jason Scott](https://www.flickr.com/people/54568729@N00)* +&&/font + +Later, those were replaced by terminals, a "normal" keyboard and a display, connected to a computer. +**The** most popular and influential one was the [VT100](TODO), with it's most influential feature being neven seen before support of [ANSI escape codes](https://en.wikipedia.org/wiki/ANSI_escape_code): special text that would modify the cursor position and later being able to, for example, change colors for specific text. + +&&/frow &&/slide &&/font + + + +&&font27 &&slide + +In UNIX CLI shells, most of the commands are just regular programs. +These programs could exist in more than one folder: `/bin` and `/usr/bin` for example, so we store every location in a variable called "PATH". + +&&flexer + +Command-line UNIX shells always have the following features: + +- pipelines: being able to redirect the output from one command to another without limit + + ``` + command1 [args...] | command 2 [args...] | ... + ``` + +- I/O redirection: redirection of input and output, allowing use to use a file as (user) input: + + ``` + command [args...] < filepath + ``` + + or to put output into a file + + ``` + command [args...] > filepath + ``` + +&&font18 +*A lot of modern ones also support [heredocs](https://en.wikipedia.org/wiki/Here_document), [job control](https://en.wikipedia.org/wiki/Job_control_%28Unix%29), built-in [test command](https://en.wikipedia.org/wiki/Test_%28Unix%29) and more, we'll explore them later.* +&&/font + +&&/slide &&/font + + + +&&font30 &&slide + +## 2.2. UNIX-style file system + +&&flexer + +- Rooted singular tree of directories. Disk partitions, removeable media, etc. all live in that tree. +- Each tree object (node) is an [i(ndex)node](TODO), containing type, ownership, access, internal data and any other metadata, but **not** name! +- Directory inodes (files) contain a table with rows of names and inode numbers, mapping a file name to it's contents. Each row is called a [hard link](https://en.wikipedia.org/wiki/Hard_link). Every directory has a hard link to itself, called ".", and a hard link to it's parent, called "..". + +&&flexer + +&&fcol  &&/fcol + +&&/slide &&/font + + + +&&font30 &&slide + +The main attributes that every inode has are as follows: + +- [file type](https://en.wikipedia.org/wiki/Unix_file_types): Each inode represents some sort of file (data), but a "file" can also be a directory or device, so we need to know how to handle it. + There are 7 main types (but there can exist more, depending on OS): + + **regular**: just a plain old file + + **directory**: as explained, a file containing hard links to other files. Each directory is allowed to appear only once in a single parent. + + **symbolic link**: points to any file (or directory). It contains the (relative) path to that object (as a simple string), so a symlink could even not be valid. + + **FIFO special**: aka [named pipe](https://en.wikipedia.org/wiki/Named_pipe), a special type of regular file, where at any moment only one process can read from it and one can write to it. It takes the concept of shell pipes to inter-process communication. + + **block special**: a device which is randomlly accessible, like a hard drive or cdrom drive. + + **character special**: devices which are accessed via serial streams of input or output, like keyboards, mice, graphics cards and teletypes + + **sockets**: file for inter-process communication. Compared to FIFO specials, they can be used by more than two processes, used in both direction and support [file descriptors](https://en.wikipedia.org/wiki/File_descriptor) and packets + &&/slide &&/font + + + +&&font30 &&slide + +- [file permissions](https://en.wikipedia.org/wiki/File_system_permissions): control the ability of a user to read (navigate for directories), change and execute a file. + A user in UNIX is essentially a small collectino of data, most important of it being an ID (number), a name (string), a group id (number; files created by the user are in that group) and a password. + Groups are also small collections of data, but much simpler, comprised only of an ID (number), a name (string) and a list of users that are "in" the group. Their main purpose is to simplify access control. + The data for each is stored in `/etc/passwd` and `/etc/group` respectively. + <br> + File permissions are split into three sets: what the owner can do, what group members can do and what anyone else can do. + Each set contains a mix of three permissions: **r**ead, **w**rite and e**x**ecute, and each set stores some combination of them. +- link count: the amount of hard links that point to the inode. Every directory inode contains (normally) exactly two: one from the parent and one from itself ("."). A file is only deleted where there are no hard links left to it (or when there is only one for a directory). +- User ID of owner and Group ID +- file size and timestamps for modification + +&&/slide &&/font + + + +&&font35 &&slide + +## 2.3. Kernel + +&&flexer + +The kernel is completely separated from everything else, it only communicates with hardware and exposes an API to have other programmes communicate with it. + +&&flexer + +Linux is **not** an operating system, it is a kernel!!! + +&&flexer + +&&/slide &&/font + + + +&&slide + +## Sources + +- [wikipedia.org](https://en.wikipedia.org/) has been used extensively. +- [CS416 - Operating Systems Design](https://people.cs.rutgers.edu/~pxk/416/index.html) by [Paul Krzyzanowski](https://people.cs.rutgers.edu/~pxk/rutgers/) at [Rutgers State University](https://www.cs.rutgers.edu/) +- [Origins and History of UNIX, 1969-1995](https://web.archive.org/web/20220713165958/https://homepage.cs.uri.edu/~thenry/resources/unix_art/ch02s01.html) from [The Art of Unix Programming](TODO) by Eric Steven Raymond +- [Ken Thompson interviewed by Brian Kernighan at VCF East 2019](https://www.youtube.com/watch?v=EY6q5dv_B-o) by [Vintage Computer Federation](https://vcfed.org/) +- [Hard links and Unix file system nodes](https://teaching.idallen.com/dat2330/04f/notes/links_and_inodes.html) from [DAT 2330 Introduction to Operating Systems](https://teaching.idallen.com/dat2330/04f/) by [Ian D. Allen](http://www.idallen.com/) + +&&/slide |