This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
|
os_cp:intro [2023/03/08 00:20] jkonczak |
os_cp:intro [2025/03/06 13:54] (current) jkonczak [Listing directory contents] |
||
|---|---|---|---|
| Line 22: | Line 22: | ||
| POSIX - a standard (published by IEEE and The Open Group) for operating system interface and environment, predominantly built to unify Unix-like systems | POSIX - a standard (published by IEEE and The Open Group) for operating system interface and environment, predominantly built to unify Unix-like systems | ||
| - | <html><small></html> | + | <small> |
| - | GNU/Linux | + | Linux, GNU/Linux, Linux distribution… |
| * [[https://www.gnu.org/gnu/gnu.html|GNU]] is a collection of free software that altogether forms an operating system supplied with a broad choice of user applications [[https://www.gnu.org/manual/blurbs.html]] | * [[https://www.gnu.org/gnu/gnu.html|GNU]] is a collection of free software that altogether forms an operating system supplied with a broad choice of user applications [[https://www.gnu.org/manual/blurbs.html]] | ||
| * the kernel of GNU, [[https://www.gnu.org/software/hurd/|Hurd]], has never been fit enough for the task | * the kernel of GNU, [[https://www.gnu.org/software/hurd/|Hurd]], has never been fit enough for the task | ||
| * therefore GNU software is usually run on top of Linux kernel | * therefore GNU software is usually run on top of Linux kernel | ||
| - | * most Linux distributions, apart form GNU software, has also a multitude of other software (not necessarely free or open source) | + | * most Linux distributions, apart form GNU software, has also a multitude of other software (not necessarily free or open source) |
| + | * some Linux distributions base on free and/or open source software that is neither GNU software nor uses GNU licenses | ||
| - | <html></small></html> | + | </small> |
| ==== Shell and vital utilities ==== | ==== Shell and vital utilities ==== | ||
| Line 59: | Line 60: | ||
| * Apple operating systems (e.g. MacOS) ship with modified BSD tools [[https://opensource.apple.com/releases/|[1]]] [[https://github.com/apple-oss-distributions/file_cmds|[2]]] [[https://github.com/apple-oss-distributions/text_cmds|[3]]] | * Apple operating systems (e.g. MacOS) ship with modified BSD tools [[https://opensource.apple.com/releases/|[1]]] [[https://github.com/apple-oss-distributions/file_cmds|[2]]] [[https://github.com/apple-oss-distributions/text_cmds|[3]]] | ||
| * Embedded / resource restrained systems often use [[https://www.busybox.net/downloads/BusyBox.html|BusyBox]] | * Embedded / resource restrained systems often use [[https://www.busybox.net/downloads/BusyBox.html|BusyBox]] | ||
| - | * Android uses [[https://www.landley.net/toybox/|toybox]] [[https://cs.android.com/android/platform/superproject/+/master:external/toybox/toys/posix/|[4]]] | + | * Android uses [[https://www.landley.net/toybox/|toybox]] [[https://cs.android.com/android/platform/superproject/main/+/main:external/toybox/toys/posix/|[4]]] |
| * For more, see [[https://wiki.archlinux.org/title/core_utilities]] | * For more, see [[https://wiki.archlinux.org/title/core_utilities]] | ||
| <html></small></html> | <html></small></html> | ||
| - | POSIX standarizes both the [[https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html|shell]] | + | POSIX standarizes both the [[https://pubs.opengroup.org/onlinepubs/9799919799/utilities/V3_chap02.html|shell]] |
| - | and its vital [[https://pubs.opengroup.org/onlinepubs/9699919799/utilities/contents.html|utilities]]. | + | and its vital [[https://pubs.opengroup.org/onlinepubs/9799919799/utilities/contents.html|utilities]]. |
| ==== Accessing the shell ==== | ==== Accessing the shell ==== | ||
| Line 78: | Line 79: | ||
| * terminals bundled with some Linux desktop environment: [[https://docs.xfce.org/apps/terminal/start|xfce4-terminal]], [[https://en.wikipedia.org/wiki/GNOME_Terminal|GNOME Terminal]], [[https://konsole.kde.org/|konsole]] | * terminals bundled with some Linux desktop environment: [[https://docs.xfce.org/apps/terminal/start|xfce4-terminal]], [[https://en.wikipedia.org/wiki/GNOME_Terminal|GNOME Terminal]], [[https://konsole.kde.org/|konsole]] | ||
| * default MacOS [[https://en.wikipedia.org/wiki/Terminal_(macOS)|Terminal]] | * default MacOS [[https://en.wikipedia.org/wiki/Terminal_(macOS)|Terminal]] | ||
| - | * drop-down terminals: [[https://apps.kde.org/yakuake/|yakuake]] / [[http://guake-project.org/|guake]] / [[https://github.com/lanoxx/tilda|tilda]] | + | * drop-down terminals: [[https://apps.kde.org/yakuake/|yakuake]] / [[https://guake.github.io/|guake]] / [[https://github.com/lanoxx/tilda|tilda]] |
| <html></small></html> | <html></small></html> | ||
| Line 102: | Line 103: | ||
| Currently all major operating systems (including Windows) provide ''ssh'' command by default. | Currently all major operating systems (including Windows) provide ''ssh'' command by default. | ||
| - | <html><small></html> | + | <small> |
| Secure SHell encrypts all traffic. Its predecessor – telnet – sends all data (including passwords) in plaintext. | Secure SHell encrypts all traffic. Its predecessor – telnet – sends all data (including passwords) in plaintext. | ||
| - | <html></small></html> | + | Upon password authentication, the client must send the password to the server. |
| + | \\ | ||
| + | It is vital for security to confirm the authenticity of the server – the client | ||
| + | must verify that it does not contact a rogue server that can learn the password | ||
| + | ([[https://docs.ssh-mitm.at/user_guide/authentication.html#id2|ready-to-go tool]]) | ||
| + | and/or hijacks the session. | ||
| + | \\ | ||
| + | [[https://en.wikipedia.org/wiki/Public-key_cryptography|Asymmetric cryptography]] | ||
| + | is used to this end: the server has a (secret) private key, and upon each | ||
| + | connection it sends the public key to the client, and the client verifies whether | ||
| + | the public key pairs with the private. | ||
| + | \\ | ||
| + | Hence, upon the first connection to a new server the SSH client program requests | ||
| + | the user to verify the authenticity of the public key and stores the key (in | ||
| + | OpenSSH in ''~/.ssh/known_hosts'') to verify it automatically upon subsequent | ||
| + | connections. | ||
| + | |||
| + | </small> | ||
| ~~Exercise.#~~ Run a terminal emulator. Execute command ''date'' and ''echo $SHELL'' within. | ~~Exercise.#~~ Run a terminal emulator. Execute command ''date'' and ''echo $SHELL'' within. | ||
| - | ~~Exercise.#~~ Execute command ''sleep 1h'' and interrupt it by pressing //Ctrl + c//. | + | ~~Exercise.#~~ Execute command ''sleep 1h'' and interrupt it by pressing //Ctrl + c//. |
| ~~Exercise.#~~ Switch to second virtual console and log in. Execute ''pwgen''. Return to graphical console. | ~~Exercise.#~~ Switch to second virtual console and log in. Execute ''pwgen''. Return to graphical console. | ||
| Line 213: | Line 231: | ||
| The command **''ls [//dir//]''** lists file in directory ''dir''. When run with no arguments, it lists the current working directory. | The command **''ls [//dir//]''** lists file in directory ''dir''. When run with no arguments, it lists the current working directory. | ||
| \\ | \\ | ||
| - | By default ''ls'' does not list hidden files. The **''-a''** and ''--all'' switch changes this behaviour. | + | By default ''ls'' does not list hidden files. The **''-a''** switch changes this behaviour. |
| \\ | \\ | ||
| - | Switch **''-l''** / ''--list'' prints list of files with details such as file owner, size, modification date, etc. | + | Switch **''-l''** prints list of files with details such as file owner, size, modification date, etc. |
| ~~Exercise.#~~ List files in ''/usr/share/zoneinfo/'' and ''../../../../../bin''. | ~~Exercise.#~~ List files in ''/usr/share/zoneinfo/'' and ''../../../../../bin''. | ||
| Line 256: | Line 274: | ||
| <html></small></html> | <html></small></html> | ||
| + | |||
| + | ==== Wildcard, regex, … ==== | ||
| + | |||
| + | <small> | ||
| + | |||
| + | In computer science patterns/expressions that describe the expected data can be | ||
| + | expressed and used to match against some data, usually to find fitting data or | ||
| + | check if the data matches the description. | ||
| + | \\ | ||
| + | For instance, //lines beginning with a word followed by an equals sign// might | ||
| + | be written as a regular expression ''^\w+=''. | ||
| + | |||
| + | There are countless syntaxes and implementations of such patterns/expressions. | ||
| + | |||
| + | In the shell, [[https://en.wikipedia.org/wiki/Wildcard_character|wildcards]] | ||
| + | and [[https://en.wikipedia.org/wiki/Regular_expression|regular expressions]] | ||
| + | are commonplace. | ||
| + | |||
| + | Syntax and implementation of both wildcards and regexes is language/application | ||
| + | specific. | ||
| + | \\ | ||
| + | The shell uses syntax summarized e.g., in | ||
| + | ''[[https://man7.org/linux/man-pages/man7/glob.7.html|man 7 glob]]'' and | ||
| + | ''[[https://man7.org/linux/man-pages/man7/regex.7.html|man 7 regex]]'' | ||
| + | |||
| + | </small> | ||
| ==== Glob names and wildcards ==== | ==== Glob names and wildcards ==== | ||
| - | Upon parsing the user input, the shell attempts to replace any word containing wildcard characters **''*''**, **''?''** and expressions in square brackets **''[…]''**. A word that contains such wildcards is called [[https://en.wikipedia.org/wiki/Glob_(programming)|glob]]. | + | Upon parsing the user input, the shell attempts to replace with filenames any |
| + | word containing wildcard characters **''*''**, **''?''** and expressions in | ||
| + | square brackets **''[…]''**. A word that contains such wildcards is called | ||
| + | [[https://en.wikipedia.org/wiki/Glob_(programming)|glob]]. | ||
| - | ''*'' expands to any text, ''?'' expand to single character, ''[ace]'' expands to either ''a'', or ''c'', or ''e'', and ''[f-h]'' expands to either ''f'', or ''g'', or ''h''. | + | ''*'' expands to any text\\ |
| + | ''?'' expand to single character\\ | ||
| + | ''[ace]'' expands to either ''a'', or ''c'', or ''e'' \\ | ||
| + | ''[f-h]'' expands to either ''f'', or ''g'', or ''h'' | ||
| If there is at least one file that matches the glob, the shell replaces the glob with all filenames that match. If no file matches, then the glob is left unaltered. | If there is at least one file that matches the glob, the shell replaces the glob with all filenames that match. If no file matches, then the glob is left unaltered. | ||