os_cp:intro
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| os_cp:intro [2023/02/27 11:41] – jkonczak | os_cp:intro [2026/03/11 23:57] (current) – [Glob names and wildcards] jkonczak | ||
|---|---|---|---|
| Line 22: | Line 22: | ||
| POSIX - a standard (published by IEEE and The Open Group) for operating system interface and environment, | POSIX - a standard (published by IEEE and The Open Group) for operating system interface and environment, | ||
| - | < | + | < |
| - | GNU/Linux | + | Linux, |
| * [[https:// | * [[https:// | ||
| * the kernel of GNU, [[https:// | * the kernel of GNU, [[https:// | ||
| * 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, | + | * most Linux distributions, |
| + | * some Linux distributions base on free and/or open source software that is neither GNU software nor uses GNU licenses | ||
| - | < | + | </ |
| ==== Shell and vital utilities ==== | ==== Shell and vital utilities ==== | ||
| Line 59: | Line 60: | ||
| * Apple operating systems (e.g. MacOS) ship with modified BSD tools [[https:// | * Apple operating systems (e.g. MacOS) ship with modified BSD tools [[https:// | ||
| * Embedded / resource restrained systems often use [[https:// | * Embedded / resource restrained systems often use [[https:// | ||
| - | * Android uses [[https:// | + | * Android uses [[https:// |
| * For more, see [[https:// | * For more, see [[https:// | ||
| < | < | ||
| - | POSIX standarizes both the [[https:// | + | POSIX standarizes both the [[https:// |
| - | and its vital [[https:// | + | and its vital [[https:// |
| ==== Accessing the shell ==== | ==== Accessing the shell ==== | ||
| Line 78: | Line 79: | ||
| * terminals bundled with some Linux desktop environment: | * terminals bundled with some Linux desktop environment: | ||
| * default MacOS [[https:// | * default MacOS [[https:// | ||
| - | * drop-down terminals: [[https:// | + | * drop-down terminals: [[https:// |
| < | < | ||
| Line 94: | Line 95: | ||
| The basic command to log into a shell on a remote system is: | The basic command to log into a shell on a remote system is: | ||
| \\ | \\ | ||
| - | '' | + | **'' |
| \\ | \\ | ||
| where '' | where '' | ||
| \\ | \\ | ||
| - | For instance, if used '' | + | For instance, if the user '' |
| + | \\ | ||
| + | To terminate a ssh session, one can use either '' | ||
| Currently all major operating systems (including Windows) provide '' | Currently all major operating systems (including Windows) provide '' | ||
| - | < | + | < |
| 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, |
| + | \\ | ||
| + | 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:// | ||
| + | and/or hijack the session. | ||
| + | \\ | ||
| + | [[https:// | ||
| + | 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 '' | ||
| + | connections. | ||
| + | |||
| + | </small> | ||
| ~~Exercise.# | ~~Exercise.# | ||
| + | |||
| + | ~~Exercise.# | ||
| ~~Exercise.# | ~~Exercise.# | ||
| - | ~~Exercise.# | + | ~~Exercise.# |
| + | \\ | ||
| + | < | ||
| ===== Getting help ===== | ===== Getting help ===== | ||
| Line 118: | Line 142: | ||
| ==== System manual and ' | ==== System manual and ' | ||
| - | Most commands will display help when run with '' | + | Most commands will display help when run with **'' |
| ~~Exercise.# | ~~Exercise.# | ||
| - | Usually | + | Usually a program comes together |
| ~~Exercise.# | ~~Exercise.# | ||
| - | |||
| Manual pages are organized into sections. Use '' | Manual pages are organized into sections. Use '' | ||
| Line 131: | Line 154: | ||
| Page names are unique within a section, but there may be pages with the same name in different sections. | Page names are unique within a section, but there may be pages with the same name in different sections. | ||
| \\ | \\ | ||
| - | You may use the '' | + | You may type **'' |
| ~~Exercise.# | ~~Exercise.# | ||
| - | To select a page from a given section, one has to use '' | + | To select a page from a given section, one has to use '' |
| ~~Exercise.# | ~~Exercise.# | ||
| '' | '' | ||
| - | To search for text in '' | + | To search for text in '' |
| ~~Exercise.# | ~~Exercise.# | ||
| Line 146: | Line 169: | ||
| < | < | ||
| - | For searching within manual there is also the '' | + | For searching within manual there are also the '' |
| Apart from '' | Apart from '' | ||
| Line 177: | Line 200: | ||
| For instance, in '' | For instance, in '' | ||
| - | ~~Exercise.# | + | ~~Exercise.# |
| ==== Autocompletion ==== | ==== Autocompletion ==== | ||
| - | Almost any shell supports autocompletion. It is invoked by pressing //TAB// key.\\ | + | Almost any shell supports autocompletion. It is invoked by pressing |
| Autocompletion is supposed to type the rest of a word for you, and does so if only one possibility is found.\\ | Autocompletion is supposed to type the rest of a word for you, and does so if only one possibility is found.\\ | ||
| If autocompletion recognizes multiple possibilities, | If autocompletion recognizes multiple possibilities, | ||
| Line 187: | Line 210: | ||
| Autocompletion implementation differs across shells. Many shells support context-aware helpers. | Autocompletion implementation differs across shells. Many shells support context-aware helpers. | ||
| - | ~~Exercise.# | + | ~~Exercise.# |
| ~~Exercise.# | ~~Exercise.# | ||
| Line 195: | Line 218: | ||
| ==== File tree ==== | ==== File tree ==== | ||
| - | In Unix-like systems all files and directories are organized in a tree, i.e., any two files share the same top-level directory called [[https:// | + | In Unix-like systems all files and directories are organized in a tree, i.e., any two files share the same top-level directory called [[https:// |
| Filesystems other than the root one (e.g., other partitions, compact disks, flash drives), are //mounted// inside a selected directory located within ''/'' | Filesystems other than the root one (e.g., other partitions, compact disks, flash drives), are //mounted// inside a selected directory located within ''/'' | ||
| A path is a chain of names separated by ''/'' | A path is a chain of names separated by ''/'' | ||
| - | '' | + | **'' |
| A path that starts with ''/'' | A path that starts with ''/'' | ||
| Line 205: | Line 228: | ||
| In Unix-like system each process has its working directory. Relative paths are resolved relative to the working directory. | In Unix-like system each process has its working directory. Relative paths are resolved relative to the working directory. | ||
| - | Each user has a [[https:// | + | Each user has a [[https:// |
| ==== Listing directory contents ==== | ==== Listing directory contents ==== | ||
| - | The command '' | + | The command |
| \\ | \\ | ||
| - | By default '' | + | By default '' |
| \\ | \\ | ||
| - | Switch '' | + | Switch |
| ~~Exercise.# | ~~Exercise.# | ||
| Line 234: | Line 257: | ||
| ==== Changing working directory ==== | ==== Changing working directory ==== | ||
| - | To print the working directory one can execute the '' | + | To print the working directory one can execute the **'' |
| ~~Exercise.# | ~~Exercise.# | ||
| - | To change directory the command '' | + | To change directory the command |
| \\ | \\ | ||
| - | < | + | < |
| ~~Exercise.# | ~~Exercise.# | ||
| Line 256: | Line 279: | ||
| < | < | ||
| - | ==== Glob names and wildcards | + | ==== Wildcard, regex, … ==== |
| - | Upon parsing the user input, the shell attempts to replace any word containing wildcard characters '' | + | < |
| - | '' | + | In computer science patterns/expressions |
| - | + | expressed | |
| - | 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. | + | check if the data matches the description. |
| - | + | ||
| - | + | ||
| - | + | ||
| - | ~~Exercise.# | + | |
| - | + | ||
| - | ~~Exercise.# | + | |
| - | + | ||
| - | ~~Exercise.# | + | |
| - | + | ||
| - | ~~Exercise.# | + | |
| - | + | ||
| - | ~~Exercise.# | + | |
| - | + | ||
| - | ~~Exercise.# | + | |
| - | + | ||
| - | < | + | |
| - | + | ||
| - | ~~Exercise.# | + | |
| - | + | ||
| - | ~~Exercise.# | + | |
| - | + | ||
| - | < | + | |
| - | + | ||
| - | + | ||
| - | ==== Copying, moving and erasing files ==== | + | |
| - | + | ||
| - | < | + | |
| - | + | ||
| - | To create an empty file, you can use '' | + | |
| - | + | ||
| - | To display a file, use '' | + | |
| - | + | ||
| - | < | + | |
| - | + | ||
| - | === Directories === | + | |
| - | + | ||
| - | '' | + | |
| \\ | \\ | ||
| - | < | + | For instance, |
| - | '' | + | be written as a regular expression |
| - | With the '' | + | |
| - | < | + | |
| - | To remove an empty directory one can use '' | + | There are countless syntaxes and implementations of such patterns/expressions. |
| - | ~~Exercise.# | + | In the shell, [[https://en.wikipedia.org/ |
| - | | + | and [[https:// |
| - | | + | are commonplace. |
| - | │ ├── baz | + | |
| - | │ │ └── bar | + | |
| - | │ └── bar | + | |
| - | └── foobaz | + | |
| - | └── bar | + | |
| - | + | ||
| - | ~~Exercise.#~~ Remove '' | + | |
| - | === Hard and soft links === | + | Syntax |
| - | + | specific. | |
| - | Multiple directory entries can point to the same file. This is called a [[https:// | + | |
| - | A directory entry can also point to another directory entry. | + | |
| - | + | ||
| - | All Linux filesystems [[https:// | + | |
| - | + | ||
| - | To create a hard link, one can use '' | + | |
| - | To create a symlink, one can use '' | + | |
| - | + | ||
| - | ~~Exercise.# | + | |
| - | + | ||
| - | < | + | |
| - | + | ||
| - | ~~Exercise.# | + | |
| - | + | ||
| - | The disk space used by a file is reclamied once link count drops to 0 (all directory entries that link to the file are erased) | + | |
| - | + | ||
| - | < | + | |
| - | + | ||
| - | ~~Exercise.# | + | |
| - | + | ||
| - | ~~Exercise.# | + | |
| - | + | ||
| - | ~~Exercise.# | + | |
| - | + | ||
| - | < | + | |
| - | + | ||
| - | The '' | + | |
| - | + | ||
| - | The Windows NTFS filesystem supports links as well. Creating the links is possible e.g., with [[https:// | + | |
| - | + | ||
| - | < | + | |
| - | + | ||
| - | === Copying and moving files === | + | |
| - | + | ||
| - | To copy files, one can use the '' | + | |
| - | + | ||
| - | The basic syntax is '' | + | |
| - | Multiple source files can be provided if the destination is a directory. \\ | + | |
| - | If the destination is a file, it will be overwritten without warning < | + | |
| - | + | ||
| - | < | + | |
| - | + | ||
| - | By default '' | + | |
| - | + | ||
| - | < | + | |
| - | + | ||
| - | When '' | + | |
| \\ | \\ | ||
| - | To copy recursively, | + | The shell uses syntax summarized e.g., in |
| + | '' | ||
| + | '' | ||
| - | < | + | </small> |
| - | With the '' | + | ==== Glob names and wildcards ==== |
| - | < | + | Upon parsing the user input, the shell attempts to replace with filenames any |
| + | word containing wildcard characters **'' | ||
| + | square brackets **'' | ||
| + | [[https://en.wikipedia.org/ | ||
| - | ~~Exercise.# | + | '' |
| + | ''?'' | ||
| + | '' | ||
| + | '' | ||
| - | ~~Exercise.#~~ Run '' | + | 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. |
| - | ~~Exercise.# | ||
| - | ~~Exercise.# | ||
| - | ~~Exercise.# | + | ~~Exercise.# |
| - | < | + | ~~Exercise.# |
| - | ~~Exercise.# | + | ~~Exercise.# |
| - | < | + | ~~Exercise.# |
| - | === Copying | + | ~~Exercise.# |
| - | It is possible to copy files via SSH. Whenever one has SSH access to a remote machine, one can copy files with '' | + | ~~Exercise.#~~ List all files starting |
| - | '' | + | |
| - | '' | + | |
| < | < | ||
| - | Microsoft Windows now ships with '' | + | ~~Exercise.# |
| - | < | + | ~~Exercise.# |
| - | + | ||
| - | Most SSH servers enable also the SFTP protocol that allows copying files more conveniently.\\ | + | |
| - | '' | + | |
| - | + | ||
| - | ~~Exercise.# | + | |
| - | + | ||
| - | ~~Exercise.# | + | |
| - | + | ||
| - | ~~Exercise.# | + | |
| - | + | ||
| - | < | + | |
| - | === Rsync === | + | |
| - | + | ||
| - | The '' | + | |
| < | < | ||
| - | |||
| - | === Removing files === | ||
| - | |||
| - | The program that removes files is called '' | ||
| - | |||
| - | '' | ||
| - | |||
| - | To remove a directory with '' | ||
| - | |||
| - | To remove write-protected files (and stop printing warnings whenever a file to be removed already does not exist) the switch '' | ||
| - | |||
| - | A misused '' | ||
| - | |||
| - | '' | ||
| - | |||
| - | ~~Exercise.# | ||
| - | |||
| - | ~~Exercise.# | ||
| - | |||
| - | ~~Exercise.# | ||
os_cp/intro.1677498097.txt.gz · Last modified: (external edit)