diff options
| Commit | 7cad15059689dd6167f23f06646e9203fe189121 (patch) | |
|---|---|---|
| Author | 2023-01-22 16:52:32 +0200 | |
| Committer | 2023-01-22 16:52:32 +0200 | |
| Files | 8448d9520a08a9ceb19074ec46a8b7cdf8c64249 | |
| syndamia.com-7cad15059689dd6167f23f06646e9203fe189121.tar syndamia.com-7cad15059689dd6167f23f06646e9203fe189121.tar.gz syndamia.com-7cad15059689dd6167f23f06646e9203fe189121.zip | ||
| Parent | 49f40fc66f50406e365a7ad07f1a71c8b5e15b48 (diff) | |
[talks/lbs] Finished chapters 3 and 4
2 files changed, 338 insertions, 33 deletions
| -rw-r--r-- | src/img/bg.svg | 7 | ||||
| -rw-r--r-- | src/talks/linuxgraphy-by-strabo/index.md | 364 |
diff --git a/src/img/bg.svg b/src/img/bg.svg new file mode 100644 index 0000000..b100dd0 --- /dev/null +++ b/src/img/bg.svg @@ -0,0 +1,7 @@ +<svg xmlns="http://www.w3.org/2000/svg" id="flag-icons-bg" viewBox="0 0 640 480"> + <g fill-rule="evenodd" stroke-width="1pt"> + <path fill="#d62612" d="M0 320h640v160H0z"/> + <path fill="#fff" d="M0 0h640v160H0z"/> + <path fill="#00966e" d="M0 160h640v160H0z"/> + </g> +</svg> diff --git a/src/talks/linuxgraphy-by-strabo/index.md b/src/talks/linuxgraphy-by-strabo/index.md index f4137be..1a19ec6 100644 --- a/src/talks/linuxgraphy-by-strabo/index.md +++ b/src/talks/linuxgraphy-by-strabo/index.md @@ -30,36 +30,26 @@ Today, I'll lay out Linux as it is known to me. -&&slide +&&font35 &&slide # Contents -&&ftable &&font20 +&&ftable &&cont 1. Brief timeline 2. Structure of UNIX-likes - 1. Layers - 2. The shell - 2. Everything is a file -<!-- + file permissions --> - 3. What is a VT100 anyway - 4. Possibilities (live CD, ...) -3. Linux systems and layout from the inside - 0. Shells -<!-- + Processes (bg, fg); file globbing; expansion; variables --> - 1. Directories - 2. Users and groups - 3. Everything is a file - 1. Devices - 2. Processes - 4. Commands you need to know - 1. File management and editing - 2. Regular expressions and text processing - 3. Everything else - 5. Networking + 1. Shell + 2. UNIX-style file system + 2. Kernel +&&lineb2 +3. Linux from the inside + 1. Shells + 2. Files and directories + 3. Common configuration files + 4. System management 4. Software licensing -&&/font &&font20 +&&/cont &&cont 5. What makes up a useful OS 0. File systems @@ -68,21 +58,17 @@ Today, I'll lay out Linux as it is known to me. 2. Package (software) manager 3. Desktop manager 6. War on distros - 1. What is a distribution and how do we compare them + 1. What is a distribution 2. Comparison - 1. Slackware - 2. Debian (and Ubuntu) - 3. Red Hat - 4. Enoch (and Gentoo) - 5. Arch Linux +<!-- 1. Slackware 2. Debian (and Ubuntu) 3. Red Hat 4. Enoch (and Gentoo) 5. Arch Linux --> 3. Non-desktop distros - 1. AOSP - 2. OpenWRT -7. Full setup and demonstration with Linux Mint +<!-- 1. AOSP 2. OpenWRT --> +&&lineb2 +7. Demo - setup from zero -&&/font &&/table +&&/cont &&/table -&&/slide +&&/slide &&/font @@ -357,6 +343,318 @@ Linux is **not** an operating system, it is a kernel!!! +&&font27 &&slide + +# 3. Linux from the inside + +Enough theory, time to have some fun and learn Linux! + +We'll be using [Linux Minimal Live](https://ivandavidov.github.io/minimal/#home) because: + +- it's very small, comprised of only the Linux kernel, GNU C library and Busybox + so confusion, distractions and distro-specific configs will be minimal +- made by a fellow Bulgarian &&bg + +It's important to note that it isn't an installable OS, but just a bootable disk image. + +We're going to explore and look around the following stuff: + +&&lineb1 + +- **Shells**: What a modern shell would often support on a Linux based OS +- **Files and directories**: Naming conventions and commands to work with them +- **Common configuration files**: Relevant configuration files, their purpose and syntax +- **System management**: Other commands with which to modify your system + +&&/slide &&/font + + + +&&slide + +## 3.1. Shells + +- [Job control](https://en.wikipedia.org/wiki/Job_control_%28Unix%29): Management of currently running groups of processes + + `&`: A process can be ran in the background with an ampersand (&) at the end of the command: + + ``` + command [args...] & + ``` + + + `Ctrl+z`: suspend (stop but leave in the background) the currently running (foreground) job + + `bg`: start a suspended job in the background + + `fg`: resume the last job to be put in the background and make it the current job with which we're interacting + + `jobs`: list all active (background) jobs + &&lineb2 + + Every job is identified with a Job ID (number), which you can use by prepending a percentage sign. Example, to resume the job with JID 4: + + ``` + fg %4 + ``` + + For managing everything, usually there is a job table. + Upon shell termination, the shell tells all jobs in that table to terminate and waits for them. + `disown`: remove a job from the job table + + `kill`: send a signal to the process or job. Then that process will have to handle it accordingly. + Common ones are `-KILL` to immediately stop the process, `-QUIT` to quit it, `-ABRT` to cancel the current action, `-TERM` shut down (orderly), `-STOP` shut down (forcefully) + +&&/slide + + + +&&font27 &&slide + +- [heredoc](https://en.wikipedia.org/wiki/Here_document): File literal, meaning it is a user "string" which is interpreted as a file + + start with `<< NAME`, where NAME can be anything you want, it is used to mark the beginning and end of a heredoc. `<<` is also a redirection symbol + + on every new line write out your text, all characters will be preserved + + to end it, write out `NAME` on the beginning of a new empty line. Example: + + ``` + cat << MYFILE + This is + some + text + MYFILE + ``` + +- control operators: Control what command is executed, depending on [exit status](https://en.wikipedia.org/wiki/Exit_status) + + `expr1 && expr2`: Run expr2, only if expr1 exited successfully + + `expr1 || expr2`: Run expr2 if expr1 exited unsuccessfully + + `expr1 ; expr2`: Run expr2 after expr1 finished (no matter how) + + Every program returns an exit status (number) to the shell, zero being a successful closing, and all others indicating failure. + +&&/slide &&/font + + + +&&font27 &&slide + +&&lineb1 + +- [redirection](https://en.wikipedia.org/wiki/Redirection_%28computing%29): Outside of having `<` and `>` for I/O redirection, ofter there is also + + `>>`: Acts like `>`, putting text into a file, but rather than overwriting everything, it appends it + + `<<`: As explained, for heredocs + + `<<<`: To the right is a string ([herestring](https://en.wikipedia.org/wiki/Here_document#Here_strings)), and it is interpreted as a file + + ``` + cat <<< "Hello World!" + ``` + + + Standard input, standard output and standard error are all files with which the shell works. + Typing text in the shell puts it into stdin, command output are put into stdout (and shown to the user) and errors are put into stderr (also shown to the user). + Each one of them is numbered from 0 to 2, and you can specify redirection by appending or pepending it to the redirection symbol. + * `N>outputfile`: redirects the output from standard stream N into outputfile + * `N>&M`: redirects the output from standard stream N into standard stream M + * `N<inputfile`: redirects input file contents to standard stream N + * `N<&M`: redirects standard stream M to standard stream N + +&&/slide &&/font + + + +&&font30 &&slide + +&&lineb1 + +- [built-in test command](https://en.wikipedia.org/wiki/Test_%28Unix%29): With `test` you can do conditionall expressions. You can also often use brackets `[ args... ]` instead of `test args...` + + Some of the available file checks + * `-e FILENAME`: FILENAME exists + * `-d FILENAME`: if FILENAME is a directory + * `-h FILENAME`: if FILENAME is a symbolic link + * `-w FILENAME`: you can write in FILENAME + + Some of the available string checks + * `-n STR`: string STR has nonzero length + * `-z STR`: string STR has length zero + * `STR1 = STR2` and `STR1 != STR2`: self explanatory + + Some of the available number checks + * `INT1 -eq INT2`: equal integers + * `INT1 -gt INT2`: INT1 > INT2 + * `INT1 -gt INT2`: INT1 >= INT2 + + Operators: `!` - negation, `-a` - binary AND, `-o` - binary OR, parentheses for grouping (escaped with `\`) + + +&&/slide &&/font + + + +&&slide + +- [scripting support](https://en.wikipedia.org/wiki/Shell_script): Rather than running a series of commands manually, you can put them all in a file and run that + + `#`: Everything between a # and the end of the line denotes a comment + + `#!`: If on the first line of the file, is treated as a [shebang](https://en.wikipedia.org/wiki/Shebang_%28Unix%29), which specifies what interpreter to be used for the script + + Each command (line) is executed in series, from top to bottom + +- [compound commands](TODO): Shells also often offer more advanced structured, with which to more easily write complex expressions + +&&/slide + + + +&&font30 &&slide + +## 3.2. Files and directories + +&&lineb1 + +- `/bin`: main command programs (binaries), used by users +- `/etc`: system configuration files +- `/sbin`: command programs, used for the system operation +- `/usr`: other system resources + + `/usr/bin`: all other user command binaries + + `/usr/lib`: library files + + `/usr/local`: local, system software + + `/usr/share`: architecture independent data, like manuals +- `/var`: variable data, like logs and cache +- `/dev`: devices +- `/home`: home directories of all users +- `/lib`: libraries and kernel modules +- `/mnt`: mounted temporary filesystems +- `/proc`: process information +- `/root`: home directory for the root user + +&&/slide &&/font + + + +&&font30 &&slide + +### General file system commands + +&&lineb1 + +- `mkdir`: create directories +- `rm`: remove a (hardlink to) file or directory +- `shred`: overwrite file contents +- `mv`: move file (or directory) to another directory +- `cp`: copy a file +- `ln`: create hard (or soft, with `-s`) links to files (inodes) +- `ls`: list directory contents +- `dd`: do many things with files, like modifying and duplicating data across devices and partitions, (basic) data recovery and generating files +- `du`: estimate file usage +- `stat`: display status for file system or file system +- `chwon`: change owner of an inode +- `chgrp`: change group of an inode +- `chmod`: change file modes +- `find`: search for a file inside a directory (recursively) + +&&/slide &&/font + + + +&&font30 &&slide + +### Working with text (files) + +&&lineb1 + +- `echo`: prints a given string to standard output +- `cat`: sequentially prints files to standard output +- `less`: view files with support for scrolling +- `grep`: searches for matches in a file, using simplified regular expressions. Often there is `egrep`, which allows for extended regex and `fgrep` where strings are matched as-is. +- `sed`: filter and transform text from files, according to regex +- `tr`: translate, map (more than one to one for example) and delete characters +- `cut`: remove parts of text from each line +- `head`: print the first lines (or characters) of a file +- `tail`: print the last lines (or cahracters) of a file +- `strings`: find embeded text inside binary files +- `truncate`: shrink or extend the size of a file +- `wc`: count words inside file +- `diff`: compare files and show their differences + +&&/slide &&/font + + + +&&font30 &&slide + +### Working with devices + +&&lineb1 + +- `mount`: bind another file system to a location in the file system +- `umount`: remove binding to a file system + +&&/slide &&/font + + + +&&font25 &&slide + +## 3.3 Common configuration files + +- `/etc/group`: the data for all groups is stored here, in the format + + ``` + GROUPNAME:PASSWORD:GID:USERS... + ``` + +- `/etc/passwd`: the data for all users is stored here, in the format + + ``` + USERNAME:PASSWORD:UID:GID:USERINFO:HOMEDIR:SHELL + ``` + +- `/etc/shadow`: stores other user data, especially the password as an encrypted string, in the format + + ``` + USERNAME:PASSWORD:LASTCHANGED:MINBETWEENCHANGES:MAXBETWEENCHANGES:WARNEXPIRE:INACTIVEDAYS:EXPIRE + ``` + +- `/etc/fstab`: mountings of devices to the file system, read on boot by mount +- `/etc/hosts`: list of host names (domain names) and their corresponding IP address, when a DNS server doesn't do the job +- `/etc/bashrc`: global defaults and aliases used by the bash shell + +&&/slide &&/font + + + +&&font25 &&slide + +## 3.4. System management + +- System information + + `date`: display current date and time + + `hostname`: show (or set) the systems hostname (network name) + + `free`: display free memory on the system + +- Users and groups + + `useradd`: creates a new user (with a password) + + `userdel`: remove a user and all of his files + + `usermod`: modify a user account, including his name and groups + + `passwd`: change password of a user. With `-l` user could be locked (impossible to log in) + &&lineb1 + + `groupadd`: create a new group + + `groupdel`: remove a group + + `groupmod`: modify an existing group + &&lineb1 + + `w`: show who is logged in and what they are doing + + `who`: show who is logged in + + `whomai`: print username + + `login`: establish a new connection to the system + +&&/slide &&/font + + + +&&font30 &&slide + +# 4. Software licensing + +It is important to note that most software in Linux, including the kernel itself, is under a variety of open licenses. +An open license is a license which allows others to reuse the original work, under some restrictions. + +For software, such a license is applied to the source code from which the original application was made. +Some commonly used ones, with a (NON-LEGALLY BINDING) summary include: + +- MIT: the author is not responsible for anything that the code does +- BSD-3-Clause: use the same license (copyleft), the author is not responsible for anything that the code does +- GNU GPL: disclose the original project and use the same license (copyleft) + +This is important, since pretty much everything can be freely modified by anyone (for the better or worse, but generally better). + +&&/slide &&/font + + + &&slide ## Sources |