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/03/01 12:33] – [Command syntax notation] 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 98: | Line 99: | ||
| 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.# | + | ~~Exercise.# |
| + | \\ | ||
| + | < | ||
| ===== Getting help ===== | ===== Getting help ===== | ||
| Line 124: | Line 146: | ||
| ~~Exercise.# | ~~Exercise.# | ||
| - | Usually | + | Usually a program comes together |
| ~~Exercise.# | ~~Exercise.# | ||
| Line 132: | 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.# | ||
| Line 147: | Line 169: | ||
| < | < | ||
| - | For searching within manual there is also the '' | + | For searching within manual there are also the '' |
| Apart from '' | Apart from '' | ||
| Line 213: | Line 235: | ||
| The command **'' | The command **'' | ||
| \\ | \\ | ||
| - | By default '' | + | By default '' |
| \\ | \\ | ||
| - | Switch **'' | + | Switch **'' |
| ~~Exercise.# | ~~Exercise.# | ||
| Line 241: | Line 263: | ||
| To change directory the command **'' | To change directory the command **'' | ||
| \\ | \\ | ||
| - | < | + | < |
| ~~Exercise.# | ~~Exercise.# | ||
| Line 257: | Line 279: | ||
| < | < | ||
| - | ==== Glob names and wildcards ==== | + | ==== Wildcard, regex, … ==== |
| - | + | ||
| - | Upon parsing the user input, the shell attempts to replace any word containing wildcard characters **'' | + | |
| - | + | ||
| - | '' | + | |
| - | + | ||
| - | 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, moving and erasing files ==== | + | |
| - | + | ||
| - | < | + | |
| - | + | ||
| - | To create an empty file, you can use '' | + | |
| - | + | ||
| - | To display a file, use '' | + | |
| - | + | ||
| - | < | + | |
| - | === Directories === | + | < |
| - | **'' | + | 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, |
| - | '' | + | 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, |
| - | . | + | and [[https:// |
| - | ├── foo | + | are commonplace. |
| - | │ ├── baz | + | |
| - | │ │ └── bar | + | |
| - | │ └── bar | + | |
| - | └── foobaz | + | |
| - | └── bar | + | |
| - | + | ||
| - | ~~Exercise.# | + | |
| - | + | ||
| - | === Hard and soft links === | + | |
| - | + | ||
| - | 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) and the file is no longer open in any process. | + | |
| - | + | ||
| - | < | + | |
| - | + | ||
| - | ~~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 '' | + | Syntax and implementation of both wildcards and regexes is language/ |
| + | specific. | ||
| \\ | \\ | ||
| - | 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.1677673999.txt.gz · Last modified: (external edit)