diff --git a/docs/books/admin_guide/03-commands.md b/docs/books/admin_guide/03-commands.md index eb1b5d59bf..838509be4f 100644 --- a/docs/books/admin_guide/03-commands.md +++ b/docs/books/admin_guide/03-commands.md @@ -199,7 +199,7 @@ man 5 passwd will inform him about the files related to the command. -Navigate through the manual with the arrows and . Exit the manual by pressing the q key. +Navigate through the manual with the arrows ++arrow-up++ and ++arrow-down++. Exit the manual by pressing the ++q++ key. ### `shutdown` command @@ -252,21 +252,21 @@ To manipulate the history, the following commands entered from the command promp | Keys | Function | | ------------------ | --------------------------------------------------------- | -| !! | Recalls the last command placed. | -| !n | Recalls the command by its number in the list. | -| !string | Recalls the most recent command beginning with the string. | -| | Navigates through your history working backward in time from the most recent command. | -| | Navigates through your history working forward in time. | +| ++exclam+exclam++ | Recalls the last command placed. | +| ++exclam+n++ | Recalls the command by its number in the list. | +| ++exclam+"string"++ | Recalls the most recent command beginning with the string. | +| ++arrow-up++ | Navigates through your history working backward in time from the most recent command. | +| ++arrow-down++ | Navigates through your history working forward in time. | ### Auto-complete Auto-completion is a great help. * Completes commands, entered paths, or file names. -* Press the TAB key to complete the entry in the case of a single solution. -* In the case of multiple solutions, press TAB a second time to see options. +* Press the ++tab++ key to complete the entry in the case of a single solution. +* In the case of multiple solutions, press ++tab++ a second time to see options. -If double-pressing the TAB key presents no options, then there is no solution to the current completion. +If double-pressing the ++tab++ key presents no options, then there is no solution to the current completion. ## Display and Identification @@ -278,7 +278,7 @@ On a physical terminal, the display will be permanently hidden, whereas in a gra !!! Tip - CTRL + L will have the same effect as the `clear` command + ++control+l++ will have the same effect as the `clear` command ### `echo` command @@ -850,7 +850,7 @@ root:x:0:0:root:/root:/bin/bash ... ``` -Using the ENTER key, the move is line by line. Using the SPACE key, the move is page by page. `/text` allows you to search for the occurrence in the file. +Using the ++enter++ key, the move is line by line. Using the ++space++ key, the move is page by page. `/text` allows you to search for the occurrence in the file. ### `less` command @@ -864,14 +864,14 @@ The commands specific to `less` are: | Command | Action | | ----------------- | ----------------------------------------------- | -| h | Help. | -| | Move up, down a line, or to the right or left. | -| Enter | Move down one line. | -| Space | Move down one page. | -| PgUp and PgDn | Move up or down one page. | -| g and G | Move to the first and last pages | +| ++h++ | Help. | +| ++arrow-up++ ++arrow-down++ ++arrow-right++ ++arrow-left++ | Move up, down a line, or to the right or left. | +| ++enter++ | Move down one line. | +| ++space++ | Move down one page. | +| ++page-up++ and ++page-down++ | Move up or down one page. | +| ++"g"++ and ++g++ | Move to the first and last pages | | `/text` | Search for text. | -| q | Quit the `less` command. | +| ++q++ | Quit the `less` command. | ### `cat` command @@ -971,7 +971,7 @@ tcpdump::x:72:72::/:/sbin/nologin user1:x:500:500:grp1:/home/user1:/bin/bash ``` -With the `-f` option, the change information of the file will always be output unless the user exits the monitoring state with CTRL + C. This option is very frequently used to track log files (the logs) in real time. +With the `-f` option, the change information of the file will always be output unless the user exits the monitoring state with ++control+c++. This option is very frequently used to track log files (the logs) in real time. Without the `-n` option, the `tail` command displays the last 10 lines of the file. @@ -1000,7 +1000,7 @@ adm:x:3:4:adm:/var/adm/:/sbin/nologin | `-o file` | Saves the sort to the specified file. | | `-t` | Specify a delimiter, which requires that the contents of the corresponding file must be regularly delimited column contents, otherwise they cannot be sorted properly. | | `-r` | Reverse the order of the result. Used in conjunction with the `-n` option to sort in order from largest to smallest. | -| `-u` | Remove duplicates after sorting. Equivalent to `sort file | uniq`. | +| `-u` | Remove duplicates after sorting. Equivalent to `sort file uniq`. | The `sort` command sorts the file only on the screen. The file is not modified by the sorting. To save the sort, use the `-o` option or an output redirection `>`. @@ -1394,7 +1394,7 @@ When both output streams are redirected, no information is displayed on the scre A **pipe** is a mechanism allowing you to link the standard output of a first command to the standard input of a second command. -This communication is uni directional and is done with the `|` symbol. The pipe symbol `|` is obtained by pressing the SHIFT + | simultaneously. +This communication is uni directional and is done with the `|` symbol. The pipe symbol `|` is obtained by pressing the ++shift+bar++ simultaneously. ![pipe](images/pipe.png) @@ -1596,7 +1596,7 @@ none on /proc/sys/fs/binfmt_misc type binfmt_misc (r The `;` character strings the commands. -The commands will all run sequentially in the order of input once the user presses ENTER. +The commands will all run sequentially in the order of input once the user presses ++enter++. ```bash ls /; cd /home; ls -lia; cd / diff --git a/docs/books/admin_guide/04-advanced-commands.md b/docs/books/admin_guide/04-advanced-commands.md index a215e29578..10fe4410b9 100644 --- a/docs/books/admin_guide/04-advanced-commands.md +++ b/docs/books/admin_guide/04-advanced-commands.md @@ -333,7 +333,7 @@ The `-n` option allows you to specify the number of seconds between each executi !!! Note - To exit the `watch` command, you must type the keys: CTRL+C to kill the process. + To exit the `watch` command, you must type the keys: ++control+c++ to kill the process. Examples: @@ -421,7 +421,7 @@ This command already saves time. Combine it with owner, owner group, and rights sudo install -v -o rocky -g users -m 644 -D -t ~/samples/ src/sample.txt ``` - !!! note +!!! note `sudo` is required in this case to make property changes. diff --git a/docs/books/admin_guide/05-vi.md b/docs/books/admin_guide/05-vi.md index 1fb58fd854..1f1a5033bc 100644 --- a/docs/books/admin_guide/05-vi.md +++ b/docs/books/admin_guide/05-vi.md @@ -74,15 +74,15 @@ At startup, VI is in *commands* mode. !!! Tip - A line of text is ended by pressing ENTER but if the screen is not wide enough, VI makes automatic line breaks, _wrap_ configuration by default. These line breaks may not be desired, this is the _nowrap_ configuration. + A line of text is ended by pressing ++enter++ but if the screen is not wide enough, VI makes automatic line breaks, *wrap* configuration by default. These line breaks may not be desired, this is the *nowrap* configuration. -To exit VI, from the Commands mode, press : then type: +To exit VI, from the Commands mode, press ++colon++ then type: * `q` to exit without saving (*quit*); * `w` to save your work (*write*); * `wq` (*write quit*) or `x` (*eXit*) to save and exit. -In command mode, Click the Z key of uppercase status twice in a row to save and exit. +In command mode, Click the ++z++ key of uppercase status twice in a row to save and exit. To force the exit without confirmation, you must add *!* to the previous commands. @@ -104,7 +104,7 @@ The third mode, *ex*, is a footer command mode from an old text editor. ### The Command Mode -This is the default mode when VI starts up. To access it from any of the other modes, simply press the ESC key. +This is the default mode when VI starts up. To access it from any of the other modes, simply press the ++escape++ key. At this time, all keyboard typing is interpreted as commands and the corresponding actions are executed. These are essentially commands for editing text (copy, paste, undo, ...). @@ -120,7 +120,7 @@ The text is not entered directly into the file but into a buffer zone in the mem This is the file modification mode. To access it, you must first switch to *command* mode, then enter the *ex* command frequently starting with the character `:`. -The command is validated by pressing the ENTER key. +The command is validated by pressing the ++enter++ key. ## Moving the cursor @@ -136,65 +136,65 @@ The cursor is placed under the desired character. * Move one or `n` characters to the left: -, n, h or nh +++arrow-left++, ++n++ ++arrow-left++, ++h++ or ++n++ ++h++ * Move one or `n` characters to the right: -, n, l or nl +++arrow-right++, ++n++ ++arrow-right++, ++l++ or ++n++ ++l++ * Move one or `n` characters up: -, n, k or nk +++arrow-up++, ++n++ ++arrow-up++, ++k++ or ++n++ ++k++ * Move one or `n` characters down: -, n, j or nj +++arrow-down++, ++n++ ++arrow-down++, ++j++ or ++n++ ++j++ * Move to the end of the line: -$ or END +++"$"++ or ++end++ * Move to the beginning of the line: -0 or POS1 +++0++ or ++"POS1"++ ### From the first character of a word Words are made up of letters or numbers. Punctuation characters and apostrophes separate words. -If the cursor is in the middle of a word w moves to the next word, b moves to the beginning of the word. +If the cursor is in the middle of a word ++w++ moves to the next word, ++b++ moves to the beginning of the word. If the line is finished, VI goes automatically to the next line. * Move one or `n` words to the right: -w or nw +++w++ or ++n++ ++w++ * Move one or `n` words to the left: -b or nb +++b++ or ++n++ ++b++ ### From any location on a line * Move to last line of text: -G +++g++ * Move to line `n`: -nG +++n++ ++g++ * Move to the first line of the screen: -H +++h++ * Move to the middle line of the screen: -M +++m++ * Move to the last line of the screen: -L +++l++ ## Inserting text @@ -204,37 +204,37 @@ VI switches to *insert* mode after entering one of these keys. !!! Note - VI switches to *insertion* mode. So you will have to press the ESC key to return to *command* mode. + VI switches to *insertion* mode. So you will have to press the ++escape++ key to return to *command* mode. ### In relation to a character * Inserting text before a character: -i (*insert*) +++"i"++ (*insert*) * Inserting text after a character: -a (*append*) +++"a"++ (*append*) ### In relation to a line * Inserting text at the beginning of a line: -I +++i++ * Inserting text at the end of a line: -A +++a++ ### In relation to the text * Inserting text before a line: -O +++o++ * Inserting text after a line: -o +++"o"++ ## Characters, words and lines @@ -258,41 +258,41 @@ These operations are done in *command* mode. * Delete one or `n` characters: -x or nx +++"x"++ or ++"n"++ ++"x"++ * Replace a character with another: -rcharacter +++"r"+"character"++ * Replace more than one character with others: -RcharactersESC +++r+"characters"+escape++ !!! Note - The R command switches to *replace* mode, which is a kind of *insert* mode. + The ++r++ command switches to *replace* mode, which is a kind of *insert* mode. ### Words * Delete (cut) one or `n` words: -dw or ndw +++"d"+"w"++ or ++"n"+"d"+"w"++ * Copy one or `n` words: -yw or nyw +++"y"+"w"++ or ++"n"+"y"+"w"++ * Paste a word once or `n` times after the cursor: -p or np +++p++ or ++"n"+"p"++ * Paste a word once or `n` times before the cursor: -P or nP +++p++ or ++"n"+p++ * Replace one word: -cw*word*ESC +++c+w+"word"+escape++ !!! Tip @@ -303,65 +303,65 @@ These operations are done in *command* mode. * Delete (cut) one or `n` lines: -dd or ndd +++"d"+"d"++ or ++"n"+"d"+"d"++ * Copy one or `n` lines: -yy or nyy +++"y"+"y"++ or ++"n"+"y"+"y"++ * Paste what has been copied or deleted once or `n` times after the current line: -p or np +++"p"++ or ++"n"+"p"++ * Paste what has been copied or deleted once or `n` times before the current line: -P or nP +++p++ or ++"n"+p++ * Delete (cut) from the beginning of the line to the cursor: -d0 +++"d"+0++ * Delete (cut) from the cursor to the end of the line: -d$ +++"d"+"$"++ * Copy from the beginning of the line to the cursor: -y0 +++"y"+0++ * Copy from the cursor to the end of the line: -y$ +++"y"+"$"++ * Delete (cut) the text from the current line: -dL or dG +++"d"+l++ or ++"d"+g++ * Copy the text from the current line: -yL or yG +++"y"+l++ or ++"y"+g++ ### Cancel an action * Undo the last action: -u +++u++ * Undo the actions on the current line: -U +++U ### Cancel cancellation * Cancel a cancellation -Ctrl+r +++control+r++ ## EX commands -The *Ex* mode allows you to act on the file (saving, layout, options, ...). It is also in *Ex* mode where search and replace commands are entered. The commands are displayed at the bottom of the page and must be validated with the ENTER key. +The *Ex* mode allows you to act on the file (saving, layout, options, ...). It is also in *Ex* mode where search and replace commands are entered. The commands are displayed at the bottom of the page and must be validated with the ++enter++ key. -To switch to *Ex* mode, from *command* mode, type :. +To switch to *Ex* mode, from *command* mode, type ++colon++. ### File line numbers @@ -383,11 +383,11 @@ To switch to *Ex* mode, from *command* mode, type :. * Find the next matching string: -n +++"n"++ * Find the previous matching string: -N +++n++ There are wildcards to facilitate the search in VI. diff --git a/docs/books/admin_guide/07-file-systems.md b/docs/books/admin_guide/07-file-systems.md index ed17f5bc2a..7f3b13adf9 100644 --- a/docs/books/admin_guide/07-file-systems.md +++ b/docs/books/admin_guide/07-file-systems.md @@ -37,12 +37,12 @@ and also discover: Partitioning will allow the installation of several operating systems because it is impossible for them to cohabit on the same logical drive. It also allows the separation of data logically (security, access optimization, etc.). -The partition table, stored in the first sector of the disk (MBR: _Master Boot Record_), records the division of the physical disk into partitioned volumes. +The partition table, stored in the first sector of the disk (MBR: *Master Boot Record*), records the division of the physical disk into partitioned volumes. For **MBR** partition table types, the same physical disk can be divided into a maximum of 4 partitions: -- _Primary partition_ (or main partition) -- _Extended partition_ +- *Primary partition* (or main partition) +- *Extended partition* !!! Warning @@ -74,7 +74,7 @@ In the world of GNU/Linux, everything is a file. For disks, they are recognized The Linux kernel contains drivers for most hardware devices. -What we call _devices_ are the files stored without `/dev`, identifying the different hardware detected by the motherboard. +What we call *devices* are the files stored without `/dev`, identifying the different hardware detected by the motherboard. The service called udev is responsible for applying the naming conventions (rules) and applying them to the devices it detects. @@ -94,7 +94,7 @@ There are at least two commands for partitioning a disk: `fdisk` and `cfdisk`. B The only reason to use `fdisk` is when you want to list all logical devices with the `-l` option. `fdisk` uses MBR partition tables, so it is not supported for **GPT** partition tables and cannot be processed for disks larger than **2TB**. -``` +```bash sudo fdisk -l sudo fdisk -l /dev/sdc sudo fdisk -l /dev/sdc2 @@ -102,11 +102,11 @@ sudo fdisk -l /dev/sdc2 ### `parted` command -The `parted` (_partition editor_) command can partition a disk without the drawbacks of `fdisk`. +The `parted` (*partition editor*) command can partition a disk without the drawbacks of `fdisk`. The `parted` command can be used on the command line or interactively. It also has a recovery function capable of rewriting a deleted partition table. -``` +```bash parted [-l] [device] ``` @@ -124,13 +124,13 @@ The `gparted` command, when run without any arguments, will show an interactive The `cfdisk` command is used to manage partitions. -``` +```bash cfdisk device ``` Example: -``` +```bash $ sudo cfdisk /dev/sda Disk: /dev/sda Size: 16 GiB, 17179869184 bytes, 33554432 sectors @@ -149,7 +149,7 @@ $ sudo cfdisk /dev/sda [ Write ] [ Dump ] ``` -The preparation, without _LVM_, of the physical media goes through five steps: +The preparation, without *LVM*, of the physical media goes through five steps: - Setting up the physical disk; - Partitioning of the volumes (a division of the disk, possibility of installing several systems, ...); @@ -159,15 +159,15 @@ The preparation, without _LVM_, of the physical media goes through five steps: ## Logical Volume Manager (LVM) -**L**ogical **V**olume **M**anager (_LVM_) +**L**ogical **V**olume **M**anager (*LVM*) The partition created by the **standard partition** cannot dynamically adjust the resources of the hard disk, once the partition is mounted, the capacity is completely fixed, this constraint is unacceptable on the server. Although the standard partition can be forcibly expanded or shrunk through certain technical means, it can easily cause data loss. LVM can solve this problem very well. LVM is available under Linux from kernel version 2.4, and its main features are: - More flexible disk capacity; - Online data movement; -- Disks in _stripe_ mode; +- Disks in *stripe* mode; - Mirrored volumes (recopy); -- Volume snapshots (_snapshot_). +- Volume snapshots (*snapshot*). The principle of LVM is very simple: @@ -193,7 +193,7 @@ The disadvantage is that if one of the physical volumes becomes out of order, th !!! note - LVM is only managed by the operating system. Therefore the _BIOS_ needs at least one partition without LVM to boot. + LVM is only managed by the operating system. Therefore the *BIOS* needs at least one partition without LVM to boot. !!! info @@ -204,7 +204,7 @@ The disadvantage is that if one of the physical volumes becomes out of order, th There are several storage mechanisms when storing data to **LV**, two of which are: - Linear volumes; -- Volumes in _stripe_ mode; +- Volumes in *stripe* mode; - Mirrored volumes. ![Linear volumes](images/07-file-systems-005.png) @@ -229,20 +229,20 @@ The main relevant commands are as follows: The `pvcreate` command is used to create physical volumes. It turns Linux partitions (or disks) into physical volumes. -``` +```bash pvcreate [-options] partition ``` Example: -``` +```bash [root]# pvcreate /dev/hdb1 pvcreate -- physical volume « /dev/hdb1 » successfully created ``` You can also use a whole disk (which facilitates disk size increases in virtual environments for example). -``` +```bash [root]# pvcreate /dev/hdb pvcreate -- physical volume « /dev/hdb » successfully created @@ -259,13 +259,13 @@ pvcreate -- physical volume « /dev/hdb » successfully created The `vgcreate` command creates volume groups. It groups one or more physical volumes into a volume group. -``` +```bash vgcreate [option] ``` Example: -``` +```bash [root]# vgcreate volume1 /dev/hdb1 … vgcreate – volume group « volume1 » successfully created and activated @@ -278,13 +278,13 @@ vgcreate – volume group « volume1 » successfully created and activated The `lvcreate` command creates logical volumes. The file system is then created on these logical volumes. -``` +```bash lvcreate -L size [-n name] VG_name ``` Example: -``` +```bash [root]# lvcreate –L 600M –n VolLog1 volume1 lvcreate -- logical volume « /dev/volume1/VolLog1 » successfully created ``` @@ -305,13 +305,13 @@ lvcreate -- logical volume « /dev/volume1/VolLog1 » successfully created The `pvdisplay` command allows you to view information about the physical volumes. -``` +```bash pvdisplay /dev/PV_name ``` Example: -``` +```bash [root]# pvdisplay /dev/PV_name ``` @@ -319,13 +319,13 @@ Example: The `vgdisplay` command allows you to view information about volume groups. -``` +```bash vgdisplay VG_name ``` Example: -``` +```bash [root]# vgdisplay volume1 ``` @@ -333,13 +333,13 @@ Example: The `lvdisplay` command allows you to view information about the logical volumes. -``` +```bash lvdisplay /dev/VG_name/LV_name ``` Example: -``` +```bash [root]# lvdisplay /dev/volume1/VolLog1 ``` @@ -358,7 +358,7 @@ The preparation with LVM of the physical support is broken down into the followi ## Structure of a file system -A _file system_ **FS** is in charge of the following actions: +A *file system* **FS** is in charge of the following actions: - Securing access and modification rights to files; - Manipulating files: create, read, modify, and delete; @@ -371,13 +371,13 @@ The Linux operating system is able to use different file systems (ext2, ext3, ex The `mkfs`(make file system) command allows you to create a Linux file system. -``` +```bash mkfs [-t fstype] filesys ``` Example: -``` +```bash [root]# mkfs -t ext4 /dev/sda1 ``` @@ -447,7 +447,7 @@ A file is managed by its inode number. The size of the inode table determines the maximum number of files the FS can contain. -Information present in the _inode table_ : +Information present in the *inode table* : - Inode number; - File type and access permissions; @@ -482,19 +482,19 @@ In case of errors, solutions are proposed to repair the inconsistencies. After r The `fsck` command is a console-mode integrity check and repair tool for Linux file systems. -``` +```bash fsck [-sACVRTNP] [ -t fstype ] filesys ``` Example: -``` +```bash [root]# fsck /dev/sda1 ``` To check the root partition, it is possible to create a `forcefsck` file and reboot or run `shutdown` with the `-F` option. -``` +```bash [root]# touch /forcefsck [root]# reboot or @@ -517,31 +517,31 @@ By definition, a File System is a tree structure of directories built from a roo Text document, directory, binary, partition, network resource, screen, keyboard, Unix kernel, user program, ... -Linux meets the **FHS** (_Filesystems Hierarchy Standard_) (see `man hier`), which defines the folders' names and roles. +Linux meets the **FHS** (*Filesystems Hierarchy Standard*) (see `man hier`), which defines the folders' names and roles. | Directory | Functionality | Complete word | | ---------- | ---------------------------------------------------------------------------------------------------------------- | ----------------------------- | | `/` | Contains special directories | | | `/boot` | Files related to system startup | | -| `/sbin` | Commands necessary for system startup and repair | _system binaries_ | -| `/bin` | Executables of basic system commands | _binaries_ | +| `/sbin` | Commands necessary for system startup and repair | *system binaries* | +| `/bin` | Executables of basic system commands | *binaries* | | `/usr/bin` | System administration commands | | -| `/lib` | Shared libraries and kernel modules | _libraries_ | -| `/usr` | Saves data resources related to UNIX | _UNIX System Resources_ | -| `/mnt` | Temporary mount point directory | _mount_ | +| `/lib` | Shared libraries and kernel modules | *libraries* | +| `/usr` | Saves data resources related to UNIX | *UNIX System Resources* | +| `/mnt` | Temporary mount point directory | *mount* | | `/media` | For mounting removable media | | | `/misc` | To mount the shared directory of the NFS service. | | | `/root` | Administrator's login directory | | | `/home` | The upper-level directory of a common user's home directory | | -| `/tmp` | The directory containing temporary files | _temporary_ | -| `/dev` | Special device files | _device_ | -| `/etc` | Configuration and script files | _editable text configuration_ | -| `/opt` | Specific to installed applications | _optional_ | -| `/proc` | This is a mount point for the proc filesystem, which provides information about running processes and the kernel | _processes_ | -| `/var` | This directory contains files which may change in size, such as spool and log files | _variables_ | +| `/tmp` | The directory containing temporary files | *temporary* | +| `/dev` | Special device files | *device* | +| `/etc` | Configuration and script files | *editable text configuration* | +| `/opt` | Specific to installed applications | *optional* | +| `/proc` | This is a mount point for the proc filesystem, which provides information about running processes and the kernel | *processes* | +| `/var` | This directory contains files which may change in size, such as spool and log files | *variables* | | `/sys` | Virtual file system, similar to /proc | | | `/run` | That is /var/run | | -| `/srv` | Service Data Directory | _service_ | +| `/srv` | Service Data Directory | *service* | - To mount or unmount at the tree level, you must not be under its mount point. - Mounting on a non-empty directory does not delete the content. It is only hidden. @@ -556,7 +556,7 @@ The `/etc/fstab` file is read at system startup and contains the mounts to be pe Lines are read sequentially (`fsck`, `mount`, `umount`). -``` +```bash /dev/mapper/VolGroup-lv_root / ext4 defaults 1 1 UUID=46….92 /boot ext4 defaults 1 2 /dev/mapper/VolGroup-lv_swap swap swap defaults 0 0 @@ -604,13 +604,13 @@ The `mount -a` command allows you to mount automatically based on the contents o The `mount` command allows you to mount and view the logical drives in the tree. -``` +```bash mount [-option] [device] [directory] ``` Example: -``` +```bash [root]# mount /dev/sda7 /home ``` @@ -631,13 +631,13 @@ Example: The `umount` command is used to unmount logical drives. -``` +```bash umount [-option] [device] [directory] ``` Example: -``` +```bash [root]# umount /home [root]# umount /dev/sda7 ``` @@ -664,7 +664,7 @@ As in any system, it is important to respect the file naming rules to navigate t Groups of words separated by spaces must be enclosed in quotation marks: -``` +```bash [root]# mkdir "working dir" ``` @@ -689,7 +689,7 @@ Examples of file extension agreements: ### Details of a file name -``` +```bash [root]# ls -liah /usr/bin/passwd 266037 -rwsr-xr-x 1 root root 59K mars 22 2019 /usr/bin/passwd 1 2 3 4 5 6 7 8 9 @@ -741,7 +741,7 @@ Shell > ls -ldi /tmp/t1 #### Special files -To communicate with peripherals (hard disks, printers, etc.), Linux uses interface files called special files (_device file_ or _special file_). These files allow the peripherals to identify themselves. +To communicate with peripherals (hard disks, printers, etc.), Linux uses interface files called special files (*device file* or *special file*). These files allow the peripherals to identify themselves. These files are special because they do not contain data but specify the access mode to communicate with the device. @@ -762,12 +762,12 @@ crw------- 1 root root 8, 0 jan 1 1970 /dev/tty0 #### Communication files -These are the pipe (_pipes_) and the _socket_ files. +These are the pipe (*pipes*) and the *socket* files. -- **Pipe files** pass information between processes by FIFO (_First In, First Out_). - One process writes transient information to a _pipe_ file, and another reads it. After reading, the information is no longer accessible. +- **Pipe files** pass information between processes by FIFO (*First In, First Out*). + One process writes transient information to a *pipe* file, and another reads it. After reading, the information is no longer accessible. -- **Socket files** allow bidirectional inter-process communication (on local or remote systems). They use an _inode_ of the file system. +- **Socket files** allow bidirectional inter-process communication (on local or remote systems). They use an *inode* of the file system. #### Link files @@ -783,7 +783,7 @@ Their main features are: | Link types | Description | | -------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | soft link file | Represents a shortcut similar to Windows. It has permission of 777 and points to the original file. When the original file is deleted, the linked file and the original file are displayed in red. | -| Hard link file | Represents the original file. It has the same _ inode_ number as the hard-linked file. They can be updated synchronously, including the contents of the file and when it was modified. Cannot cross partitions, cannot cross file systems. Cannot be used for directories. | +| Hard link file | Represents the original file. It has the same *inode* number as the hard-linked file. They can be updated synchronously, including the contents of the file and when it was modified. Cannot cross partitions, cannot cross file systems. Cannot be used for directories. | Specific examples are as follows: @@ -825,7 +825,7 @@ Linux is a multi-user operating system where the control of access to files is e These controls are functions of: - file access permissions ; -- users (_ugo_ _Users Groups Others_). +- users (*ugo* *Users Groups Others*). ### Basic permissions of files and directories @@ -867,7 +867,7 @@ The description of **directory permissions** is as follows: The display of rights is done with the command `ls -l`. It is the last 9 characters of the block of 10. More precisely 3 times 3 characters. -``` +```bash [root]# ls -l /tmp/myfile -rwxrw-r-x 1 root sys ... /tmp/myfile 1 2 3 4 5 @@ -881,7 +881,7 @@ The display of rights is done with the command `ls -l`. It is the last 9 charact | 4 | File owner | | 5 | Group owner of the file | -By default, the _owner_ of a file is the one who created it. The _group_ of the file is the group of the owner who created the file. The _others_ are those not concerned by the previous cases. +By default, the *owner* of a file is the one who created it. The *group* of the file is the group of the owner who created the file. The *others* are those not concerned by the previous cases. The attributes are changed with the `chmod` command. @@ -891,7 +891,7 @@ Only the administrator and the owner of a file can change the rights of a file. The `chmod` command allows you to change the access permissions to a file. -``` +```bash chmod [option] mode file ``` @@ -903,9 +903,9 @@ chmod [option] mode file The rights of files and directories are not dissociated. For some operations, it will be necessary to know the rights of the directory containing the file. A write-protected file can be deleted by another user as long as the rights of the directory containing it allow this user to perform this operation. -The mode indication can be an octal representation (e.g. `744`) or a symbolic representation ([`ugoa`][`+=-`][`rwxst`]). +The mode indication can be an octal representation (e.g. `744`) or a symbolic representation ([`ugoa`] [`+=-`] [`rwxst`]). -##### Octal (or number)representation: +##### Octal (or number)representation | Number | Description | | :----: | ----------- | @@ -926,7 +926,7 @@ Add the three numbers together to get one user type permission. E.g. **755=rwxr- Sometimes you will see `chmod 4755`. The number 4 here refers to the special permission **set uid**. Special permissions will not be expanded here for the moment, just as a basic understanding. -``` +```bash [root]# ls -l /tmp/fil* -rwxrwx--- 1 root root … /tmp/file1 -rwx--x--- 1 root root … /tmp/file2 @@ -945,7 +945,7 @@ This method can be considered as a "literal" association between a user type, an ![Symbolic method](images/07-file-systems-014.png) -``` +```bash [root]# chmod -R u+rwx,g+wx,o-r /tmp/file1 [root]# chmod g=x,o-r /tmp/file2 [root]# chmod -R o=r /tmp/file3 @@ -955,8 +955,8 @@ This method can be considered as a "literal" association between a user type, an When a file or directory is created, it already has permissions. -- For a directory: `rwxr-xr-x` or _755_. -- For a file: `rw-r-r-` or _644_. +- For a directory: `rwxr-xr-x` or *755*. +- For a file: `rw-r-r-` or *644*. This behavior is defined by the **default mask**. @@ -985,13 +985,13 @@ For a file, the execution rights are removed: The `umask` command allows you to display and modify the mask. -``` +```bash umask [option] [mode] ``` Example: -``` +```bash $ umask 033 $ umask 0033 diff --git a/docs/books/admin_guide/08-process.md b/docs/books/admin_guide/08-process.md index 3b4ddd96ab..2a1a73e3e4 100644 --- a/docs/books/admin_guide/08-process.md +++ b/docs/books/admin_guide/08-process.md @@ -10,13 +10,13 @@ In this chapter, you will learn how to work with processes. **Objectives**: In this chapter, future Linux administrators will learn how to: -:heavy_check_mark: Recognize the `PID` and `PPID` of a process; -:heavy_check_mark: View and search for processes; +:heavy_check_mark: Recognize the `PID` and `PPID` of a process; +:heavy_check_mark: View and search for processes; :heavy_check_mark: Manage processes. :checkered_flag: **process**, **linux** -**Knowledge**: :star: :star: +**Knowledge**: :star: :star: **Complexity**: :star: **Reading time**: 20 minutes @@ -31,17 +31,17 @@ When a program runs, the system will create a process by placing the program dat Each process has: -* a _PID_: _**P**rocess **ID**entifier_, a unique process identifier -* a _PPID_: _**P**arent **P**rocess **ID**entifier_, unique identifier of parent process +* a *PID*: ***P**rocess **ID**entifier*, a unique process identifier +* a *PPID*: ***P**arent **P**rocess **ID**entifier*, unique identifier of parent process By successive filiations, the `init` process is the father of all processes. * A parent process always creates a process * A parent process can have multiple child processes -There is a parent/child relationship between processes. A child process results from the parent calling the _fork()_ primitive and duplicating its code to create a child. The _PID_ of the child is returned to the parent process so that it can talk to it. Each child has its parent's identifier, the _PPID_. +There is a parent/child relationship between processes. A child process results from the parent calling the *fork()* primitive and duplicating its code to create a child. The *PID* of the child is returned to the parent process so that it can talk to it. Each child has its parent's identifier, the *PPID*. -The _PID_ number represents the process at the time of execution. When the process finishes, the number is available again for another process. Running the same command several times will produce a different _PID_ each time. +The *PID* number represents the process at the time of execution. When the process finishes, the number is available again for another process. Running the same command several times will produce a different *PID* each time. @@ -52,12 +52,14 @@ The _PID_ number represents the process at the time of execution. When the proce ## Viewing processes The `ps` command displays the status of running processes. -``` + +```bash ps [-e] [-f] [-u login] ``` Example: -``` + +```bash # ps -fu root ``` @@ -84,7 +86,7 @@ Without an option specified, the `ps` command only displays processes running fr The result is displayed in the following columns: -``` +```bash # ps -ef UID PID PPID C STIME TTY TIME CMD root 1 0 0 Jan01 ? 00:00/03 /sbin/init @@ -103,7 +105,7 @@ root 1 0 0 Jan01 ? 00:00/03 /sbin/init The behavior of the control can be fully customized: -``` +```bash # ps -e --format "%P %p %c %n" --sort ppid --headers PPID PID COMMAND NI 0 1 systemd 0 @@ -123,14 +125,14 @@ The user process: * is started from a terminal associated with a user * accesses resources via requests or daemons -The system process (_daemon_): +The system process (*daemon*): * is started by the system * is not associated with any terminal and is owned by a system user (often `root`) * is loaded at boot time, resides in memory, and is waiting for a call * is usually identified by the letter `d` associated with the process name -System processes are therefore called daemons (_**D**isk **A**nd **E**xecution **MON**itor_). +System processes are therefore called daemons (***D**isk **A**nd **E**xecution **MON**itor*). ## Permissions and rights @@ -192,23 +194,23 @@ The constraints of the asynchronous mode: The `kill` command sends a stop signal to a process. -``` +```bash kill [-signal] PID ``` Example: -``` -$ kill -9 1664 +```bash +kill -9 1664 ``` | Code | Signal | Description | |------|-----------|--------------------------------------------------------| -| `2` | _SIGINT_ | Immediate termination of the process | -| `9` | _SIGKILL_ | Interrupt the process (CTRL + D) | -| `15` | _SIGTERM_ | Clean termination of the process | -| `18` | _SIGCONT_ | Resume the process | -| `19` | _SIGSTOP_ | Suspend the process | +| `2` | *SIGINT* | Immediate termination of the process | +| `9` | *SIGKILL* | Interrupt the process (++control+d++) | +| `15` | *SIGTERM* | Clean termination of the process | +| `18` | *SIGCONT* | Resume the process | +| `19` | *SIGSTOP* | Suspend the process | Signals are the means of communication between processes. The `kill` command sends a signal to a process. @@ -224,14 +226,14 @@ Signals are the means of communication between processes. The `kill` command sen `nohup` allows the launching of a process independently of a connection. -``` +```bash nohup command ``` Example: -``` -$ nohup myprogram.sh 0CTRL + Z keys simultaneously, the synchronous process is temporarily suspended. Access to the prompt is restored after displaying the number of the process that has just been suspended. +By pressing the ++control+z++ keys simultaneously, the synchronous process is temporarily suspended. Access to the prompt is restored after displaying the number of the process that has just been suspended. ### `&` instruction -The `&` statement executes the command asynchronously (the command is then called _job_) and displays the number of _job_. Access to the prompt is then returned. +The `&` statement executes the command asynchronously (the command is then called *job*) and displays the number of *job*. Access to the prompt is then returned. Example: -``` +```bash $ time ls -lR / > list.ls 2> /dev/null & [1] 15430 $ ``` -The _job_ number is obtained during background processing and is displayed in square brackets, followed by the `PID` number. +The *job* number is obtained during background processing and is displayed in square brackets, followed by the `PID` number. ### `fg` and `bg` commands The `fg` command puts the process in the foreground: -``` +```bash $ time ls -lR / > list.ls 2>/dev/null & $ fg 1 time ls -lR / > list.ls 2/dev/null @@ -270,7 +272,7 @@ time ls -lR / > list.ls 2/dev/null while the command `bg` places it in the background: -``` +```bash [CTRL]+[Z] ^Z [1]+ Stopped @@ -279,7 +281,7 @@ $ bg 1 $ ``` -Whether it was put in the background when it was created with the `&` argument or later with the CTRL +Z keys, a process can be brought back to the foreground with the `fg` command and its job number. +Whether it was put in the background when it was created with the `&` argument or later with the ++control+z++ keys, a process can be brought back to the foreground with the `fg` command and its job number. ### `jobs` command @@ -287,7 +289,7 @@ The `jobs` command displays the list of processes running in the background and Example: -``` +```bash $ jobs [1]- Running sleep 1000 [2]+ Running find / > arbo.txt @@ -296,24 +298,26 @@ $ jobs The columns represent: 1. job number -2. the order that the processes run -- a `+` : The process selected by default for the `fg` and `bg` commands when no job number is specified -- a `-` : This process is the next process to take the `+` -3. _Running_ (running process) or _Stopped_ (suspended process) +2. the order that the processes run: + + * a `+` : The process selected by default for the `fg` and `bg` commands when no job number is specified + * a `-` : This process is the next process to take the `+` + +3. *Running* (running process) or *Stopped* (suspended process) 4. the command ### `nice` and `renice` commands The command `nice` allows the execution of a command by specifying its priority. -``` +```bash nice priority command ``` Example: -``` -$ nice -n+15 find / -name "file" +```bash +nice -n+15 find / -name "file" ``` Unlike `root`, a standard user can only reduce the priority of a process. Only values between +0 and +19 will be accepted. @@ -324,15 +328,16 @@ Unlike `root`, a standard user can only reduce the priority of a process. Only v The `renice` command allows you to change the priority of a running process. -``` +```bash renice priority [-g GID] [-p PID] [-u UID] ``` Example: +```bash +renice +15 -p 1664 ``` -$ renice +15 -p 1664 -``` + | Option | Description | |--------|-----------------------------------| | `-g` | `GID` of the process owner group. | @@ -353,7 +358,7 @@ The `renice` command acts on processes already running. It is therefore possible The `top` command displays the processes and their resource consumption. -``` +```bash $ top PID USER PR NI ... %CPU %MEM TIME+ COMMAND 2514 root 20 0 15 5.5 0:01.14 top @@ -374,11 +379,11 @@ The `top` command allows control of the processes in real-time and in interactiv ### `pgrep` and `pkill` commands -The `pgrep` command searches the running processes for a process name and displays the _PID_ matching the selection criteria on the standard output. +The `pgrep` command searches the running processes for a process name and displays the *PID* matching the selection criteria on the standard output. -The `pkill` command will send each process the specified signal (by default _SIGTERM_). +The `pkill` command will send each process the specified signal (by default *SIGTERM*). -``` +```bash pgrep process pkill [option] [-signal] process ``` @@ -387,14 +392,14 @@ Examples: * Get the process number from `sshd`: - ``` - $ pgrep -u root sshd + ```bash + pgrep -u root sshd ``` * Kill all `tomcat` processes: - ``` - $ pkill tomcat + ```bash + pkill tomcat ``` !!! note @@ -403,13 +408,13 @@ Examples: In addition to sending signals to the relevant processes, the `pkill` command can also end the user's connection session according to the terminal number, such as: -``` -$ pkill -t pts/1 +```bash +pkill -t pts/1 ``` ### `killall` command -This command's function is roughly the same as that of the `pkill` command. The usage is —`killall [option] [ -s SIGNAL | -SIGNAL ] NAME`. The default signal is _SIGTERM_. +This command's function is roughly the same as that of the `pkill` command. The usage is —`killall [option] [ -s SIGNAL | -SIGNAL ] NAME`. The default signal is *SIGTERM*. | Options | Description | | :--- | :--- | @@ -419,8 +424,8 @@ This command's function is roughly the same as that of the `pkill` command. The Example: -``` -$ killall tomcat +```bash +killall tomcat ``` ### `pstree` command @@ -472,8 +477,8 @@ Hazard: How can we check for any zombie processes in the current system? -``` -$ ps -lef | awk '{print $2}' | grep Z +```bash +ps -lef | awk '{print $2}' | grep Z ``` These characters may appear in this column: diff --git a/docs/books/admin_guide/09-backups.md b/docs/books/admin_guide/09-backups.md index ef6c72fa8b..3b1d6602dc 100644 --- a/docs/books/admin_guide/09-backups.md +++ b/docs/books/admin_guide/09-backups.md @@ -10,14 +10,14 @@ In this chapter you will learn how to back up and restore your data with Linux. **Objectives**: In this chapter, future Linux administrators will learn how to: -:heavy_check_mark: use the `tar` and `cpio` command to make a backup; -:heavy_check_mark: check their backups and restore data; +:heavy_check_mark: use the `tar` and `cpio` command to make a backup; +:heavy_check_mark: check their backups and restore data; :heavy_check_mark: compress or decompress their backups. :checkered_flag: **backup**, **restore**, **compression** -**Knowledge**: :star: :star: :star: -**Complexity**: :star: :star: +**Knowledge**: :star: :star: :star: +**Complexity**: :star: :star: **Reading time**: 40 minutes @@ -104,13 +104,16 @@ There are many utilities to make backups. The commands we will use here are `tar` and `cpio`. * `tar`: - * easy to use; - * allows adding files to an existing backup. + + 1. easy to use; + 2. allows adding files to an existing backup. + * `cpio`: - * retains owners; - * retains groups, dates and rights; - * skips damaged files; - * entire file system. + + 1. retains owners; + 2. retains groups, dates and rights; + 3. skips damaged files; + 4. entire file system. !!! Note @@ -185,9 +188,9 @@ The default utility for creating backups on UNIX systems is the `tar` command. T #### Estimate the size of a backup -The following command estimates the size in kilobytes of a possible _tar_ file: +The following command estimates the size in kilobytes of a possible *tar* file: -``` +```bash $ tar cf - /directory/to/backup/ | wc -c 20480 $ tar czf - /directory/to/backup/ | wc -c @@ -208,10 +211,10 @@ Here is an example of a naming convention for a `tar` backup, knowing that the d |---------|---------|------------------|----------------------------------------------| | `cvf` | `home` | `home.tar` | `/home` in relative mode, uncompressed form | | `cvfP` | `/etc` | `etc.A.tar` | `/etc` in absolute mode, no compression | -| `cvfz` | `usr` | `usr.tar.gz` | `/usr` in relative mode, _gzip_ compression | -| `cvfj` | `usr` | `usr.tar.bz2` | `/usr` in relative mode, _bzip2_ compression | -| `cvfPz` | `/home` | `home.A.tar.gz` | `home` in absolute mode, _gzip_ compression | -| `cvfPj` | `/home` | `home.A.tar.bz2` | `home` in absolute mode, _bzip2_ compression | +| `cvfz` | `usr` | `usr.tar.gz` | `/usr` in relative mode, *gzip* compression | +| `cvfj` | `usr` | `usr.tar.bz2` | `/usr` in relative mode, *bzip2* compression | +| `cvfPz` | `/home` | `home.A.tar.gz` | `home` in absolute mode, *gzip* compression | +| `cvfPj` | `/home` | `home.A.tar.bz2` | `home` in absolute mode, *bzip2* compression | | … | | | | #### Create a backup @@ -220,17 +223,16 @@ Here is an example of a naming convention for a `tar` backup, knowing that the d Creating a non-compressed backup in relative mode is done with the `cvf` keys: -``` +```bash tar c[vf] [device] [file(s)] ``` Example: -``` +```bash [root]# tar cvf /backups/home.133.tar /home/ ``` - | Key | Description | |-----|--------------------------------------------------------| | `c` | Creates a backup. | @@ -245,20 +247,19 @@ Example: Creating a non-compressed backup explicitly in absolute mode is done with the `cvfP` keys: -``` -$ tar c[vf]P [device] [file(s)] +```bash +tar c[vf]P [device] [file(s)] ``` Example: -``` +```bash [root]# tar cvfP /backups/home.133.P.tar /home/ ``` | Key | Description | |-----|-----------------------------------| -| `P` | Creates a backup in absolute mode. | - +| `P` |Creates a backup in absolute mode. | !!! Warning @@ -268,14 +269,13 @@ Example: Creating a compressed backup with `gzip` is done with the `cvfz` keys: -``` -$ tar cvzf backup.tar.gz dirname/ +```bash +tar cvzf backup.tar.gz dirname/ ``` | Key | Description | |-----|----------------------------------| -| `z` | Compresses the backup in _gzip_. | - +| `z` |Compresses the backup in *gzip*. | !!! Note @@ -289,13 +289,13 @@ $ tar cvzf backup.tar.gz dirname/ Creating a compressed backup with `bzip` is done with the keys `cvfj`: -``` -$ tar cvfj backup.tar.bz2 dirname/ +```bash +tar cvfj backup.tar.bz2 dirname/ ``` | Key | Description | |-----|-----------------------------------| -| `j` | Compresses the backup in _bzip2_. | +| `j` |Compresses the backup in *bzip2*. | !!! Note @@ -307,36 +307,36 @@ Compression, and consequently decompression, will have an impact on resource con Here is a ranking of the compression of a set of text files, from least to most efficient: -- compress (`.tar.Z`) -- gzip (`.tar.gz`) -- bzip2 (`.tar.bz2`) -- lzip (`.tar.lz`) -- xz (`.tar.xz`) +* compress (`.tar.Z`) +* gzip (`.tar.gz`) +* bzip2 (`.tar.bz2`) +* lzip (`.tar.lz`) +* xz (`.tar.xz`) #### Add a file or directory to an existing backup It is possible to add one or more items to an existing backup. -``` +```bash tar {r|A}[key(s)] [device] [file(s)] ``` To add `/etc/passwd` to the backup `/backups/home.133.tar`: -``` +```bash [root]# tar rvf /backups/home.133.tar /etc/passwd ``` Adding a directory is similar. Here add `dirtoadd` to `backup_name.tar`: -``` -$ tar rvf backup_name.tar dirtoadd +```bash +tar rvf backup_name.tar dirtoadd ``` | Key | Description | |-----|----------------------------------------------------------------------------------| -| `r` | Adds one or more files at the end of a direct access media backup (hard disk). | -| `A` | Adds one or more files at the end of a backup on sequential access media (tape). | +| `r` |Adds one or more files at the end of a direct access media backup (hard disk). | +| `A` |Adds one or more files at the end of a backup on sequential access media (tape). | !!! Note @@ -358,26 +358,26 @@ $ tar rvf backup_name.tar dirtoadd Viewing the contents of a backup without extracting it is possible. -``` +```bash tar t[key(s)] [device] ``` -| Key | Description | +| Key |Description | |-----|-------------------------------------------------------| -| `t` | Displays the content of a backup (compressed or not). | +| `t` |Displays the content of a backup (compressed or not). | Examples: -``` -$ tar tvf backup.tar -$ tar tvfz backup.tar.gz -$ tar tvfj backup.tar.bz2 +```bash +tar tvf backup.tar +tar tvfz backup.tar.gz +tar tvfj backup.tar.bz2 ``` -When the number of files in a backup becomes large, it is possible to _pipe_ the result of the `tar` command to a _pager_ (`more`, `less`, `most`, etc.): +When the number of files in a backup becomes large, it is possible to *pipe* the result of the `tar` command to a *pager* (`more`, `less`, `most`, etc.): -``` -$ tar tvf backup.tar | less +```bash +tar tvf backup.tar | less ``` !!! Tip @@ -392,14 +392,14 @@ $ tar tvf backup.tar | less The integrity of a backup can be tested with the `W` key at the time of its creation: -``` -$ tar cvfW file_name.tar dir/ +```bash +tar cvfW file_name.tar dir/ ``` The integrity of a backup can be tested with the key `d` after its creation: -``` -$ tar vfd file_name.tar dir/ +```bash +tar vfd file_name.tar dir/ ``` !!! Tip @@ -419,7 +419,7 @@ $ tar vfd file_name.tar dir/ The `W` key is also used to compare the content of an archive against the filesystem: -``` +```bash $ tar tvfW file_name.tar Verify 1/file1 1/file1: Mod time differs @@ -428,33 +428,33 @@ Verify 1/file2 Verify 1/file3 ``` -The verification with the `W` key cannot be done with a compressed archive. The key `d` must be used: +The verification with the `W` key cannot be done with a compressed archive. The key ++d++ must be used: -``` -$ tar dfz file_name.tgz -$ tar dfj file_name.tar.bz2 +```bash +tar dfz file_name.tgz +tar dfj file_name.tar.bz2 ``` -#### Extract (_untar_) a backup +#### Extract (*untar*) a backup -Extract (_untar_) a ``*.tar`` backup is done with the `xvf` keys: +Extract (*untar*) a ``*.tar`` backup is done with the `xvf` keys: Extract the `etc/exports` file from the `/savings/etc.133.tar` backup into the `etc` directory of the active directory: -``` -$ tar xvf /backups/etc.133.tar etc/exports +```bash +tar xvf /backups/etc.133.tar etc/exports ``` Extract all files from the compressed backup `/backups/home.133.tar.bz2` into the active directory: -``` +```bash [root]# tar xvfj /backups/home.133.tar.bz2 ``` Extract all files from the backup `/backups/etc.133.P.tar` to their original directory: -``` -$ tar xvfP /backups/etc.133.P.tar +```bash +tar xvfP /backups/etc.133.P.tar ``` !!! Warning @@ -463,21 +463,20 @@ $ tar xvfP /backups/etc.133.P.tar Check the contents of the backup. -| Key | Description | +| Key |Description | |------|----------------------------------------------------| -| `x` | Extracts files from the backup, compressed or not. | - +| `x` |Extracts files from the backup, compressed or not. | -Extracting a _tar-gzipped_ (`*.tar.gz`) backup is done with the `xvfz` keys: +Extracting a *tar-gzipped* (`*.tar.gz`) backup is done with the `xvfz` keys: -``` -$ tar xvfz backup.tar.gz +```bash +tar xvfz backup.tar.gz ``` -Extracting a _tar-bzipped_ (`*.tar.bz2`) backup is done with the `xvfj` keys: +Extracting a *tar-bzipped* (`*.tar.bz2`) backup is done with the `xvfj` keys: -``` -$ tar xvfj backup.tar.bz2 +```bash +tar xvfj backup.tar.bz2 ``` !!! Tip @@ -488,52 +487,52 @@ $ tar xvfj backup.tar.bz2 To restore the files in their original directory (key `P` of a `tar xvf`), you must have generated the backup with the absolute path. That is, with the `P` key of a `tar cvf`. -##### Extract only a file from a _tar_ backup +##### Extract only a file from a *tar* backup -To extract a specific file from a _tar_ backup, specify the name of that file at the end of the `tar xvf` command. +To extract a specific file from a *tar* backup, specify the name of that file at the end of the `tar xvf` command. -``` -$ tar xvf backup.tar /path/to/file +```bash +tar xvf backup.tar /path/to/file ``` The previous command extracts only the `/path/to/file` file from the `backup.tar` backup. This file will be restored to the `/path/to/` directory created, or already present, in the active directory. -``` -$ tar xvfz backup.tar.gz /path/to/file -$ tar xvfj backup.tar.bz2 /path/to/file +```bash +tar xvfz backup.tar.gz /path/to/file +tar xvfj backup.tar.bz2 /path/to/file ``` -##### Extract a folder from a backup _tar_ +##### Extract a folder from a backup *tar* To extract only one directory (including its subdirectories and files) from a backup, specify the directory name at the end of the `tar xvf` command. -``` -$ tar xvf backup.tar /path/to/dir/ +```bash +tar xvf backup.tar /path/to/dir/ ``` To extract multiple directories, specify each of the names one after the other: -``` -$ tar xvf backup.tar /path/to/dir1/ /path/to/dir2/ -$ tar xvfz backup.tar.gz /path/to/dir1/ /path/to/dir2/ -$ tar xvfj backup.tar.bz2 /path/to/dir1/ /path/to/dir2/ +```bash +tar xvf backup.tar /path/to/dir1/ /path/to/dir2/ +tar xvfz backup.tar.gz /path/to/dir1/ /path/to/dir2/ +tar xvfj backup.tar.bz2 /path/to/dir1/ /path/to/dir2/ ``` -##### Extract a group of files from a _tar_ backup using regular expressions (_regex_) +##### Extract a group of files from a *tar* backup using regular expressions (*regex*) -Specify a regular expression (_regex_) to extract the files matching the specified selection pattern. +Specify a regular expression (*regex*) to extract the files matching the specified selection pattern. For example, to extract all files with the extension `.conf`: -``` -$ tar xvf backup.tar --wildcards '*.conf' +```bash +tar xvf backup.tar --wildcards '*.conf' ``` keys: - * **--wildcards *.conf** corresponds to files with the extension `.conf`. +* **--wildcards *.conf** corresponds to files with the extension `.conf`. -## _CoPy Input Output_ - `cpio` +## *CoPy Input Output* - `cpio` The `cpio` command allows saving on several successive media without specifying any options. @@ -560,7 +559,7 @@ This list is provided with the commands `find`, `ls` or `cat`. Syntax of the `cpio` command: -``` +```bash [files command |] cpio {-o| --create} [-options] [device] ``` @@ -568,32 +567,32 @@ Example: With a redirection of the output of `cpio`: -``` -$ find /etc | cpio -ov > /backups/etc.cpio +```bash +find /etc | cpio -ov > /backups/etc.cpio ``` Using the name of a backup media: -``` -$ find /etc | cpio -ovF /backups/etc.cpio +```bash +find /etc | cpio -ovF /backups/etc.cpio ``` -The result of the `find` command is sent as input to the `cpio` command via a _pipe_ (character `|`, AltGr + 6). +The result of the `find` command is sent as input to the `cpio` command via a *pipe* (character `|`, ++alt-graph+6++). Here, the `find /etc` command returns a list of files corresponding to the contents of the `/etc` directory (recursively) to the `cpio` command, which performs the backup. Do not forget the `>` sign when saving or the `F save_name_cpio`. -| Options | Description | +| Options |Description | |---------|------------------------------------------------| -| `-o` | Creates a backup (_output_). | -| `-v` | Displays the name of the processed files. | -| `-F` | Designates the backup to be modified (medium). | +| `-o` |Creates a backup (*output*). | +| `-v` |Displays the name of the processed files. | +| `-F` |Designates the backup to be modified (medium). | Backup to a media: -``` -$ find /etc | cpio -ov > /dev/rmt0 +```bash +find /etc | cpio -ov > /dev/rmt0 ``` The media can be of several types: @@ -605,15 +604,15 @@ The media can be of several types: #### Backup with relative path -``` -$ cd / -$ find etc | cpio -o > /backups/etc.cpio +```bash +cd / +find etc | cpio -o > /backups/etc.cpio ``` #### Backup with absolute path -``` -$ find /etc | cpio -o > /backups/etc.A.cpio +```bash +find /etc | cpio -o > /backups/etc.A.cpio ``` !!! Warning @@ -624,14 +623,14 @@ $ find /etc | cpio -o > /backups/etc.A.cpio ### Add to a backup -``` +```bash [files command |] cpio {-o| --create} -A [-options] [device} ``` Example: -``` -$ find /etc/shadow | cpio -o -AF SystemFiles.A.cpio +```bash +find /etc/shadow | cpio -o -AF SystemFiles.A.cpio ``` Adding files is only possible on direct access media. @@ -645,7 +644,7 @@ Adding files is only possible on direct access media. * Save **then** compress -``` +```bash $ find /etc | cpio –o > etc.A.cpio $ gzip /backups/etc.A.cpio $ ls /backups/etc.A.cpio* @@ -654,8 +653,8 @@ $ ls /backups/etc.A.cpio* * Save **and** compress -``` -$ find /etc | cpio –o | gzip > /backups/etc.A.cpio.gz +```bash +find /etc | cpio –o | gzip > /backups/etc.A.cpio.gz ``` There is no option, unlike the `tar` command, to save and compress at the same time. @@ -667,19 +666,19 @@ For the first method, the backup file is automatically renamed by the `gzip` uti ### Read the contents of a backup -Syntax of the `cpio` command to read the contents of a _cpio_ backup: +Syntax of the `cpio` command to read the contents of a *cpio* backup: -``` +```bash cpio -t [-options] [ tmp cpio –iuE tmp -F etc.A.cpio rm -f tmp @@ -777,13 +776,13 @@ The `gzip` command compresses data. Syntax of the `gzip` command: -``` +```bash gzip [options] [file ...] ``` Example: -``` +```bash $ gzip usr.tar $ ls usr.tar.gz @@ -799,13 +798,13 @@ The `bunzip2` command also compresses data. Syntax of the `bzip2` command: -``` +```bash bzip2 [options] [file ...] ``` Example: -``` +```bash $ bzip2 usr.cpio $ ls usr.cpio.bz2 @@ -821,13 +820,13 @@ The `gunzip` command decompresses compressed data. Syntax of the `gunzip` command: -``` +```bash gunzip [options] [file ...] ``` Example: -``` +```bash $ gunzip usr.tar.gz $ ls usr.tar @@ -847,13 +846,13 @@ The `bunzip2` command decompresses compressed data. Syntax of the `bzip2` command: -``` +```bash bzip2 [options] [file ...] ``` Example: -``` +```bash $ bunzip2 usr.cpio.bz2 $ ls usr.cpio diff --git a/docs/books/admin_guide/10-boot.md b/docs/books/admin_guide/10-boot.md index 23843b37c1..27e98c7421 100644 --- a/docs/books/admin_guide/10-boot.md +++ b/docs/books/admin_guide/10-boot.md @@ -9,16 +9,16 @@ In this chapter, you will learn how the system starts. **** **Objectives**: In this chapter, future Linux administrators will learn: -:heavy_check_mark: The different stages of the booting process; -:heavy_check_mark: How Rocky Linux supports this boot by using GRUB2 and systemd; -:heavy_check_mark: How to protect GRUB2 from an attack; -:heavy_check_mark: How to manage the services; +:heavy_check_mark: The different stages of the booting process; +:heavy_check_mark: How Rocky Linux supports this boot by using GRUB2 and systemd; +:heavy_check_mark: How to protect GRUB2 from an attack; +:heavy_check_mark: How to manage the services; :heavy_check_mark: How to access logs from `journald`. :checkered_flag: **users** -**Knowledge**: :star: :star: -**Complexity**: :star: :star: :star: +**Knowledge**: :star: :star: +**Complexity**: :star: :star: :star: **Reading time**: 20 minutes **** @@ -49,7 +49,7 @@ The GRUB 2 configuration file is located under `/boot/grub2/grub.cfg` but this f The GRUB2 menu configuration settings are located under `/etc/default/grub` and are used to generate the `grub.cfg` file. -``` +```bash # cat /etc/default/grub GRUB_TIMEOUT=5 GRUB_DEFAULT=saved @@ -61,7 +61,7 @@ GRUB_DISABLE_RECOVERY="true" If changes are made to one or more of these parameters, the `grub2-mkconfig` command must be run to regenerate the `/boot/grub2/grub.cfg` file. -``` +```bash [root] # grub2-mkconfig –o /boot/grub2/grub.cfg ``` @@ -71,7 +71,8 @@ If changes are made to one or more of these parameters, the `grub2-mkconfig` com ### The kernel The kernel starts the `systemd` process with PID 1. -``` + +```bash root 1 0 0 02:10 ? 00:00:02 /usr/lib/systemd/systemd --switched-root --system --deserialize 23 ``` @@ -104,7 +105,7 @@ To password protect the GRUB2 bootloader: * If a user has not yet been configured, use the `grub2-setpassword` command to provide a password for the root user: -``` +```bash # grub2-setpassword ``` @@ -114,14 +115,14 @@ A `/boot/grub2/user.cfg` file will be created if it was not already present. It This command only supports configurations with a single root user. -``` +```bash [root]# cat /boot/grub2/user.cfg GRUB2_PASSWORD=grub.pbkdf2.sha512.10000.CC6F56....A21 ``` * Recreate the configuration file with the `grub2-mkconfig` command: -``` +```bash [root]# grub2-mkconfig -o /boot/grub2/grub.cfg Generating grub configuration file ... Found linux image: /boot/vmlinuz-3.10.0-327.el7.x86_64 @@ -185,27 +186,27 @@ Service units end with the `.service` file extension and have a similar purpose | systemctl | Description | |-------------------------------------------|-----------------------------------------| -| systemctl start _name_.service | Starts a service | -| systemctl stop _name_.service | Stops a service | -| systemctl restart _name_.service | Restarts a service | -| systemctl reload _name_.service | Reloads a configuration | -| systemctl status _name_.service | Checks if a service is running | -| systemctl try-restart _name_.service | Restarts a service only if it is running | +| systemctl start *name*.service | Starts a service | +| systemctl stop *name*.service | Stops a service | +| systemctl restart *name*.service | Restarts a service | +| systemctl reload *name*.service | Reloads a configuration | +| systemctl status *name*.service | Checks if a service is running | +| systemctl try-restart *name*.service | Restarts a service only if it is running | | systemctl list-units --type service --all | Displays the status of all services | The `systemctl` command is also used for the `enable` or `disable` of system a service and displaying associated services: | systemctl | Description | |------------------------------------------|---------------------------------------------------------| -| systemctl enable _name_.service | Activates a service | -| systemctl disable _name_.service | Disables a service | +| systemctl enable *name*.service | Activates a service | +| systemctl disable *name*.service | Disables a service | | systemctl list-unit-files --type service | Lists all services and checks if they are running | | systemctl list-dependencies --after | Lists the services that start before the specified unit | | systemctl list-dependencies --before | Lists the services that start after the specified unit | Examples: -``` +```bash systemctl stop nfs-server.service # or systemctl stop nfs-server @@ -213,24 +214,24 @@ systemctl stop nfs-server To list all units currently loaded: -``` +```bash systemctl list-units --type service ``` To list all units to check if they are activated: -``` +```bash systemctl list-unit-files --type service ``` -``` +```bash systemctl enable httpd.service systemctl disable bluetooth.service ``` ### Example of a .service file for the postfix service -``` +```bash postfix.service Unit File What follows is the content of the /usr/lib/systemd/system/postfix.service unit file as currently provided by the postfix package: @@ -275,20 +276,20 @@ Similarly, the `multi-user.target` unit starts other essential system services, To determine which target is used by default: -``` +```bash systemctl get-default ``` This command searches for the target of the symbolic link located at `/etc/systemd/system/default.target` and displays the result. -``` +```bash $ systemctl get-default graphical.target ``` The `systemctl` command can also provide a list of available targets: -``` +```bash systemctl list-units --type target UNIT LOAD ACTIVE SUB DESCRIPTION basic.target loaded active active Basic System @@ -314,13 +315,13 @@ timers.target loaded active active Timers To configure the system to use a different default target: -``` +```bash systemctl set-default name.target ``` Example: -``` +```bash # systemctl set-default multi-user.target rm '/etc/systemd/system/default.target' ln -s '/usr/lib/systemd/system/multi-user.target' '/etc/systemd/system/default.target' @@ -328,7 +329,7 @@ ln -s '/usr/lib/systemd/system/multi-user.target' '/etc/systemd/system/default.t To switch to a different target unit in the current session: -``` +```bash systemctl isolate name.target ``` @@ -340,7 +341,7 @@ On Rocky 8, the `rescue mode` is equivalent to the old `single user mode` and re To change the current target and enter `rescue mode` in the current session: -``` +```bash systemctl rescue ``` @@ -348,7 +349,7 @@ systemctl rescue To change the current target and enter emergency mode in the current session: -``` +```bash systemctl emergency ``` @@ -377,7 +378,7 @@ The format of the native log file, which is a structured and indexed binary file The `journalctl` command displays the log files. -``` +```bash journalctl ``` @@ -392,7 +393,7 @@ The command lists all log files generated on the system. The structure of this o With continuous display, log messages are displayed in real time. -``` +```bash journalctl -f ``` @@ -402,7 +403,7 @@ This command returns a list of the ten most recent log lines. The journalctl uti It is possible to use different filtering methods to extract information that fits different needs. Log messages are often used to track erroneous behavior on the system. To view entries with a selected or higher priority: -``` +```bash journalctl -p priority ``` diff --git a/docs/books/admin_guide/11-tasks.md b/docs/books/admin_guide/11-tasks.md index a418c32728..38225e4abb 100644 --- a/docs/books/admin_guide/11-tasks.md +++ b/docs/books/admin_guide/11-tasks.md @@ -10,8 +10,8 @@ In this chapter you will learn how to manage scheduled tasks. **Objectives**: In this chapter, future Linux administrators will learn how to: -:heavy_check_mark: Linux deals with the tasks scheduling; -:heavy_check_mark: restrict the use of **`cron`** to certain users; +:heavy_check_mark: Linux deals with the tasks scheduling; +:heavy_check_mark: restrict the use of **`cron`** to certain users; :heavy_check_mark: schedule tasks. :checkered_flag: **crontab**, **crond**, **scheduling**, **linux** @@ -48,7 +48,7 @@ The `cron` service is run by a `crond` daemon present in memory. To check its status: -``` +```bash [root] # systemctl status crond ``` @@ -58,13 +58,13 @@ To check its status: Initialization of the `crond` daemon in manual: -``` +```bash [root]# systemctl {status|start|restart|stop} crond ``` Initialization of the `crond` daemon at startup: -``` +```bash [root]# systemctl enable crond ``` @@ -105,15 +105,16 @@ By default, `/etc/cron.deny` exists and is empty and `/etc/cron.allow` does not Only **user1** will be able to use `cron`. -``` +```bash [root]# vi /etc/cron.allow user1 ``` ### Prohibit a user + Only **user2** will not be able to use `cron`. -``` +```bash [root]# vi /etc/cron.deny user2 ``` @@ -132,17 +133,17 @@ This file contains all the information the `crond` needs to know regarding all t The `crontab` command is used to manage the schedule file. -``` +```bash crontab [-u user] [-e | -l | -r] ``` Example: -``` +```bash [root]# crontab -u user1 -e ``` -| Option | Description | +| Option |Description | |--------|-----------------------------------------------------------| | `-e` | Edits the schedule file with vi | | `-l` | Displays the contents of the schedule file | @@ -184,7 +185,7 @@ The `crontab` file is structured according to the following rules. * Each line ends with a carriage return; * A `#` at the beginning of the line comments it. -``` +```bash [root]# crontab –e 10 4 1 * * /root/scripts/backup.sh 1 2 3 4 5 6 @@ -216,25 +217,25 @@ Examples: Script executed on April 15 at 10:25 am: -``` +```bash 25 10 15 04 * /root/scripts/script > /log/… ``` Run at 11am and then at 4pm every day: -``` +```bash 00 11,16 * * * /root/scripts/script > /log/… ``` Run every hour from 11am to 4pm every day: -``` +```bash 00 11-16 * * * /root/scripts/script > /log/… ``` Run every 10 minutes during working hours: -``` +```bash */10 8-17 * * 1-5 /root/scripts/script > /log/… ``` @@ -253,12 +254,12 @@ For the root user, `crontab` also has some special time settings: A user, rockstar, wants to edit his `crontab` file: -1) `crond` checks to see if he is allowed (`/etc/cron.allow` and `/etc/cron.deny`). +1. `crond` checks to see if he is allowed (`/etc/cron.allow` and `/etc/cron.deny`). -2) If he is, he accesses his `crontab` file (`/var/spool/cron/rockstar`). +2. If he is, he accesses his `crontab` file (`/var/spool/cron/rockstar`). -Every minute `crond` reads the schedule files. + Every minute `crond` reads the schedule files. -3) It executes the scheduled tasks. +3. It executes the scheduled tasks. -4) It reports systematically in a log file (`/var/log/cron`). +4. It reports systematically in a log file (`/var/log/cron`). diff --git a/docs/books/admin_guide/12-network.md b/docs/books/admin_guide/12-network.md index 861c0e7662..5ebb3d9d41 100644 --- a/docs/books/admin_guide/12-network.md +++ b/docs/books/admin_guide/12-network.md @@ -11,9 +11,9 @@ In this chapter you will learn how to work with and manage the network. **Objectives**: In this chapter you will learn how to: :heavy_check_mark: Configure a workstation to use DHCP; -:heavy_check_mark: Configure a workstation to use a static configuration; -:heavy_check_mark: Configure a workstation to use a gateway; -:heavy_check_mark: Configure a workstation to use DNS servers; +:heavy_check_mark: Configure a workstation to use a static configuration; +:heavy_check_mark: Configure a workstation to use a gateway; +:heavy_check_mark: Configure a workstation to use DNS servers; :heavy_check_mark: Troubleshoot the network of a workstation. :checkered_flag: **network**, **linux**, **ip** @@ -45,9 +45,9 @@ The minimum parameters to be defined for the machine are: Example: -* `pc-rocky`; -* `192.168.1.10`; -* `255.255.255.0`. +* `pc-rocky`; +* `192.168.1.10`; +* `255.255.255.0`. The notation called CIDR is more and more frequent: 192.168.1.10/24 @@ -103,7 +103,7 @@ In order for a computer to be part of a DNS domain, it must be given a DNS suffi !!! Note "Memory aid" - To remember the order of the layers of the OSI model, remember the following sentence: __Please Do Not Touch Steven's Pet Alligator__. + To remember the order of the layers of the OSI model, remember the following sentence: **Please Do Not Touch Steven's Pet Alligator**. | Layer | Protocoles | |-------------------|----------------------------------------------| @@ -170,7 +170,7 @@ Forget the old `ifconfig` command! Think `ip`! The `hostname` command displays or sets the host name of the system -``` +```bash hostname [-f] [hostname] ``` @@ -187,7 +187,7 @@ To assign a host name, it is possible to use the `hostname` command, but the cha To set the host name, the file `/etc/sysconfig/network` must be modified: -``` +```bash NETWORKING=yes HOSTNAME=pc-rocky.mondomaine.lan ``` @@ -208,13 +208,13 @@ It is therefore essential to fill in these two files before any configuration of The `/etc/hosts` file is a static host name mapping table, which follows the following format: -``` +```bash @IP [alias] [# comment] ``` Example of `/etc/hosts` file: -``` +```bash 127.0.0.1 localhost localhost.localdomain ::1 localhost localhost.localdomain 192.168.1.10 rockstar.rockylinux.lan rockstar @@ -236,7 +236,7 @@ The **NSS** (**N**ame **S**ervice **S**witch) allows configuration files (e.g., The `/etc/nsswitch.conf` file is used to configure the name service databases. -``` +```bash passwd: files shadow: files group: files @@ -254,7 +254,7 @@ The resolution of the name service can be tested with the `getent` command that The `/etc/resolv.conf` file contains the DNS name resolution configuration. -``` +```bash #Generated by NetworkManager domain mondomaine.lan search mondomaine.lan @@ -275,25 +275,25 @@ The `ip` command from the `iproute2` package allows you to configure an interfac Display interfaces: -``` +```bash [root]# ip link ``` Display interfaces information: -``` +```bash [root]# ip addr show ``` Display the information of an interface: -``` +```bash [root]# ip addr show eth0 ``` Display the ARP table: -``` +```bash [root]# ip neigh ``` @@ -307,34 +307,34 @@ The configuration of interfaces under Rocky Linux is done in the `/etc/sysconfig For each Ethernet interface, a `ifcfg-ethX` file allows for the configuration of the associated interface. -``` +```bash DEVICE=eth0 ONBOOT=yes BOOTPROTO=dhcp HWADDR=00:0c:29:96:32:e3 ``` -* Interface name: (must be in the file name) +* Interface name: (must be in the file name) -``` +```bash DEVICE=eth0 ``` * Automatically start the interface: -``` +```bash ONBOOT=yes ``` * Make a DHCP request when the interface starts up: -``` +```bash BOOTPROTO=dhcp ``` * Specify the MAC address (optional but useful when there are several interfaces): -``` +```bash HWADDR=00:0c:29:96:32:e3 ``` @@ -344,7 +344,7 @@ HWADDR=00:0c:29:96:32:e3 * Restart the network service: -``` +```bash [root]# systemctl restart NetworkManager ``` @@ -352,7 +352,7 @@ HWADDR=00:0c:29:96:32:e3 The static configuration requires at least: -``` +```bash DEVICE=eth0 ONBOOT=yes BOOTPROTO=none @@ -362,25 +362,25 @@ NETMASK=255.255.255.0 * Here we are replacing "dhcp" with "none" which equals static configuration: -``` +```bash BOOTPROTO=none ``` * IP Address: -``` +```bash IPADDR=192.168.1.10 ``` * Subnet mask: -``` +```bash NETMASK=255.255.255.0 ``` * The mask can be specified with a prefix: -``` +```bash PREFIX=24 ``` @@ -392,7 +392,7 @@ PREFIX=24 ![Network architecture with a gateway](images/network-002.png) -``` +```bash DEVICE=eth0 ONBOOT=yes BOOTPROTO=none @@ -404,7 +404,7 @@ GATEWAY=192.168.1.254 The `ip route` command: -``` +```bash [root]# ip route show 192.168.1.0/24 dev eth0 […] src 192.168.1.10 metric 1 default via 192.168.1.254 dev eth0 proto static @@ -422,23 +422,23 @@ A system needs to resolve: * FQDNs into IP addresses -``` +```bash www.free.fr = 212.27.48.10 ``` * IP addresses into names -``` +```bash 212.27.48.10 = www.free.fr ``` * or to obtain information about an area: -``` +```bash MX de free.fr = 10 mx1.free.fr + 20 mx2.free.fr ``` -``` +```bash DEVICE=eth0 ONBOOT=yes BOOTPROTO=none @@ -453,7 +453,7 @@ DOMAIN=rockylinux.lan In this case, to reach the DNS, you have to go through the gateway. -``` +```bash #Generated by NetworkManager domain mondomaine.lan search mondomaine.lan @@ -471,7 +471,7 @@ It is the basic command for testing the network because it checks the connectivi Syntax of the `ping` command: -``` +```bash ping [-c numerical] destination ``` @@ -479,7 +479,7 @@ The `-c` (count) option allows you to stop the command after the countdown in se Example: -``` +```bash [root]# ping –c 4 localhost ``` @@ -487,41 +487,41 @@ Example: Validate connectivity from near to far -1) Validate the TCP/IP software layer +1. Validate the TCP/IP software layer -``` -[root]# ping localhost -``` + ```bash + [root]# ping localhost + ``` -"Pinging" the inner loop does not detect a hardware failure on the network interface. It simply determines whether the IP software configuration is correct. + "Pinging" the inner loop does not detect a hardware failure on the network interface. It simply determines whether the IP software configuration is correct. -2) Validate the network card +2. Validate the network card -``` -[root]# ping 192.168.1.10 -``` + ```bash + [root]# ping 192.168.1.10 + ``` -To determine that the network card is functional, we must now ping its IP address. The network card, if the network cable is not connected, should be in a "down" state. + To determine that the network card is functional, we must now ping its IP address. The network card, if the network cable is not connected, should be in a "down" state. -If the ping does not work, first check the network cable to your network switch and reassemble the interface (see the `if up` command), then check the interface itself. + If the ping does not work, first check the network cable to your network switch and reassemble the interface (see the `if up` command), then check the interface itself. -3) Validate the connectivity of the gateway +3. Validate the connectivity of the gateway -``` -[root]# ping 192.168.1.254 -``` + ```bash + [root]# ping 192.168.1.254 + ``` -4) Validate the connectivity of a remote server +4. Validate the connectivity of a remote server -``` -[root]# ping 172.16.1.2 -``` + ```bash + [root]# ping 172.16.1.2 + ``` -5) Validate the DNS service +5. Validate the DNS service -``` -[root]# ping www.free.fr -``` + ```bash + [root]# ping www.free.fr + ``` ### `dig` command @@ -529,13 +529,13 @@ The `dig` command is used to query the DNS server. The `dig` command syntax: -``` +```bash dig [-t type] [+short] [name] ``` Examples: -``` +```bash [root]# dig +short rockylinux.org 76.223.126.88 [root]# dig -t MX +short rockylinux.org  ✔ @@ -553,14 +553,13 @@ The `getent` (get entry) command is used to get an NSSwitch entry (`hosts` + `dn Syntax of the `getent` command: - -``` +```bash getent hosts name ``` Example: -``` +```bash [root]# getent hosts rockylinux.org 76.223.126.88 rockylinux.org ``` @@ -575,13 +574,13 @@ The `ipcalc` (**ip calculation**) command is used to calculate the address of a Syntax of the `ipcalc` command: -``` +```bash ipcalc [options] IP ``` Example: -``` +```bash [root]# ipcalc –b 172.16.66.203 255.255.240.0 BROADCAST=172.16.79.255 ``` @@ -616,13 +615,13 @@ The `ss` (**socket statistics**) command displays the listening ports on the net Syntax of the `ss` command: -``` +```bash ss [-tuna] ``` Example: -``` +```bash [root]# ss –tuna tcp LISTEN 0 128 *:22 *:* ``` @@ -641,13 +640,13 @@ The `netstat` command (**network statistics**) displays the listening ports on t Syntax of the `netstat` command: -``` +```bash netstat -tapn ``` Example: -``` +```bash [root]# netstat –tapn tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 2161/sshd ``` @@ -658,13 +657,13 @@ A misconfiguration can cause multiple interfaces to use the same IP address. Thi When the network is malfunctioning, and when an IP address conflict could be the cause, it is possible to use the `arp-scan` software (requires the EPEL repository): -``` -$ dnf install arp-scan +```bash +dnf install arp-scan ``` Example: -``` +```bash $ arp-scan -I eth0 -l 172.16.1.104 00:01:02:03:04:05 3COM CORPORATION @@ -686,39 +685,39 @@ $ arp-scan -I eth0 -l The `ip` command can hot add an IP address to an interface -``` +```bash ip addr add @IP dev DEVICE ``` Example: -``` +```bash [root]# ip addr add 192.168.2.10 dev eth1 ``` The `ip` command allows for the activation or deactivation of an interface: -``` +```bash ip link set DEVICE up ip link set DEVICE down ``` Example: -``` +```bash [root]# ip link set eth1 up [root]# ip link set eth1 down ``` The `ip` command is used to add a route: -``` +```bash ip route add [default|netaddr] via @IP [dev device] ``` Example: -``` +```bash [root]# ip route add default via 192.168.1.254 [root]# ip route add 192.168.100.0/24 via 192.168.2.254 dev eth1 ``` @@ -731,7 +730,7 @@ The files used in this chapter are: A complete interface configuration could be this (file `/etc/sysconfig/network-scripts/ifcfg-eth0`): -``` +```bash DEVICE=eth0 ONBOOT=yes BOOTPROTO=none diff --git a/docs/books/admin_guide/13-softwares.md b/docs/books/admin_guide/13-softwares.md index 43a2b7c51c..2e3a58fec7 100644 --- a/docs/books/admin_guide/13-softwares.md +++ b/docs/books/admin_guide/13-softwares.md @@ -166,7 +166,6 @@ Only the short name of the package is required. | `info` | Displays the package information. | | `autoremove` | Removes all packages installed as dependencies but no longer needed. | - The `dnf install` command allows you to install the desired package without worrying about its dependencies, which will be resolved directly by `dnf` itself. ```bash @@ -230,7 +229,6 @@ nginx-mod-mail.aarch64 : Nginx mail modules nginx-mod-stream.aarch64 : Nginx stream modules ``` - The `dnf remove` command removes a package from the system and its dependencies. Below is an excerpt of the **dnf remove httpd** command. ```bash @@ -258,13 +256,13 @@ Removing unused dependencies: The `dnf list` command lists all the packages installed on the system and present in the repository. It accepts several parameters: -| Parameter | Description | -|-------------|----------------------------------------------------------------------------| -| `all` | Lists the installed packages and then those available on the repositories. | -| `available` | Lists only the packages available for installation. | -| `updates` | Lists packages that can be upgraded. | -| `obsoletes` | Lists the packages made obsolete by higher versions available. | -| `recent` | Lists the latest packages added to the repository. | +| Parameter |Description | +|-------------|---------------------------------------------------------------------------| +| `all` |Lists the installed packages and then those available on the repositories. | +| `available` |Lists only the packages available for installation. | +| `updates` |Lists packages that can be upgraded. | +| `obsoletes` |Lists the packages made obsolete by higher versions available. | +| `recent` |Lists the latest packages added to the repository. | The `dnf info` command, as you might expect, provides detailed information about a package: @@ -494,7 +492,6 @@ The `dnf clean` command cleans all caches and temporary files created by `dnf`. | `metadata` | Removes all the repositories metadata. | | `packages` | Removes any cached packages. | - ### How DNF works The DNF manager relies on one or more configuration files to target the repositories containing the RPM packages. @@ -511,7 +508,7 @@ Each `.repo` file consists of at least the following information, one directive Example: -``` +```bash [baseos] # Short name of the repository name=Rocky Linux $releasever - BaseOS # Short name of the repository #Detailed name mirrorlist=http://mirrors.rockylinux.org/mirrorlist?arch=$basearch&repo=BaseOS-$releasever # http address of a list or mirror @@ -543,19 +540,19 @@ Modules come from the AppStream repository and contain both streams and profiles You can obtain a list of all modules by executing the following command: -``` +```bash dnf module list ``` This will give you a long list of the available modules and the profiles that can be used for them. The thing is you probably already know what package you are interested in, so to find out if there are modules for a particular package, add the package name after "list". We will use our `postgresql` package example again here: -``` +```bash dnf module list postgresql ``` This will give you output that looks like this: -``` +```bash Rocky Linux 8 - AppStream Name Stream Profiles Summary postgresql 9.6 client, server [d] PostgreSQL server and client module @@ -570,7 +567,7 @@ Notice in the listing the "[d]". This means that this is the default. It shows t Using our example `postgresql` package, let's say that we want to enable version 12. To do this, you simply use the following: -``` +```bash dnf module enable postgresql:12 ``` @@ -578,7 +575,7 @@ Here the enable command requires the module name followed by a ":" and the strea To verify that you have enabled `postgresql` module stream version 12, use your list command again which should show you the following output: -``` +```bash Rocky Linux 8 - AppStream Name Stream Profiles Summary postgresql 9.6 client, server [d] PostgreSQL server and client module @@ -593,13 +590,13 @@ Here we can see the "[e]" for "enabled" next to stream 12, so we know that versi Now that our module stream is enabled, the next step is to install `postgresql`, the client application for the postgresql server. This can be achieved by running the following command: -``` +```bash dnf install postgresql ``` Which should give you this output: -``` +```bash ======================================================================================================================================== Package Architecture Version Repository Size ======================================================================================================================================== @@ -622,13 +619,13 @@ After approving by typing "y" you installed the application. It's also possible to directly install packages without even having to enable the module stream! In this example, let's assume that we only want the client profile applied to our installation. To do this, we simply enter this command: -``` +```bash dnf install postgresql:12/client ``` Which should give you this output: -``` +```bash ======================================================================================================================================== Package Architecture Version Repository Size ======================================================================================================================================== @@ -656,7 +653,7 @@ Answering "y" to the prompt will install everything you need to use postgresql v After you install, you may decide that for whatever reason, you need a different version of the stream. The first step is to remove your packages. Using our example `postgresql` package again, we would do this with: -``` +```bash dnf remove postgresql ``` @@ -664,13 +661,13 @@ This will display similar output as the install procedure above, except it will Once this step is complete, you can issue the reset command for the module using: -``` +```bash dnf module reset postgresql ``` Which will give you output like this: -``` +```bash Dependencies resolved. ======================================================================================================================================== Package Architecture Version Repository Size @@ -688,7 +685,7 @@ Is this ok [y/N]: Answering "y" to the prompt will then reset `postgresql` back to the default stream with the stream that we had enabled (12 in our example) no longer enabled: -``` +```bash Rocky Linux 8 - AppStream Name Stream Profiles Summary postgresql 9.6 client, server [d] PostgreSQL server and client module @@ -701,7 +698,7 @@ Now you can use the default. You can also use the switch-to sub-command to switch from one enabled stream to another. Using this method not only switches to the new stream, but installs the needed packages (either downgrade or upgrade) without a separate step. To use this method to enable `postgresql` stream version 13 and use the "client" profile, you would use: -``` +```bash dnf module switch-to postgresql:13/client ``` @@ -711,13 +708,13 @@ There may be times when you wish to disable the ability to install packages from To disable the module streams for `postgresql` simply do: -``` +```bash dnf module disable postgresql ``` And if you list out the `postgresql` modules again, you will see the following showing all `postgresql` module versions disabled: -``` +```bash Rocky Linux 8 - AppStream Name Stream Profiles Summary postgresql 9.6 [x] client, server [d] PostgreSQL server and client module @@ -799,7 +796,7 @@ epel-modular Extra Packages for Enterprise Linux Modular 8 - aarch64 The repository configuration files are located in `/etc/yum.repos.d/`. -``` +```bash ll /etc/yum.repos.d/ | grep epel -rw-r--r--. 1 root root 1485 Jan 31 17:19 epel-modular.repo -rw-r--r--. 1 root root 1422 Jan 31 17:19 epel.repo @@ -911,7 +908,7 @@ The `dnf-plugins-core` package adds plugins to `dnf` that will be useful for man Install the package on your system: -``` +```bash dnf install dnf-plugins-core ``` @@ -925,26 +922,26 @@ Examples: * Download a `.repo` file and use it: -``` +```bash dnf config-manager --add-repo https://packages.centreon.com/ui/native/rpm-standard/23.04/el8/centreon-23.04.repo ``` * You can also set an url as a base url for a repo: -``` +```bash dnf config-manager --add-repo https://repo.rocky.lan/repo ``` * Enable or disable one or more repos: -``` +```bash dnf config-manager --set-enabled epel centreon dnf config-manager --set-disabled epel centreon ``` * Add a proxy to your config file: -``` +```bash dnf config-manager --save --setopt=*.proxy=http://proxy.rocky.lan:3128/ ``` @@ -954,7 +951,7 @@ dnf config-manager --save --setopt=*.proxy=http://proxy.rocky.lan:3128/ * Activate a copr repo: -``` +```bash copr enable xxxx ``` @@ -962,19 +959,19 @@ copr enable xxxx Download rpm package instead of installing it: -``` +```bash dnf download ansible ``` If you just want to obtain the remote location url of the package: -``` +```bash dnf download --url ansible ``` Or if you want to also download the dependencies: -``` +```bash dnf download --resolv --alldeps ansible ``` @@ -984,7 +981,7 @@ After running a `dnf update`, the running processes will continue to run but wit The `needs-restarting` plugin will allow you to detect processes that are in this case. -``` +```bash dnf needs-restarting [-u] [-r] [-s] ``` @@ -997,11 +994,11 @@ dnf needs-restarting [-u] [-r] [-s] ### `versionlock` plugin -Sometimes it is useful to protect packages from all updates or to exclude certain versions of a package (because of known problems for example). For this purpose, the versionlock plugin will be of great help. +Sometimes it is useful to protect packages from all updates or to exclude certain versions of a package (because of known problems for example). For this purpose, the versionlock plugin will be of great help. You need to install an extra package: -``` +```bash dnf install python3-dnf-plugin-versionlock ``` @@ -1009,14 +1006,14 @@ Examples: * Lock the ansible version: -``` +```bash dnf versionlock add ansible Adding versionlock on: ansible-0:6.3.0-2.el9.* ``` * List locked packages: -``` +```bash dnf versionlock list ansible-0:6.3.0-2.el9.* ``` diff --git a/docs/books/admin_guide/14-special-authority.md b/docs/books/admin_guide/14-special-authority.md index b58611274b..66e7f36fb1 100644 --- a/docs/books/admin_guide/14-special-authority.md +++ b/docs/books/admin_guide/14-special-authority.md @@ -41,11 +41,11 @@ Their meanings are as follows: |:-----------:|--------------------------------------------------------------------------------------------------------------------------------------------| | **-** | Represents an ordinary file. Including plain text files (ASCII); binary files (binary); data format files (data); various compressed files. | | **d** | Represents a directory file. By default, there is one in every directory `.` and `..`. | -| **b** | Block device file. Including all kinds of hard drives, USB drives and so on. | +| **b** | Block device file. Including all kinds of hard drives, USB drives and so on. | | **c** | Character device file. Interface device of serial port, such as mouse, keyboard, etc. | -| **s** | Socket file. It is a file specially used for network communication. | +| **s** | Socket file. It is a file specially used for network communication. | | **p** | Pipe file. It is a special file type, the main purpose is to solve the errors caused by multiple programs accessing a file at the same time. FIFO is the abbreviation of first-in-first-out. | -| **l** | Soft link files, also called symbolic link files, are similar to shortcuts in Windows. Hard link file, also known as physical link file.| +| **l** | Soft link files, also called symbolic link files, are similar to shortcuts in Windows. Hard link file, also known as physical link file.| ## The meaning of basic permissions @@ -76,7 +76,7 @@ In GNU/Linux, in addition to the basic permissions mentioned above, there are al ### ACL permissions What is ACL? -ACL(Access Control List), the purpose is to solve the problem that the three identities under Linux can not meet the needs of resource permission allocation. +ACL(Access Control List), the purpose is to solve the problem that the three identities under Linux can not meet the needs of resource permission allocation. For example, the teacher gives lessons to the students, and the teacher creates a directory under the root directory of OS. Only the students in this class are allowed to upload and download, and others are not allowed. At this point, the permissions for the directory are 770. One day, a student from another school came to listen to the teacher, how should permissions be assigned? If you put this student in the **owner group**, he will have the same permissions as the students in this class - **rwx**. If the student is put into the **other users**, he will not have any permissions. At this time, the basic permission allocation cannot meet the requirements, and you need to use ACL. @@ -305,7 +305,7 @@ The role of "SetUID": * Only executable binaries can set SUID permissions. * The executor of the command should have x permission to the program. -* The executor of the command obtains the identity of the owner of the program file when executing the program. +* The executor of the command obtains the identity of the owner of the program file when executing the program. * The identity change is only valid during execution, and once the binary program is finished, the executor's identity is restored to the original identity. Why does GNU/Linux need such strange permissions? @@ -368,12 +368,12 @@ The role of "SetGID": * Only executable binaries can set SGID permissions. * The executor of the command should have x permission to the program. -* The executor of the command obtains the identity of the owner group of the program file when executing the program. +* The executor of the command obtains the identity of the owner group of the program file when executing the program. * The identity change is only valid during execution, and once the binary program is finished, the executor's identity is restored to the original identity. Take the `locate` command for example: -``` +```bash Shell > rpm -ql mlocate /usr/bin/locate ... @@ -417,7 +417,7 @@ Shell > chmod g-s FILE_NAME -rwxr-S--x 1 root root 0 Jan 14 12:11 sgid ``` -SGID can be used not only for executable binary file/program, but also for directories, but it is rarely used. +SGID can be used not only for executable binary file/program, but also for directories, but it is rarely used. * Ordinary users must have rwx permissions on the directory. * For files created by ordinary users in this directory, the default owner group is the owner group of the directory. @@ -489,15 +489,15 @@ Usage of the `chattr` command -- `chattr [ -RVf ] [ -v version ] [ -p project ] The format of a symbolic mode is +-=[aAcCdDeFijPsStTu]. -* "+" means to increase permissions; -* "-" means to reduce permissions; +* "+" means to increase permissions; +* "-" means to reduce permissions; * "=" means equal to a permission. The most commonly used permissions (also called attribute) are **a** and **i**. -#### Description of attribute i: +#### Description of attribute i -| | Delete | Free modification | Append file content | View | Create file | +| | Delete | Free modification | Append file content | View | Create file | |:----------:|:------:|:-----------------:|:-------------------:|:----:|:-----------:| | file | × | × | × | √ | - | | directory | x
(Directory and files under the directory) | √
(Files in the directory) | √
(Files in the directory) | √
(Files in the directory) | x | @@ -558,9 +558,9 @@ Remove the i attribute from the above example: Shell > chattr -i /tmp/filei /tmp/diri ``` -#### Description of attribute a: +#### Description of attribute a -| | Delete | Free modification | Append file content | View | Create file | +| | Delete | Free modification | Append file content | View | Create file | |:----------:|:------:|:-----------------:|:-------------------:|:----:|:-----------:| | file | × | × | √ | √ | - | | directory | x
(Directory and files under the directory) | x
(Files in the directory) | √
(Files in the directory) | √
(Files in the directory) | √ |