Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

Prochaine révision
Révision précédente
elearning:workbooks:redhat:rh124en:l104 [2024/11/11 12:40] – created adminelearning:workbooks:redhat:rh124en:l104 [2024/11/26 10:56] (Version actuelle) admin
Ligne 1: Ligne 1:
 +~~PDF:LANDSCAPE~~
 +
 Version : **2024.01** Version : **2024.01**
  
-Last updated : ~~LASTMOD~~+Last update : ~~LASTMOD~~
  
-======RH12404 Basic Shell Commands and Text Manipulation Tools======+====== RH12405 The Command Line Interface======
  
 =====Contents===== =====Contents=====
  
-  * **RH12404 Basic Shell Commands and Text Manipulation Tools**+  * **RH12405 The Command Line Interface**
     * Contents     * Contents
-    * LAB #1 - Use of Basic Shell Commands +    * The Shell 
-      * 1.1 - The stty Command +    * LAB #1 - The /bin/bash Shell 
-      * 1.2 - The date command +      * 1.1 - Shell Internal and External Commands 
-      * 1.3 - The who Command +      * 1.2 - Aliases 
-      * 1.4 - The df Command +      * 1.3 - Defining a user's shell 
-      * 1.5 - The free Command +      * 1.4 - The Prompt 
-      * 1.6 - The whoami Command +      * 1.5 - Recalling commands 
-      * 1.7 - The pwd Command +      * 1.6 - Generating file name endings 
-      1.8 - The cd Command +      * 1.7 - The interactive shell 
-      1.9 - The ls Command +        Character 
-      1.10 - The lsof Command +        Character ? 
-      1.11 - The touch Command +        Character [ ] 
-      * 1.12 - The echo Command +      * 1.- The extglob option 
-      1.13 - The cp Command +        ?(expression) 
-      1.14 - The file Command +        * *(expression) 
-      1.15 - The cat Command +        +(expression) 
-      1.16 - The mv Command +        @(expression) 
-      1.17 - The mkdir Command +        !(expression) 
-      1.18 - The rmdir Command +        Protecting Metacharacters 
-      1.19 - The rm Command +    * 1.Exit Codes 
-      * 1.20 The sort Command +    * 1.10 Redirections 
-      * 1.21 The more Command +    * 1.11 Pipes 
-      * 1.22 The less Command +    * 1.12 - Command substitution 
-      * 1.23 The find Command +    * 1.13 - Command chaining 
-      * 1.24 The su Command +    * 1.14 Displaying shell variables 
-      * 1.25 The updatedb and locate Commands +      * Main variables 
-      * 1.26 - The whereis Command +      * Internationalization and Localization Variables 
-      * 1.27 - The which Command +      * Special variables 
-      * 1.28 - The uptime Command +    * 1.15 - The env command 
-      * 1.29 - The w Command +    * 1.16 Bash Shell options 
-      * 1.30 The uname Command +      * Examples 
-      * 1.31 - The du Command +        * noclobber 
-      * 1.32 - The clear Command +        * noglob 
-      * 1.33 - The exit Command +        * nounset
-      * 1.34 - The logout Command +
-      * 1.35 - The sleep Command +
-      * 1.36 - The wall Command +
-      * 1.37 - The seq Command +
-      * 1.38 - The screen Command +
-    * LAB #2 - Switches and Arguments +
-    * LAB #3 - Regular Expressions +
-        * BREs +
-        * EREs +
-    * Manipulating Text Files +
-      * Text-search Utilities +
-        * The grep Command +
-        * The egrep Command +
-        * The fgrep Command +
-        * LAB #4 - Using grep, egrep and fgrep +
-      * The Stream EDitor SED +
-        * LAB #5 - Using sed +
-      * The Text Processor AWK +
-        * Presentation +
-        * Field Separation +
-        * Conditions +
-          * A regular expression applied to a record +
-          * A regular expression applied to a field +
-          * Comparisons +
-          * Logical Operators  +
-          * Built-in Variables +
-        * Awk Scripts +
-        * The printf function +
-        * Control Statements +
-          * if +
-          * for +
-          * while +
-          * do-while +
-        * LAB #3 - Using awk +
-    * LAB 7 - Other Useful Commands +
-      * 7.1 - The expand Command +
-      * 7.2 - La Commande unexpand +
-      * 7.3 - The cut command +
-      * 7.4 - The uniq Command +
-      * 7.5 - The tr Command +
-      * 7.6 - The paste Command +
-      * 7.7 - The split Command +
-      * 7.8 - The diff Command +
-      * 7.9 - The cmp Command +
-      * 7.10 - The patch Command +
-      * 7.11 - The strings Command +
-      * 7.12 - The comm Command +
-      * 7.13 - The head Command +
-      * 7.14 - The tail Command +
-    * LAB #8 - Use the grep, tr and cut commands to extract your IPv4 address from the output of ifconfig +
-    * LAB #9 - Use the grep, awk and sed commands to extract your IPv4 address from the output of ip+
  
-=====LAB #1 - Use of Basic Shell Commands=====+=====The Shell=====
  
-<WRAP center round todo 60%> +A shell is a **command line interpreter** (C.L.I)It is used as an interface to give instructions or **commands** to the operating system
-**To do** - You are currently the root user in your terminalBefore proceeding further, type **exit** and hit the <key>Enter</key> key. +
-</WRAP>+
  
-====1.1 - The stty Command==== +The word shell is genericThere are many shells in the Unix world, for example :
- +
-Using this command with the **-a** switch allows you to identify which combination of keys should be used to control a foreground process: +
- +
-<code> +
-[root@redhat9 ~]# exit +
-logout +
-[trainee@redhat9 ~]$ stty -a +
-speed 38400 baud; rows 27; columns 105; line = 0; +
-intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>; eol2 = <undef>; swtch = <undef>; +
-start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R; werase = ^W; lnext = ^V; discard = ^O; min = 1; time = 0; +
--parenb -parodd -cmspar cs8 -hupcl -cstopb cread -clocal -crtscts +
--ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl ixon -ixoff -iuclc -ixany -imaxbel +
--iutf8 +
-opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0 +
-isig icanon iexten echo echoe echok -echonl -noflsh -xcase -tostop -echoprt echoctl echoke -flusho +
--extproc +
-</code> +
- +
-<WRAP center round important 60%> +
-**Important** - The two most important combinations are **intr = ^C** and **susp = ^Z**. The former kills the process whilst the latter suspends its execution. +
-</WRAP> +
- +
-===Command Line Switches=== +
- +
-<WRAP center round todo 60%> +
-**To do** Use the **--help** option of the **stty** command to view the command line switches. +
-</WRAP>+
  
-====1.2 - The date command====+^ Shell ^ Name ^ Release Date ^ Inventer ^ Command ^ Comments ^ 
 +| tsh | Thompson Shell | 1971 | Ken Thompson | sh | The first shell | 
 +| sh | Bourne Shell | 1977 | Stephen Bourne | sh | The shell common to all Unix and Linux OSs: /bin/sh | 
 +| csh | C-Shell | 1978 | Bill Joy | csh | The BSD shell: /bin/csh | 
 +| tcsh | Tenex C-Shell | 1979 | Ken Greer | tcsh | A fork of the csh shell: /bin/tcsh | 
 +| ksh | Korn Shell | 1980 | David Korn | ksh | Open Source since 2005: /bin/ksh | 
 +| bash| Bourne Again Shell | 1987 | Brian Fox | bash | The default shell for Linux, MacOS X, Solaris 11: /bin/bash | 
 +| zsh | Z Shell | 1990 | Paul Falstad | zsh | Zsh is an extended Bourne shell with a large number of improvements, including some features of bash, ksh, and tcsh: /usr/bin/zsh |
  
-This command's output gives the current system date and time. The command can also be used to set the system date:+Under RHEL 9 the **/bin/sh** shell is a symbolic link to **/bin/bash** :
  
 <code> <code>
-[trainee@redhat9 ~]$ date +[trainee@redhat9 ~]$ ls -l /bin/sh 
-Wed Sep 25 02:45:00 PM CEST 2024+lrwxrwxrwx. 1 root root 4 Feb 15 2024 /bin/sh -> bash
 </code> </code>
  
-===Command Line Switches===+=====LAB #1 - The /bin/bash Shell=====
  
-<WRAP center round todo 60%> +This module is about using the **bash** shell under Linux. The **bash** shell allows you to:
-**To do** : Use the **--help** option of the **date** command to view the command line switches. +
-</WRAP>+
  
-====1.3 The who Command====+  * Recall previously typed commands 
 +  * Auto-generate the end of a file name 
 +  * Use Aliases 
 +  * Use tables 
 +  * Use C language numerical and math variables 
 +  * Manage strings 
 +  * Use Functions
  
-This command's output shows who is currently connected to the system:+command always begins with a keyword. This keyword is interpreted by the shell according to the type of command and in the following order:
  
-<code> +  * An Alias, 
-[trainee@redhat9 ~]$ who +  * A Function, 
-trainee  pts/0        2024-09-25 12:47 (10.0.2.1) +  * A Built-in Command, 
-</code>+  * An External Command.
  
-===Command Line Switches===+====1.1 - Built-in and External Shell Commands====
  
-<WRAP center round todo 60%> +Built-in shell commands are commands such as **cd**. To check the type of command, use the **type** command:
-**To do** : Use the **--help** option of the **who** command to view the command line switches. +
-</WRAP> +
- +
-====1.4 - The df Command==== +
- +
-This command's output shows the free space on each mounted block device:+
  
 <code> <code>
-[trainee@redhat9 ~]$ df +[trainee@redhat9 ~]$ type cd 
-Filesystem            1K-blocks    Used Available Use% Mounted on +cd is a shell builtin
-devtmpfs                   4096            4096   0% /dev +
-tmpfs                   3934780         3934780   0% /dev/shm +
-tmpfs                   1573912    9244   1564668   1% /run +
-/dev/mapper/rhel-root  46110724 7023448  39087276  16% / +
-/dev/sda1               1038336  406796    631540  40% /boot +
-tmpfs                    786956      52    786904   1% /run/user/42 +
-tmpfs                    786956      36    786920   1% /run/user/1000+
 </code> </code>
  
-The units are shown as **blocks**. In order to **humanize** the outputit is possible to use the **-h** switch (also known as a **parameter****option** or **flag**):+Commands external to the shell are executable binaries or scriptsgenerally located in /bin, /sbin/usr/bin or /usr/sbin :
  
 <code> <code>
-[trainee@redhat9 ~]$ df -h +[trainee@redhat9 ~]$ type ifconfig 
-Filesystem             Size  Used Avail Use% Mounted on +ifconfig is /usr/sbin/ifconfig
-devtmpfs               4.0M      4.0M   0% /dev +
-tmpfs                  3.8G      3.8G   0% /dev/shm +
-tmpfs                  1.6G  9.1M  1.5G   1% /run +
-/dev/mapper/rhel-root   44G  6.7G   38G  16% / +
-/dev/sda1             1014M  398M  617M  40% /boot +
-tmpfs                  769M   52K  769M   1% /run/user/42 +
-tmpfs                  769M   36K  769M   1% /run/user/1000+
 </code> </code>
-===Command Line Switches=== 
  
-<WRAP center round todo 60%> +====1.Aliases====
-**To do** : Use the **--help** option of the **df** command to view the command line switches. +
-</WRAP> +
- +
-====1.5 - The free Command==== +
- +
-This command's output shows the memory usage: +
- +
-<code> +
-[trainee@redhat9 ~]$ free +
-               total        used        free      shared  buff/cache   available +
-Mem:         7869560      845388     6607588       15324      678020     7024172 +
-Swap:        5242876               5242876 +
-</code> +
- +
-The units are shown as **blocks**. In order to **humanize** the output, it is possible to use the **-h** switch: +
- +
-<code> +
-[trainee@redhat9 ~]$ free -h +
-               total        used        free      shared  buff/cache   available +
-Mem:           7.5Gi       825Mi       6.3Gi        14Mi       662Mi       6.7Gi +
-Swap:          5.0Gi          0B       5.0Gi +
-</code> +
- +
-===Command Line Switches=== +
- +
-<WRAP center round todo 60%> +
-**To do** : Use the **--help** option of the **free** command to view the command line switches. +
-</WRAP> +
- +
-====1.The whoami Command==== +
- +
-This command's output indicates the user name associated with the current effective user ID: +
- +
-<code> +
-[trainee@redhat9 ~]$ whoami +
-trainee +
-</code>+
  
-Now become the system administrator **root**:+Aliases are names used to designate a command or a sequence of commands and are specific only to the shell that created them and to the user's environment :
  
 <code> <code>
-[trainee@redhat9 ~]$ su - +[trainee@redhat9 ~]$ type ls 
-Password: fenestros+ls is aliased to `ls --color=auto'
 </code> </code>
  
 <WRAP center round important 60%> <WRAP center round important 60%>
-**Important** : Note that the password will not be visible.+**Important**: Note that in this case the **ls** alias is indeed an alias that uses the ls **command** itself.
 </WRAP> </WRAP>
  
-Now use the **whoami** command again:+An alias is defined using the **alias** command:
  
 <code> <code>
-[root@redhat9 ~]# whoami +[trainee@redhat9 ~]$ alias dir=‘ls -l’ 
-root+[trainee@redhat9 ~]$ dir 
 +total 4 
 +-rw-r--r--. 1 trainee trainee 0 Sep 25 15:11 aac 
 +-rw-r--r--. 1 trainee trainee 0 Sep 25 15:11 abc 
 +-rw-r--r--. 1 trainee trainee 0 Sep 25 15:11 bca 
 +drwxr-xr-x. 2 trainee trainee 6 Oct 19 2023 Desktop 
 +drwxr-xr-x. 2 trainee trainee 6 Oct 19 2023 Documents 
 +drwxr-xr-x. 2 trainee trainee 6 Oct 19 2023 Downloads 
 +drwxr-xr-x. 2 trainee trainee 6 Oct 19 2023 Music 
 +drwxr-xr-x. 2 trainee trainee 6 Oct 19 2023 Pictures 
 +drwxr-xr-x. 2 trainee trainee 6 Oct 19 2023 Public 
 +drwxr-xr-x. 2 trainee trainee 6 Oct 19 2023 Templates 
 +drwxr-xr-x. 2 trainee trainee 6 Oct 19 2023 Videos 
 +-rw-r--r--. 1 trainee trainee 442 Sep 25 14:24 vitext 
 +-rw-r--r--. 1 trainee trainee 0 Sep 25 15:11 xyz
 </code> </code>
- 
  
 <WRAP center round important 60%> <WRAP center round important 60%>
-**Important** : Note the current effective user ID is root.+**Important**: Note that the **dir** command actually exists. Creating an alias that is called **dir** implies that the alias will be executed instead of the **dir** command.
 </WRAP> </WRAP>
  
-Finally execute the **exit** command to return as **trainee**:+The list of defined aliases can be viewed using the **alias** command:
  
 <code> <code>
-[root@redhat9 ~]# exit +[trainee@redhat9 ~]$ alias 
-logout +alias dir=‘ls -l’ 
-[trainee@redhat9 ~]$+alias egrep=‘egrep --color=auto’ 
 +alias fgrep=‘fgrep --color=auto’ 
 +alias grep=‘grep --color=auto’ 
 +alias l.=‘ls -d .* --color=auto’ 
 +alias ll=‘ls -l --color=auto’ 
 +alias ls=‘ls --color=auto’ 
 +alias xzegrep=‘xzegrep --color=auto’ 
 +alias xzfgrep=‘xzfgrep --color=auto’ 
 +alias xzgrep=‘xzgrep --color=auto’ 
 +alias zegrep=‘zegrep --color=auto’ 
 +alias zfgrep=‘zfgrep --color=auto’ 
 +alias zgrep=‘zgrep --color=auto’
 </code> </code>
  
-===Command Line Switches=== +<WRAP centre round important 60%> 
- +**Important**: Note that this list contains, indiscriminately, aliases defined in system startup files as well as the **dir** alias created by **trainee** that is only available to **trainee** in the current terminal.
-<WRAP center round todo 60%> +
-**To do** : Use the **--help** option of the **whoami** command to view the command line switches.+
 </WRAP> </WRAP>
  
-====1.7 - The pwd Command==== +To force execution of a command and not the alias you must precede the command with the **\** character:
- +
-This command's output shows the current working directory:+
  
 <code> <code>
-[trainee@redhat9 ~]$ pwd +[trainee@redhat9 ~]$ \dir 
-/home/trainee+aac abc bca Desktop Documents Downloads Music Pictures Public Templates Videos vitext xyz
 </code> </code>
  
-===Command Line Switches=== +To delete an alias, use the **unalias** command:
- +
-<WRAP center round todo 60%> +
-**To do** : Use the **help** command with **pwd** option to view the command line switches. +
-</WRAP> +
- +
-====1.8 - The cd Command=== +
- +
-This command's output changes the current working directory to that specified by the **argument**:+
  
 <code> <code>
-[trainee@redhat9 ~]$ cd /tmp +[trainee@redhat9 ~]$ unalias dir 
- +[trainee@redhat9 ~]$ dir 
-[trainee@redhat9 tmp]$ pwd +aac abc bca Desktop Documents Downloads Music Pictures Public Templates Videos vitext xyz
-/tmp +
-[trainee@redhat9 tmp]$ +
 </code> </code>
  
-===Command Line Switches===+====1.3 - Defining a user's shell====
  
-<WRAP center round todo 60%> +The user shell is defined by **root** in the last field of the **/etc/passwd** file:
-**To do** : Use the **help** command with **cd** option to view the command line switches. +
-</WRAP> +
- +
-====1.9 - The ls Command=== +
- +
-This commands output lists information about the files in directory specified as an argument. If no argument is specified, the output lists the files in the current working directory+
  
 <code> <code>
-[trainee@redhat9 tmp]$ ls +[trainee@redhat9 ~]$ cat /etc/passwd 
-dbus-G7skg3Wlpv +root:x:0:0:root:/root:/bin/bash 
-dbus-s2vBGtxTHi +bin:x:1:1:bin:/bin:/sbin/nologin 
-inode +daemon:x:2:2:daemon:/sbin:/sbin/nologin 
-systemd-private-7e6b4544d8d34a9bb30a13aeb8e4e02a-colord.service-FfNuds +adm:x:3:4:adm:/var/adm:/sbin/nologin 
-systemd-private-7e6b4544d8d34a9bb30a13aeb8e4e02a-dbus-broker.service-VIpKgR +lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin 
-systemd-private-7e6b4544d8d34a9bb30a13aeb8e4e02a-kdump.service-0SbYbm +sync:x:5:0:sync:/sbin:/bin/sync 
-systemd-private-7e6b4544d8d34a9bb30a13aeb8e4e02a-ModemManager.service-k4DpLF +shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown 
-systemd-private-7e6b4544d8d34a9bb30a13aeb8e4e02a-power-profiles-daemon.service-mIx9S5 +halt:x:7:0:halt:/sbin:/sbin/halt 
-systemd-private-7e6b4544d8d34a9bb30a13aeb8e4e02a-rtkit-daemon.service-2gD28Z +mail:x:8:12:mail:/var/spool/mail:/sbin/nologin 
-systemd-private-7e6b4544d8d34a9bb30a13aeb8e4e02a-switcheroo-control.service-rLbOK4 +operator:x:11:0:operator:/root:/sbin/nologin 
-systemd-private-7e6b4544d8d34a9bb30a13aeb8e4e02a-systemd-logind.service-uLNyfd +games:x:12:100:games:/usr/games:/sbin/nologin 
-systemd-private-7e6b4544d8d34a9bb30a13aeb8e4e02a-upower.service-bIpAUN+ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin 
 +nobody:x:65534:65534:Kernel Overflow User:/:/sbin/nologin 
 +systemd-coredump:x:999:997:systemd Core Dumper:/:/sbin/nologin 
 +dbus:x:81:81:System message bus:/:/sbin/nologin 
 +polkitd:x:998:996:User for polkitd:/:/sbin/nologin 
 +avahi:x:70:70:Avahi mDNS/DNS-SD Stack:/var/run/avahi-daemon:/sbin/nologin 
 +tss:x:59:59:Account used for TPM access:/dev/null:/sbin/nologin 
 +colord:x:997:993:User for colord:/var/lib/colord:/sbin/nologin 
 +clevis:x:996:992:Clevis Decryption Framework unprivileged user:/var/cache/clevis:/usr/sbin/nologin 
 +rtkit:x:172:172:RealtimeKit:/proc:/sbin/nologin 
 +sssd:x:995:991:User for sssd:/:/sbin/nologin 
 +geoclue:x:994:990:User for geoclue:/var/lib/geoclue:/sbin/nologin 
 +libstoragemgmt:x:988:988:daemon account for libstoragemgmt:/:/usr/sbin/nologin 
 +systemd-oom:x:987:987:systemd Userspace OOM Killer:/:/usr/sbin/nologin 
 +setroubleshoot:x:986:986:SELinux troubleshoot server:/var/lib/setroubleshoot:/sbin/nologin 
 +pipewire:x:985:984:PipeWire System Daemon:/var/run/pipewire:/sbin/nologin 
 +flatpak:x:984:983:User for flatpak system helper:/:/sbin/nologin 
 +gdm:x:42:42::/var/lib/gdm:/sbin/nologin 
 +cockpit-ws:x:983:982:User for cockpit web service:/nonexisting:/sbin/nologin 
 +cockpit-wsinstance:x:982:981:User for cockpit-ws instances:/nonexisting:/sbin/nologin 
 +gnome-initial-setup:x:981:980::/run/gnome-initial-setup/:/sbin/nologin 
 +sshd:x:74:74:Privilege-separated SSH:/usr/share/empty.sshd:/sbin/nologin 
 +chrony:x:980:979:chrony system user:/var/lib/chrony:/sbin/nologin 
 +dnsmasq:x:979:978:Dnsmasq DHCP and DNS server:/var/lib/dnsmasq:/sbin/nologin 
 +tcpdump:x:72:72::/:/sbin/nologin 
 +trainee:x:1000:1000:trainee:/home/trainee:/bin/bash
 </code> </code>
  
-===Command Line Switches=== +However the user can change their shell using the **chsh** command. The shells available to system users are listed in the **/etc/shells** file. Enter the **cat /etc/shells** command:
- +
-<WRAP center round todo 60%> +
-**To do** : Use the **--help** option of the **ls** command to view the command line switches. +
-</WRAP> +
- +
-====1.10 - The lsof Command==== +
- +
-This command's output shows information about open files:+
  
 <code> <code>
-[trainee@redhat9 tmp]$ su - +[trainee@redhat9 ~]$ cat /etc/shells 
-Password: fenestros +/bin/sh 
- +/bin/bash 
-[root@redhat9 ~]# lsof | more +/usr/bin/sh 
-COMMAND    PID  TID TASKCMD             USER   FD      TYPE             DEVICE  SIZE/OFF       NODE NAME +/usr/bin/bash
-systemd      1                          root  cwd       DIR              253,0       235        128 / +
-systemd      1                          root  rtd       DIR              253,0       235        128 / +
-systemd      1                          root  txt       REG              253,0     98224     701526 /usr/ +
-lib/systemd/systemd +
-systemd      1                          root  mem       REG              253,0    598592   68842572 /etc/ +
-selinux/targeted/contexts/files/file_contexts.bin +
-systemd      1                          root  mem       REG              253,0    914360   67157969 /usr+
-lib64/libm.so.6 +
-systemd      1                          root  mem       REG              253,0    882376   67158330 /usr/ +
-lib64/libzstd.so.1.5.1 +
-systemd      1                          root  mem       REG              253,0   4487176   67224852 /usr/ +
-lib64/libcrypto.so.3.0.7 +
-systemd      1                          root  mem       REG              253,0   1714208   68560752 /usr/ +
-lib64/libp11-kit.so.0.3.1 +
-systemd      1                          root  mem       REG              253,0   2592552   67918617 /usr/ +
-lib64/libc.so.6 +
-systemd      1                          root  mem       REG              253,0    636848   67918540 /usr/ +
-lib64/libpcre2-8.so.0.11.0 +
-systemd      1                          root  mem       REG              253,0   1288512   68560763 /usr/ +
-lib64/libgcrypt.so.20.4.0 +
-systemd      1                          root  mem       REG              253,0   3785712   67956161 /usr/ +
-lib64/systemd/libsystemd-shared-252.so +
-systemd      1                          root  mem       REG              253,0     44784   68560751 /usr/ +
-lib64/libffi.so.8.1.0 +
-systemd      1                          root  mem       REG              253,0    153600   67188275 /usr/ +
---More-- +
-[q]+
 </code> </code>
  
-===Command Line Switches=== +Then use the **echo** command to display the current **trainee** shell:
- +
-<WRAP center round todo 60%> +
-**To do** : Use the **--help** option of the **lsof** command to view the command line switches. +
-</WRAP> +
- +
-====1.11 - The touch Command==== +
- +
-This command updates the access and modification times of one or several file(s) to the current time. If the file does not exist, the system creates an empty file:+
  
 <code> <code>
-[root@redhat9 ~]# exit +[trainee@redhat9 ~]$ echo $SHELL 
-logout +/bin/bash
- +
-[trainee@redhat9 tmp]$ touch test +
- +
-[trainee@redhat9 tmp]$ ls +
-dbus-G7skg3Wlpv +
-dbus-s2vBGtxTHi +
-inode +
-systemd-private-7e6b4544d8d34a9bb30a13aeb8e4e02a-colord.service-FfNuds +
-systemd-private-7e6b4544d8d34a9bb30a13aeb8e4e02a-dbus-broker.service-VIpKgR +
-systemd-private-7e6b4544d8d34a9bb30a13aeb8e4e02a-kdump.service-0SbYbm +
-systemd-private-7e6b4544d8d34a9bb30a13aeb8e4e02a-ModemManager.service-k4DpLF +
-systemd-private-7e6b4544d8d34a9bb30a13aeb8e4e02a-power-profiles-daemon.service-mIx9S5 +
-systemd-private-7e6b4544d8d34a9bb30a13aeb8e4e02a-rtkit-daemon.service-2gD28Z +
-systemd-private-7e6b4544d8d34a9bb30a13aeb8e4e02a-switcheroo-control.service-rLbOK4 +
-systemd-private-7e6b4544d8d34a9bb30a13aeb8e4e02a-systemd-logind.service-uLNyfd +
-systemd-private-7e6b4544d8d34a9bb30a13aeb8e4e02a-upower.service-bIpAUN +
-test +
-</code> +
- +
-===Command Line Switches=== +
- +
-<WRAP center round todo 60%> +
-**To do** : Use the **--help** option of the **touch** command to view the command line switches. +
-</WRAP> +
- +
-====1.12 - The echo Command ==== +
- +
-This command writes the arguments to the standard output (i.e. the screen): +
- +
-<code> +
-[trainee@redhat9 tmp]echo fenestros +
-fenestros +
-</code> +
- +
-===Command Line Switches=== +
- +
-<WRAP center round todo 60%> +
-**To do** : Use the **help** command with **echo** option to view the command line switches. +
-</WRAP> +
- +
-====1.13 - The cp Command=== +
- +
-This command is used to copy a source to a destination or multiple sources to a directory: +
- +
-<code> +
-[trainee@redhat9 tmp]$ cp test ~ +
- +
-[trainee@redhat9 tmp]$ ls -l ~ +
-total 4 +
-drwxr-xr-x. 2 trainee trainee   6 Oct 19  2023 Desktop +
-drwxr-xr-x. 2 trainee trainee   6 Oct 19  2023 Documents +
-drwxr-xr-x. 2 trainee trainee   6 Oct 19  2023 Downloads +
-drwxr-xr-x. 2 trainee trainee   6 Oct 19  2023 Music +
-drwxr-xr-x. 2 trainee trainee   6 Oct 19  2023 Pictures +
-drwxr-xr-x. 2 trainee trainee   6 Oct 19  2023 Public +
-drwxr-xr-x. 2 trainee trainee   6 Oct 19  2023 Templates +
--rw-r--r--. 1 trainee trainee   0 Sep 25 14:59 test +
-drwxr-xr-x. 2 trainee trainee   6 Oct 19  2023 Videos +
--rw-r--r--. 1 trainee trainee 442 Sep 25 14:24 vitext+
 </code> </code>
  
 <WRAP center round important 60%> <WRAP center round important 60%>
-Note the use of the **~** (tilde) character which is a shortcut to the current user's home directory. In the case of this example : **/home/trainee**.+**Important**: Note that under RHEL 9, the system informs us that the current shell of the **trainee** user is **/bin/bash** and not **/usr/bin/bash**. This is because the /bin directory is a symbolic link pointing to the /usr/bin directory.
 </WRAP> </WRAP>
  
-===Command Line Switches=== +Then change the **trainee** shell using the **chsh** command, specifying the value of **/bin/sh** for the new shell:
- +
-<WRAP center round todo 60%> +
-**To do** : Use the **--help** option of the **cp** command to view the command line switches. +
-</WRAP> +
- +
-====1.14 - The file Command==== +
- +
-This command determines a file type:+
  
 <code> <code>
-[trainee@redhat9 tmp]$ file ~/test +[trainee@redhat9 ~]$ chsh 
-/home/trainee/testempty+Changing shell for trainee. 
 +New shell [/bin/bash]: /bin/sh 
 +Passwordtrainee 
 +Shell changed.
 </code> </code>
  
 <WRAP center round important 60%> <WRAP center round important 60%>
-**Important** Note that in the case of the first line of the above output, tha command **file** is incapable of informing you of the type of file since **test** is empty.+**Important**Note that the password entered will **not** be visible.
 </WRAP> </WRAP>
  
-Using the <key>></key> keyredirect the output of **echo fenestros** into the **/home/trainee/test** file as follows:+Nextcheck the active shell for **trainee** :
  
 <code> <code>
-[trainee@redhat9 tmp]$ echo "fenestros" > ~/test+[trainee@redhat9 ~]$ echo $SHELL 
 +/bin/bash
 </code> </code>
  
-Now use the **file** command once again to determine the file type:+Lastly check the shell stipulated in the **/etc/passwd** file for **trainee**:
  
 <code> <code>
-[trainee@redhat9 tmp]$ file ~/test +[trainee@redhat9 ~]$ cat /etc/passwd | grep trainee 
-/home/trainee/testASCII text+trainee:x:1000:1000:trainee:/home/trainee:/bin/sh
 </code> </code>
  
-===Command Line Switches=== +<WRAP center round important 60%> 
- +**Important**: You will notice that the active shell is always **/bin/bash** whereas the shell stipulated in the /etc/passwd file is the **/bin/sh**. The **/bin/sh** shell will only become **trainee**'s active shell the next time it connects to the system.
-<WRAP center round todo 60%> +
-**To do** : Use the **--help** option of the **file** command to view the command line switches.+
 </WRAP> </WRAP>
  
-====1.15 - The cat Command==== +Change your shell to **/bin/bash** again using the chsh command:
- +
-This commands concatenate files, or standard input, to standard output. In the case of only one file as an argument, the effective result is to print the file contents to the screen:+
  
 <code> <code>
-[trainee@redhat9 tmp]$ cat ~/test +[trainee@redhat9 ~]$ chsh 
-fenestros +Changing shell for trainee. 
-</code> +New shell [/bin/sh]: /bin/bash 
- +Passwordtrainee 
-===Command Line Switches=== +Shell changed.
- +
-<WRAP center round todo 60%> +
-**To do** : Use the **--help** option of the **cat** command to view the command line switches. +
-</WRAP> +
- +
-====1.16 - The mv Command==== +
- +
-This command renames a source to a destination or moves sources to a directory: +
- +
-<code> +
-[trainee@redhat9 tmp]$ mv ~/test . +
- +
-[trainee@redhat9 tmp]$ ls -l ~ +
-total 4 +
-drwxr-xr-x2 trainee trainee   6 Oct 19  2023 Desktop +
-drwxr-xr-x. 2 trainee trainee   6 Oct 19  2023 Documents +
-drwxr-xr-x. 2 trainee trainee   6 Oct 19  2023 Downloads +
-drwxr-xr-x. 2 trainee trainee   6 Oct 19  2023 Music +
-drwxr-xr-x. 2 trainee trainee   6 Oct 19  2023 Pictures +
-drwxr-xr-x. 2 trainee trainee   6 Oct 19  2023 Public +
-drwxr-xr-x. 2 trainee trainee   6 Oct 19  2023 Templates +
-drwxr-xr-x. 2 trainee trainee   6 Oct 19  2023 Videos +
--rw-r--r--. 1 trainee trainee 442 Sep 25 14:24 vitext +
- +
-[trainee@redhat9 tmp]$ mv test TeSt +
- +
-[trainee@redhat9 tmp]$ ls -l +
-total 4 +
-srwxrwxrwx. 1 gdm     gdm      0 Sep 25 12:30 dbus-G7skg3Wlpv +
-srwxrwxrwx. 1 gdm     gdm      0 Sep 25 12:45 dbus-s2vBGtxTHi +
-drwxr-xr-x2 root    root    54 Sep 25 13:10 inode +
-drwx------. 3 root    root    17 Sep 25 12:45 systemd-private-7e6b4544d8d34a9bb30a13aeb8e4e02a-colord.service-FfNuds +
-drwx------. 3 root    root    17 Sep 25 12:44 systemd-private-7e6b4544d8d34a9bb30a13aeb8e4e02a-dbus-broker.service-VIpKgR +
-drwx------. 3 root    root    17 Sep 25 12:44 systemd-private-7e6b4544d8d34a9bb30a13aeb8e4e02a-kdump.service-0SbYbm +
-drwx------. 3 root    root    17 Sep 25 12:44 systemd-private-7e6b4544d8d34a9bb30a13aeb8e4e02a-ModemManager.service-k4DpLF +
-drwx------. 3 root    root    17 Sep 25 12:44 systemd-private-7e6b4544d8d34a9bb30a13aeb8e4e02a-power-profiles-daemon.service-mIx9S5 +
-drwx------. 3 root    root    17 Sep 25 12:44 systemd-private-7e6b4544d8d34a9bb30a13aeb8e4e02a-rtkit-daemon.service-2gD28Z +
-drwx------. 3 root    root    17 Sep 25 12:44 systemd-private-7e6b4544d8d34a9bb30a13aeb8e4e02a-switcheroo-control.service-rLbOK4 +
-drwx------. 3 root    root    17 Sep 25 12:44 systemd-private-7e6b4544d8d34a9bb30a13aeb8e4e02a-systemd-logind.service-uLNyfd +
-drwx------. 3 root    root    17 Sep 25 12:44 systemd-private-7e6b4544d8d34a9bb30a13aeb8e4e02a-upower.service-bIpAUN +
--rw-r--r--. 1 trainee trainee 10 Sep 25 15:01 TeSt+
 </code> </code>
  
 <WRAP center round important 60%> <WRAP center round important 60%>
-**Important** Note the use of the shortcut **.** which indicates the current working directory.+**Important**Note that the password entered will **not** be visible.
 </WRAP> </WRAP>
  
-===Command Line Switches===+====1.4 - The Prompt====
  
-<WRAP center round todo 60%> +A user's prompt depends on their status:
-**To do** Use the **--help** option of the **mv** command to view the command line switches. +
-</WRAP>+
  
-====1.17 - The mkdir Command====+  * **$** for a normal user, 
 +  * **#** for root.
  
-This command creates the directory(ies) if it (they) does (do) not exist:+====1.5 - Recalling commands ====
  
-<code> +The **/bin/bash** shell can be used to recall the last commands entered. To see the list of memorised commands, use the history command:
-[trainee@redhat9 tmp]$ cd ~ +
- +
-[trainee@redhat9 ~]$ mkdir testdir +
- +
-[trainee@redhat9 ~]$ ls +
-Desktop  Documents  Downloads  Music  Pictures  Public  Templates  testdir  Videos  vitext +
-</code> +
- +
-===Command Line Switches=== +
- +
-<WRAP center round todo 60%> +
-**To do** : Use the **--help** option of the **mkdir** command to view the command line switches. +
-</WRAP> +
- +
-====1.18 - The rmdir Command==== +
- +
-This command removes the directory(ies) if it (they) is (are) **empty**:+
  
 <code> <code>
-[trainee@redhat9 ~]$ rmdir testdir +[trainee@redhat9 ~]$ history | more 
- +    1 su - 
-[trainee@redhat9 ~]$ ls +    2 exit 
-Desktop  Documents  Downloads  Music  Pictures  Public  Templates  Videos  vitext+    3 su - 
 +    4 clear 
 +    5 cd / 
 +    6 ls -l 
 +    7 cd afs 
 +    8 ls 
 +    9 cd / 
 +   10 su - 
 +   11 cd ~ 
 +   12 vi vitext 
 +   13 view vitext 
 +   14 vi vitext 
 +   15 vi .exrc 
 +   16 vi vitext 
 +   17 su - 
 +   18 stty -a 
 +   19 date 
 +   20 who 
 +   21 df 
 +   22 df -h 
 +   23 free 
 +   24 free -h 
 +   25 whoami 
 +   26 su - 
 +   27 pwd 
 +   28 cd /tmp 
 +   29 pwd 
 +   30 ls 
 +   31 su - 
 +   32 touch test 
 +   33 ls 
 +   34 echo fenestros 
 +   35 cp test ~ 
 +   36 ls -l ~ 
 +   37 file ~/test 
 +--More-- 
 +[q]
 </code> </code>
  
-===Command Line Switches=== +<WRAP center round important 60%> 
- +**Important**: The history is specific to each user.
-<WRAP center round todo 60%> +
-**To do** : Use the **--help** option of the **rmdir** command to view the command line switches.+
 </WRAP> </WRAP>
  
-====1.19 The rm Command====+The command history is in **emacs** mode by defaultAs a result, the last command is recalled using the **[Up Arrow]** key or the **[CTRL]-[P]** keys and the next command is recalled using the **[Down Arrow]** key or the **[CTRL]-[N]** keys :
  
-This command removes a directory, empty of not, as well as files:+^ Control Character  ^ Action 
 +| [CTRL]-[P] (= Up Arrow)  | Navigates backwards through the list   |  
 +| [CTRL]-[N] (= Down Arrow)  | Navigates forwards through the list    |
  
-<code> +To move through the history line :
-[trainee@redhat9 ~]$ mkdir testdir1+
  
-[trainee@redhat9 ~]$ cd /tmp+^ Control Character  ^ Action 
 +[CTRL]-[A] | Move to the beginning of the line |  
 +| [CTRL]-[E] | Move to the end of the line | 
 +| [CTRL]-[B] | Move one character to the left |  
 +| [CTRL]-[F] | Move one character to the right | 
 +| [CTRL]-[D] | Delete the character under the cursor | 
  
-[trainee@redhat9 tmp]$ echo "fenestros" > TeSt+To search the history, use the keys :
  
-[trainee@redhat9 tmp]$ cd ~+^ Control Character  ^ Action 
 +[CTRL]-[R] //string//  | Search backwards for //string// in the history. Using [CTRL]-[R] again will search for the previous occurence of //string// |  
 +| [CTRL]-[S] //string//  | Search forwards for //string// in the history. Using [CTRL]-[S] again will search for the next occurence of //string// | 
 +| [CTRL]-[G] | Quit the search mode |
  
-[trainee@redhat9 ~]$ mv /tmp/TeSt ~/testdir1 +It is also possible to recall the last command in the history using the **!!** characters:
- +
-[trainee@redhat9 ~]$ ls -lR testdir1/ +
-testdir1/: +
-total 4 +
--rw-r--r--. 1 trainee trainee 10 Sep 25 15:08 TeSt +
- +
-[trainee@redhat9 ~]$ rmdir testdir1/ +
-rmdir: failed to remove 'testdir1/': Directory not empty +
- +
-[trainee@redhat9 ~]$ rm -rf testdir1 +
- +
-[trainee@redhat9 ~]$ ls +
-Desktop  Documents  Downloads  Music  Pictures  Public  Templates  Videos  vitext +
-</code> +
- +
-===Command Line Switches=== +
- +
-<WRAP center round todo 60%> +
-**To do** : Use the **--help** option of the **rm** command to view the command line switches. +
-</WRAP> +
- +
-====1.20 - The sort Command ==== +
- +
-This command writes a sorted concatenation of all files to standard output:+
  
 <code> <code>
-[trainee@redhat9 ~]$ touch aac abc bca xyz 
- 
 [trainee@redhat9 ~]$ ls [trainee@redhat9 ~]$ ls
 +aac abc bca Desktop Documents Downloads Music Pictures Public Templates Videos vitext xyz
  
-aac  abc  bca  Desktop  Documents  Downloads  Music  Pictures  Public  Templates  Videos  vitext  xyz +[trainee@redhat9 ~]$ !! 
- +ls 
-[trainee@redhat9 ~]$ ls | sort +aac abc bca Desktop Documents Downloads Music Pictures Public Templates Videos vitext xyz
-aac +
-abc +
-bca +
-Desktop +
-Documents +
-Downloads +
-Music +
-Pictures +
-Public +
-Templates +
-Videos +
-vitext +
-xyz +
- +
-[trainee@redhat9 ~]$ ls | sort -r +
-xyz +
-vitext +
-Videos +
-Templates +
-Public +
-Pictures +
-Music +
-Downloads +
-Documents +
-Desktop +
-bca +
-abc +
-aac+
 </code> </code>
  
-<WRAP center round important 60%> +You can recall specific command from the history by using the **!** character followed by the number of the command to be recalled:
-**Important** - Note the use of the **|** character, called **pipe**. A pipe is used to channel the standard output of the command that precedes it into the standard input of the command that follows it. +
-</WRAP> +
- +
-===Command Line Switches=== +
- +
-<WRAP center round todo 60%> +
-**To do** : Use the **--help** option of the **sort** command to view the command line switches. +
-</WRAP> +
- +
-====1.21 - The more Command ==== +
- +
-This command is used to display a long file page by page:+
  
 <code> <code>
-[trainee@redhat9 ~]$ more /etc/services +[trainee@redhat9 ~]$ history 
-# /etc/services: +    su 
-# $Id: services,1.49 2017/08/18 12:43:23 ovasik Exp $ +    2 exit 
-+    3 su 
-# Network services, Internet style +    4 clear 
-# IANA services version: last updated 2016-07-08 +    5 cd / 
-# +    6 ls -l 
-# Note that it is presently the policy of IANA to assign a single well-known +    7 cd afs 
-# port number for both TCP and UDP; hence, most entries here have two entries +    8 ls 
-# even if the protocol doesn't support UDP operations. +    9 cd / 
-# Updated from RFC 1700, ``Assigned Numbers'' (October 1994).  Not all ports +   10 su 
-# are included, only the more common ones. +..
-# +   85 echo $SHELL 
-# The latest IANA port assignments can be gotten from +   86 cat /etc/passwd | grep trainee 
-#       http://www.iana.org/assignments/port-numbers +   87 chsh 
-# The Well Known Ports are those from 0 through 1023+   88 history | more 
-# The Registered Ports are those from 1024 through 49151 +   89 clear 
-# The Dynamic and/or Private Ports are those from 49152 through 65535 +   90 ls 
-# +   91 history
-# Each line describes one service, and is of the form: +
-# +
-# service-name  port/protocol  [aliases ...]   [# comment]+
  
-tcpmux          1/tcp                           # TCP port service multiplexer +[trainee@redhat9 ~]$ !90 
-tcpmux          1/udp                           # TCP port service multiplexer +ls 
-rje             5/tcp                           # Remote Job Entry +aac abc bca Desktop Documents Downloads Music Pictures Public Templates Videos vitext xyz
-rje             5/udp                           # Remote Job Entry +
---More--(0%) +
-[q]+
 </code> </code>
  
-<WRAP center round important 60%> +The command callback function is set up for all users in the **/etc/profile** file. In this file, variables concerning the order callback can be defined. The most important is **HISTSIZE** :
-**Important** - The <key>Enter</key> key scrolls down line by line, the <key>Space Bar</key> key scrolls down page by page and the <key>Q</key> key comes back to the command line prompt. +
-</WRAP> +
- +
-===Command Line Switches=== +
- +
-<WRAP center round todo 60%> +
-**To do** : Use the **--help** option of the **more** command to view the command line switches. +
-</WRAP> +
- +
-====1.22 - The less Command==== +
- +
-The **less** command produces a similar result to that of the **more** command. Practice using the less command and refer to the help using **less --help**. Which command seems the most powerful and versatile ?+
  
 <code> <code>
-[trainee@redhat9 ~]$ less /etc/services +[trainee@redhat9 ~]$ cat /etc/profile | grep HISTSIZE 
-# /etc/services: +HISTSIZE=1000 
-# $Id: services,v 1.49 2017/08/18 12:43:23 ovasik Exp $ +export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE HISTCONTROL
-+
-# Network services, Internet style +
-# IANA services version: last updated 2016-07-08 +
-+
-# Note that it is presently the policy of IANA to assign a single well-known +
-# port number for both TCP and UDP; hence, most entries here have two entries +
-# even if the protocol doesn't support UDP operations. +
-# Updated from RFC 1700, ``Assigned Numbers'' (October 1994).  Not all ports +
-# are included, only the more common ones. +
-+
-# The latest IANA port assignments can be gotten from +
-#       http://www.iana.org/assignments/port-numbers +
-# The Well Known Ports are those from 0 through 1023. +
-# The Registered Ports are those from 1024 through 49151 +
-# The Dynamic and/or Private Ports are those from 49152 through 65535 +
-+
-# Each line describes one service, and is of the form: +
-+
-# service-name  port/protocol  [aliases ...]   [# comment] +
- +
-tcpmux          1/tcp                           # TCP port service multiplexer +
-tcpmux          1/udp                           # TCP port service multiplexer +
-rje             5/tcp                           # Remote Job Entry +
-rje             5/udp                           # Remote Job Entry +
-/etc/services +
-[q]+
 </code> </code>
  
-===Command Line Switches===+You will notice that in the previous case, the value of **HISTSIZE** is **1000**. This implies that the last thousand commands are memorised.
  
-<WRAP center round todo 60%> +The memorised commands are stored in the **~/.bash_history** file. The commands for the current session are not saved in this file until the session is closed:
-**To do** : Use the **--help** option of the **less** command to view the command line switches. +
-</WRAP> +
-  +
-====1.23 - The find Command=== +
- +
-This command is used to search for a specific file or directory. The default path is the **current directory** and default expression is **-print**+
  
 <code> <code>
-[trainee@redhat9 ~]$ find acc +[trainee@redhat9 ~]$ nl .bash_history | tail 
-find: ‘acc’: No such file or directory +    59 ls 
- +    60 ls | sort 
-[trainee@redhat9 ~]$ find aac +    61 ls | sort -r 
-aac+    62 more /etc/services 
 +    63 less /etc/services 
 +    64 find acc 
 +    65 find aac 
 +    66 su - 
 +    67 sleep 10 
 +    68 su -
 </code> </code>
  
 <WRAP center round important 60%> <WRAP center round important 60%>
-**Important** : Note that when the file cannot be found, the find command informs you clearly. However when the file is found, the find command just prints the name of the file to standard output.+**Important**: Note the use of the **nl** command to number the lines in the display of the contents of the **.bash_history** file.
 </WRAP> </WRAP>
  
-===Command Line Switches===+====1.6 - Generating file name endings====
  
-<WRAP center round todo 60%> +The /bin/bash shell is used to generate file name endings. This is accomplished by using the **[Tab]** key. In the following example, the command entered is :
-**To do** : Use the **--help** option of the **find** command to view the command line switches. +
-</WRAP> +
-  +
-====1.24 - The su Command===+
  
-This command is used to change the effective user id and group id to that of the user passed as an argumentWhen executed with no argument, the system assumes the destination user is **root**:+  $ ls .b [Tab][Tab][Tab]
  
 <code> <code>
-[trainee@redhat9 ~]$ su - +[trainee@redhat9 ~]$ ls .bash 
-Password: fenestros +.bash_history .bash_logout .bash_profile .bashrc 
- +
-[root@redhat9 ~]#  +
 </code> </code>
  
 <WRAP center round important 60%> <WRAP center round important 60%>
-**Important** : Note that the password will not be visible.+**Important**: Note that by pressing the <key>tab</key> key three times the shell offers 4 filename completion possibilities. This is because, without more information, the shell does not know which file is involved.
 </WRAP> </WRAP>
  
-===Command Line Switches===+The same possibility exists for generating command name endings. In this case enter the following command:
  
-<WRAP center round todo 60%> +  $ mo [Tab][Tab]
-**To do** : Use the **--help** option of the **su** command to view the command line switches. +
-</WRAP>+
  
-====1.25 - The updatedb and locate Commands==== +Press the <key>tab</key> key twiceYou will get window similar to this one:
- +
-The **locate** command is used to list files in databases that match a pattern supplied as an argument to the commandThe **locate** command uses database. This database needs to be created using the **updatedb** command before using the **locate** command.  +
- +
-The default database is **/var/lib/mlocate/mlocate.db**:+
  
 <code> <code>
-[root@redhat9 ~]# ls -l /var/lib/mlocate/mlocate.db +[trainee@redhat9 ~]$ mo 
--rw-r-----. 1 root slocate 3436535 Sep 25 15:21 /var/lib/mlocate/mlocate.db+modinfo             modulemd-validator  more                mount.composefs     mount.fuse3          
 +modprobe            monitor-sensor      mount               mount.fuse          mountpoint 
 </code> </code>
  
 +====1.7 - The interactive shell ====
  
-<WRAP center round important 60%> +When using the shellwe often need to execute a command on several files instead of processing them individually. For this purpose we can use metacharacters
-**Important** : For information concerning the database formatplease see **man 5 locatedb**. +
-</WRAP>+
  
-The **updatedb** command is configured by editing the **/etc/updatedb.conf** file:+^ Metacharacter ^ Description ^ 
 +***** | Matches one or more characters | 
 +| **?** | Matches a single character | 
 +| **[abc]** | Matches any one of the characters between square brackets | 
 +**[!abc]** | Matches any character except those between square brackets | 
 +| [m-t] | Matches any character from m through to t | 
 +| [!m-t] | Matches any character other than m through to t | 
 +| **?(expression1|expression2| ...)** | Matches 0 or 1 occurence of expression1 OR 0 or 1 occurence of expression2 OR ... | 
 +| ***(expression1|expression2| ...)** | Matches 0 to x occurences of expression1 OR 0 to x occurences of expression2 OR ... | 
 +| **+(expression1|expression2| ...)** | Matches 1 to x occurences of expression1 OR 1 to x occurences of expression2 OR ... | 
 +| **@(expression1|expression2| ...)** | Matches 1 occurrence of expression1 OR 1 occurence of expression2 OR ... | 
 +| **!(expression1|expression2| ...)** | Matches 0 occurrences of expression1 OR 0 occurrences of expression2 OR ... |
  
-<code> +===The * Metacharacter===
-[root@redhat9 ~]# cat /etc/updatedb.conf +
-PRUNE_BIND_MOUNTS "yes" +
-PRUNEFS "9p afs anon_inodefs auto autofs bdev binfmt_misc cgroup cifs coda configfs cpuset debugfs devpts ecryptfs exofs fuse fuse.sshfs fusectl gfs gfs2 gpfs hugetlbfs inotifyfs iso9660 jffs2 lustre mqueue ncpfs nfs nfs4 nfsd pipefs proc ramfs rootfs rpc_pipefs securityfs selinuxfs sfs sockfs sysfs tmpfs ubifs udf usbfs ceph fuse.ceph" +
-PRUNENAMES ".git .hg .svn .bzr .arch-ids {arch} CVS" +
-PRUNEPATHS "/afs /media /mnt /net /sfs /tmp /udev /var/cache/ccache /var/lib/yum/yumdb /var/lib/dnf/yumdb /var/spool/cups /var/spool/squid /var/tmp /var/lib/ceph /var/lib/mock /sysroot/ostree/deploy" +
-</code>+
  
-Use of these two commands is very simple:+In your home directory, create a **training** directory. Then create 5 files in this directory named f1, f2, f3, f4 and f5 respectively:
  
 <code> <code>
-[root@redhat9 ~]# updatedb +[trainee@redhat9 ~]$ mkdir training 
- +[trainee@redhat9 ~]$ cd training 
-[root@redhat9 ~]# locate aac +[trainee@redhat9 training]$ touch f1 f2 f3 f4 f5 
-/home/trainee/aac +[trainee@redhat9 training]$ ls 
-/usr/lib/.build-id/06/c3a6d0cdc5a9b909aac3230f36c0cdc531df73 +f1 f2 f3 f4 f5
-/usr/lib/.build-id/09/896cf90eb4029fa90aacc745e15c2e4057f507 +
-/usr/lib/.build-id/14/801c515faacd31994cac96626b4fc6431c98e3 +
-/usr/lib/.build-id/16/6676d6a86bf3cafaac1899f6388fdb8e337b7c +
-/usr/lib/.build-id/23/6fb54a26ac01da011289125dd0757134b23aac +
-/usr/lib/.build-id/32/2f4ede33bea5be64a2d1d74437fed6aac08dff +
-/usr/lib/.build-id/3c/231a016543a94a4ad2fad826bc3aacfe653af3 +
-/usr/lib/.build-id/3d/104aacf884f203e4a4756eab74e265a10f6649 +
-/usr/lib/.build-id/44/a9047149e3968faa7a0066bbbaac1d728b69e8 +
-/usr/lib/.build-id/4a/9684161daa9e62b9bc5b600aacd967c50e57c4 +
-/usr/lib/.build-id/4e/09a851a069264c701ac18fd1aac4bd656e14fa +
-/usr/lib/.build-id/53/f01644d1fd5ae63b97390282aacf54b0b7d7ce +
-/usr/lib/.build-id/67/3819a49f31f8bbfb5f7eb89a377094fa84eaac +
-/usr/lib/.build-id/68/aa242c520331aacf4985d2a098c5da6614237f +
-/usr/lib/.build-id/7e/eaac475f440b615e0355e10c2c484e129f1474 +
-/usr/lib/.build-id/82/594874aaccba13283a7bfb590a8c2e920ed42a +
-/usr/lib/.build-id/86/e4d1ddaebefae1e0f496ac74ca91064aac13d6 +
-/usr/lib/.build-id/95/430b0d5c622cb1b4691ec85232b7aac072fcb4 +
-/usr/lib/.build-id/98/39921f8f8e36cdaaac8a434953e4c54ca7dd93 +
-/usr/lib/.build-id/9f/7ae04ba24806351a2963e65f1dfaace1f0394b +
-/usr/lib/.build-id/b0/61a09a1e360c89eaac146ce8055ca8d45676fc +
-/usr/lib/.build-id/bf/bf2df2e242f211ebd37ccccbdaaac6bf591bff +
-/usr/lib/.build-id/c6/d48de21818e9eaac2ceb6273840b600a7eac7d +
-/usr/lib/.build-id/c9/8ae396ecaacf790ba4bb73ea16f909ef212163 +
-/usr/lib/.build-id/c9/aac0292a12c0bb393cc5457502a0338f1fb554 +
-/usr/lib/.build-id/cc/b6a8165e506f7aacc1e633dba76719e2192fee +
-/usr/lib/.build-id/d2/d307f71de28588b58faacd57147c666fbd38b0 +
-/usr/lib/.build-id/d6/a427d13f7f07f818ddc87d705d0747eaaac2ba +
-/usr/lib/.build-id/e3/8b781faac831c3d302cc7f83ee9c4f1ab85117 +
-/usr/lib/.build-id/ea/ac093f74b0ec2597caac77f848ccf3fad2b6f5 +
-/usr/lib/.build-id/ef/80915badd5754301e394c245c9c8e5dffaac40 +
-/usr/lib/.build-id/f2/267eb994604adc5efff9aac163613ffeaeb77e +
-/usr/lib/.build-id/f7/9a1addf23c6242b55cfaac4cc39a97d7ed1151 +
-/usr/lib/.build-id/f9/79b85f31aacc55596565106c25f182f55891a7 +
-/usr/lib/.build-id/f9/d198993d87e621b9db59273caace4344254b73 +
-/usr/lib/.build-id/fa/d302f61d5aacdead41db2d128dd0a52eb2b411 +
-/usr/lib/fontconfig/cache/d63f98f14a274bd69a5425fc33aaac6b-le64.cache-8 +
-/usr/lib/modules/5.14.0-284.11.1.el9_2.x86_64/kernel/drivers/scsi/aacraid +
-/usr/lib/modules/5.14.0-284.11.1.el9_2.x86_64/kernel/drivers/scsi/aacraid/aacraid.ko.xz +
-/usr/lib/modules/5.14.0-427.37.1.el9_4.x86_64/kernel/drivers/scsi/aacraid +
-/usr/lib/modules/5.14.0-427.37.1.el9_4.x86_64/kernel/drivers/scsi/aacraid/aacraid.ko.xz +
-/usr/lib64/libfdk-aac.so.2 +
-/usr/lib64/libfdk-aac.so.2.0.0 +
-/usr/lib64/gstreamer-1.0/libgstfdkaac.so +
-/usr/lib64/spa-0.2/bluez5/libspa-codec-bluez5-aac.so +
-/usr/share/doc/fdk-aac-free +
-/usr/share/doc/fdk-aac-free/ChangeLog +
-/usr/share/doc/fdk-aac-free/README.fedora +
-/usr/share/licenses/fdk-aac-free +
-/usr/share/licenses/fdk-aac-free/NOTICE +
-/usr/share/mime/audio/aac.xml+
 </code> </code>
  
-The default database is **/var/lib/mlocate/mlocate.db** :+To demonstrate the use of the metacharacter *, enter the following command:
  
 <code> <code>
-[root@redhat9 ~]# ls -l /var/lib/mlocate/mlocate.db +[trainee@redhat9 training]$ echo f* 
--rw-r-----. 1 root slocate 3436535 Sep 25 15:21 /var/lib/mlocate/mlocate.db+f1 f2 f3 f4 f5
 </code> </code>
  
 <WRAP center round important 60%> <WRAP center round important 60%>
-**Important**: For more information about the database format, see **man 5 locatedb**.+**Important**: Note that the ***** character replaces a character or a string of characters.
 </WRAP> </WRAP>
  
-===Command Line Switches===+===The ? Metacharacter===
  
-<WRAP center round todo 60%> +Now create the f52 and f62 files:
-**To do** : Use the **--help** option of the **updatedb** and **locate** commands to view their command line switches. +
-</WRAP> +
- +
-==== 1.26 - The whereis Command=== +
- +
-This command is used to show the full paths of the executable, the configuration files and the manuals associated with the argument+
  
 <code> <code>
-[root@redhat9 ~]# whereis passwd +[trainee@redhat9 training]$ touch f52 f62
-passwd: /usr/bin/passwd /etc/passwd /usr/share/man/man5/passwd.5.gz /usr/share/man/man1/passwd.1ossl.gz /usr/share/man/man1/passwd.1.gz+
 </code> </code>
  
-===Command Line Switches=== +Then enter the following command:
- +
-<WRAP center round todo 60%> +
-**To do** : Use the **--help** option of the **whereis** command to view the command line switches. +
-</WRAP> +
- +
-==== 1.27 - The which Command==== +
- +
-This command searches the PATH variable and returns to standard output the first full path associated with the argument:+
  
 <code> <code>
-[root@redhat9 ~]# which passwd +[trainee@redhat9 training]$ echo f?2 
-/usr/bin/passwd+f52 f62
 </code> </code>
  
-===Command Line Switches=== +<WRAP center round important 60%> 
- +**Important**: Note that the **?** character replaces **a single** character.
-<WRAP center round todo 60%> +
-**To do** : Use the **--help** option of the **which** command to view the command line switches.+
 </WRAP> </WRAP>
  
-====1.28 - The uptime Command====+===The [] Metacharacter===
  
-This command prints to standard output the current time, the length of time the system has been up, the number of users on the system and the average number of jobs in the run queue over the last 1, 5 and 15 minutes:+Usage can take several different forms:
  
-<code> +^ Metacharacter ^ Description ^ 
-[root@redhat9 ~]# uptime +[xyz| Represents either x or y or z | 
- 15:27:33 up  2:42,  1 user,  load average: 0.00, 0.00, 0.00 +| [m-t] | Represents a character in the range m to t | 
-</code> +| [!xyz] | Represents any character other than x or y or z | 
- +| [!m-t] | Represents any character outside of the range m to t |
-===Command Line Switches=== +
- +
-The switches associated with this command are: +
- +
-<WRAP center round todo 60%> +
-**To do** : Use the **--help** option of the **uptime** command to view the command line switches. +
-</WRAP> +
- +
-====1.29 - The w Command====+
  
-This command outputs the same data as the **uptime** command on the first line and then complements this information with the details of each user connected to the system, including what each user is currently doing. This is the replacement under Linux for the Unix command **whodo**:+To demonstrate the use of the characters **[** and **]**, create the file a100 
  
 <code> <code>
-[root@redhat9 ~]# w +[trainee@redhat9 training]$ touch a100
- 15:28:01 up  2:43,  1 user,  load average: 0.00, 0.00, 0.00 +
-USER     TTY        LOGIN@   IDLE   JCPU   PCPU WHAT +
-trainee  pts/0     12:47    1.00s  0.13s  0.02s sshd: trainee [priv]+
 </code> </code>
  
-The JCPU time is the time used by all processes attached to the tty. It does not include past background jobs, but does include currently running background jobs. +Then enter the following commands and note the result
- +
-The PCPU time is the time used by the current process, named in the **what** field.  +
- +
-===Command Line Switches=== +
- +
-<WRAP center round todo 60%> +
-**To do** : Use the **--help** option of the **w** command to view the command line switches. +
-</WRAP> +
- +
-====1.30 - The uname Command==== +
- +
-This command prints system information to the standard output:+
  
 <code> <code>
-[root@redhat9 ~]# uname -a +[trainee@redhat9 training]$ echo [a-f]* 
-Linux redhat9.ittraining.loc 5.14.0-427.37.1.el9_4.x86_64 #1 SMP PREEMPT_DYNAMIC Fri Sep 13 12:41:50 EDT 2024 x86_64 x86_64 x86_64 GNU/Linux +a100 f1 f2 f3 f4 f5 f52 f62
- +
-[root@redhat9 ~]# uname -s +
-Linux +
- +
-[root@redhat9 ~]# uname -n +
-redhat9.ittraining.loc +
- +
-[root@redhat9 ~]# uname -r +
-5.14.0-427.37.1.el9_4.x86_64 +
- +
-[root@redhat9 ~]# uname -v +
-#1 SMP PREEMPT_DYNAMIC Fri Sep 13 12:41:50 EDT 2024 +
- +
-[root@redhat9 ~]# uname -m +
-x86_64 +
- +
-[root@redhat9 ~]# uname -p +
-x86_64 +
- +
-[root@redhat9 ~]# uname -i +
-x86_64 +
- +
-[root@redhat9 ~]# uname -o +
-GNU/Linux+
 </code> </code>
  
-===Command Line Switches=== +<WRAP center round important 60%> 
- +**Important**: Note here that all files starting with the letters **a**, **b**, **c**, **d**, **e** or **f** are displayed on the screen.
-<WRAP center round todo 60%> +
-**To do** : Use the **--help** option of the **uname** command to view the command line switches.+
 </WRAP> </WRAP>
- 
-====1.31 - The du Command==== 
- 
-This command summarizes disk usage of each file, recursively for directories: 
  
 <code> <code>
-[root@redhat9 ~]# du -sh /2>/dev/null +[trainee@redhat9 training]$ echo [af]* 
-0       /afs +a100 f1 f2 f3 f4 f5 f52 f62
-0       /bin +
-358M    /boot +
-0       /dev +
-29M     /etc +
-4.4M    /home +
-0       /lib +
-0       /lib64 +
-0       /media +
-0       /mnt +
-0       /opt +
-0       /proc +
-2.0G    /root +
-9.2M    /run +
-0       /sbin +
-0       /srv +
-0       /sys +
-12K     /tmp +
-4.0G    /usr +
-368M    /var+
 </code> </code>
  
 <WRAP center round important 60%> <WRAP center round important 60%>
-**Important** : Note the use of the **2>/dev/null** redirection. This sends all eventual errors in the **file descriptor** 2 directly to **/dev/null** so that they do not appear in the output. File descriptors are covered in the **The Command Line Interface** unit.+**Important**: Note here that all files starting with the letters **a** or **f** are displayed on the screen.
 </WRAP> </WRAP>
- 
-===Command Line Switches=== 
- 
-<WRAP center round todo 60%> 
-**To do** : Use the **--help** option of the **du** command to view the command line switches. 
-</WRAP> 
- 
-==== 1.32 - The clear Command ==== 
- 
-This command is used to clear the current screen of the terminal: 
  
 <code> <code>
-[root@redhat9 ~]# clear +[trainee@redhat9 training]$ echo [!a]
- +f1 f2 f3 f4 f5 f52 f62
-[root@redhat9 ~]+
 </code> </code>
  
-==== 1.33 - The exit Command ==== +<WRAP center round important 60%> 
- +**Important**: Note here that all files are displayed on the screen, with the exception of one file beginning with the letter **a** .
-This command exits the current shell: +
- +
-<code> +
-[root@redhat9 ~]# exit +
-logout +
-[trainee@redhat9 ~]$   +
-</code> +
- +
-===Command Line Switches=== +
- +
-<WRAP center round todo 60%> +
-**To do** : Use the **help** command with **exit** option to view the command line switches.+
 </WRAP> </WRAP>
- 
-====1.34 - The logout Command==== 
- 
-This command logs out a user from a login shell writing the utmp and wtmp entries in the log files. 
- 
-===Command Line Switches=== 
- 
-<WRAP center round todo 60%> 
-**To do** : Use the **help** command with **logout** option to view the command line switches. 
-</WRAP> 
- 
-====1.35 - The sleep Command ==== 
- 
-This command pauses for a number seconds. The number is specified as the first argument. 
  
 <code> <code>
-[trainee@redhat9 ~]$ sleep 10 +[trainee@redhat9 training]$ echo [a-b]* 
 +a100
 </code> </code>
  
-===Command Line Switches=== +<WRAP center round important 60%> 
- +**Important**: Note here that only the file starting with the letter **a** is displayed on the screen as there are no files starting with the letter **b**.
-<WRAP center round todo 60%> +
-**To do** : Use the **--help** option of the **sleep** command to view the command line switches.+
 </WRAP> </WRAP>
- 
-====1.36 - The wall Command==== 
- 
-Wall sends a message to everybody logged in with their mesg(1) permission set to yes. The message can be given as an argument to wall, or it can be sent to wall's standard input.  When using the standard input from a terminal, the message should be terminated with the EOF key (usually Control-D). The length of the message is limited to 20 lines. For every invocation of wall a notification will be written to syslog, with facility LOG_USER and level LOG_INFO: 
  
 <code> <code>
-[trainee@redhat9 ~]$ su - +[trainee@redhat9 training]$ echo [a-f] 
-Password: fenestros +[a-f]
- +
-[root@redhat9 ~]# wall this is a message from root +
-                                                                                +
-Broadcast message from root@redhat9.ittraining.loc (pts/0) (Wed Sep 25 15:31:46 +
-                                                                                +
-this is a message from root+
 </code> </code>
  
-The wall command ignores the TZ environment variable. The time displayed on the first page is based on the system's regionalisation parameters: +<WRAP centre round important 60%
- +**Important**Note that in this case, there are no files named **a**, **b****c****d**, **e** or **f**. For this reason, having found no correspondence between the filter used and the objects in the current directory, the **echo** command returns the filter passed as an argument, i.e. **[a-f]**.
-<code+
-[root@redhat9 ~]# date +
-Wed Sep 25 03:33:11 PM CEST 2024 +
-</code> +
- +
-====1.37 - The seq Command==== +
- +
-The **seq** command prints numbers from FIRST to LASTin steps of INCREMENT: +
- +
-  seq [OPTION]... LAST +
-  seq [OPTION]... FIRST LAST +
-  seq [OPTION]... FIRST INCREMENT LAST +
- +
-For example : +
- +
-<code> +
-[root@redhat9 ~]# seq 10 +
-+
-+
-+
-+
-+
-+
-+
-+
-+
-10 +
- +
-[root@redhat9 ~]# seq 10 20 +
-10 +
-11 +
-12 +
-13 +
-14 +
-15 +
-16 +
-17 +
-18 +
-19 +
-20 +
- +
-[root@redhat9 ~]# seq 20 10 90 +
-20 +
-30 +
-40 +
-50 +
-60 +
-70 +
-80 +
-90 +
-</code> +
- +
-===Command Line Switches=== +
- +
-<WRAP center round todo 60%> +
-**To do** : Use the **--help** option of the **seq** command to view the command line switches.+
 </WRAP> </WRAP>
  
-====1.38 - The screen Command====+====1.- The extglob option==== 
  
-Screen is a full-screen window manager that multiplexes a physical terminal between several processes (typically interactive  shells). Each virtual terminal provides the functions of a DEC VT100 terminal andin additionseveral control functions from the ISO 6429 (ECMA 48ANSI X3.64) and ISO 2022 standards (e.g. insert/delete line and support for multiple character sets). There is a  scrollback history buffer for each virtual terminal and a copy-and-paste mechanism that allows moving text regions between windows. +Enable the **extglob** option in the bash shell so that you can use **?(expression), *(expression)+(expression)@(expression) and !(expression)**:
- +
-The screen command is not installed by default under RHEL 9:+
  
 <code> <code>
-[root@redhat9 ~]# which screen +[trainee@redhat9 training]$ shopt -s extglob
-/usr/bin/which: no screen in (/root/.local/bin:/root/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin) +
- +
-[root@redhat9 ~]# dnf makecache +
-Updating Subscription Management repositories. +
-Red Hat Enterprise Linux 9 for x86_64 - AppStream (RPMs)                  25 kB/s | 4.5 kB     00:00     +
-Red Hat Enterprise Linux 9 for x86_64 - BaseOS (RPMs)                     25 kB/s | 4.1 kB     00:00     +
-Metadata cache created. +
- +
-[root@redhat9 ~]# dnf install screen -y +
-Updating Subscription Management repositories. +
-Last metadata expiration check: 0:00:49 ago on Wed 25 Sep 2024 03:35:01 PM CEST. +
-No match for argument: screen +
-Error: Unable to find a match: screen +
- +
-[root@redhat9 ~]# subscription-manager repos --enable codeready-builder-for-rhel-9-$(arch)-rpms +
-Repository 'codeready-builder-for-rhel-9-x86_64-rpms' is enabled for this system. +
- +
-[root@redhat9 ~]# dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm +
-Updating Subscription Management repositories. +
-Red Hat CodeReady Linux Builder for RHEL 9 x86_64 (RPMs)                 5.0 MB/| 9.1 MB     00:01     +
-Last metadata expiration check: 0:00:01 ago on Wed 25 Sep 2024 03:39:17 PM CEST. +
-epel-release-latest-9.noarch.rpm                                         158 kB/s |  18 kB     00:00     +
-Dependencies resolved. +
-========================================================================================================= +
- Package                    Architecture         Version                Repository                  Size +
-========================================================================================================= +
-Installing: +
- epel-release               noarch               9-8.el9                @commandline                18 k +
- +
-Transaction Summary +
-========================================================================================================= +
-Install  1 Package +
- +
-Total size: 18 k +
-Installed size: 26 k +
-Is this ok [y/N]: y +
-Downloading Packages: +
-Running transaction check +
-Transaction check succeeded. +
-Running transaction test +
-Transaction test succeeded. +
-Running transaction +
-  Preparing        :                                                                                 1/1  +
-  Installing       : epel-release-9-8.el9.noarch                                                     1/1  +
-  Running scriptlet: epel-release-9-8.el9.noarch                                                     1/1  +
-Many EPEL packages require the CodeReady Builder (CRB) repository. +
-It is recommended that you run /usr/bin/crb enable to enable the CRB repository. +
- +
-  Verifying        : epel-release-9-8.el9.noarch                                                     1/1  +
-Installed products updated. +
- +
-Installed: +
-  epel-release-9-8.el9.noarch                                                                             +
- +
-Complete! +
- +
-[root@redhat9 ~]# dnf install screen +
-Updating Subscription Management repositories. +
-Extra Packages for Enterprise Linux 9 - Next - x86_64                    179 kB/s | 276 kB     00:01     +
-Last metadata expiration check: 0:00:01 ago on Wed 25 Sep 2024 03:43:49 PM CEST. +
-Dependencies resolved. +
-========================================================================================================= +
- Package                Architecture           Version                        Repository            Size +
-========================================================================================================= +
-Installing: +
- screen                 x86_64                 4.8.0-6.el9                    epel                 649 k +
- +
-Transaction Summary +
-========================================================================================================= +
-Install  1 Package +
- +
-Total download size: 649 k +
-Installed size: 957 k +
-Is this ok [y/N]: y +
-Downloading Packages: +
-screen-4.8.0-6.el9.x86_64.rpm                                            1.0 MB/s | 649 kB     00:00     +
---------------------------------------------------------------------------------------------------------- +
-Total                                                                    875 kB/s | 649 kB     00:00      +
-Running transaction check +
-Transaction check succeeded. +
-Running transaction test +
-Transaction test succeeded. +
-Running transaction +
-  Preparing        :                                                                                 1/1  +
-  Running scriptlet: screen-4.8.0-6.el9.x86_64                                                       1/1  +
-  Installing       : screen-4.8.0-6.el9.x86_64                                                       1/1  +
-  Running scriptlet: screen-4.8.0-6.el9.x86_64                                                       1/1  +
-  Verifying        : screen-4.8.0-6.el9.x86_64                                                       1/1  +
-Installed products updated. +
- +
-Installed: +
-  screen-4.8.0-6.el9.x86_64                                                                               +
- +
-Complete!+
 </code> </code>
  
-Create a session with screen:+The **shopt** command is used to enable or disable options for optional shell behaviour. The list of options can be viewed by executing the **shopt** command without options:
  
 <code> <code>
-[root@redhat9 ~]# screen -S mysession+[trainee@redhat9 training]$ shopt 
 +autocd off 
 +assoc_expand_once off 
 +cdable_vars off 
 +cdspell off 
 +checkhash off 
 +checkjobs off 
 +checkwinsize on 
 +cmdhist on 
 +compat31 off 
 +compat32 off 
 +compat40 off 
 +compat41 off 
 +compat42 off 
 +compat43 off 
 +compat44 off 
 +complete_fullquote on 
 +direxpand off 
 +dirspell off 
 +dotglob off 
 +execfail off 
 +expand_aliases on 
 +extdebug off 
 +extglob on 
 +extquote on 
 +failglob off 
 +force_fignore on 
 +globasciiranges on 
 +globstar off 
 +gnu_errfmt off 
 +histappend on 
 +histreedit off 
 +histverify off 
 +hostcomplete off 
 +huponexit off 
 +inherit_errexit off 
 +interactive_comments on 
 +lastpipe off 
 +lithist off 
 +localvar_inherit off 
 +localvar_unset off 
 +login_shell on 
 +mailwarn off 
 +no_empty_cmd_completion off 
 +nocaseglob off 
 +nocasematch off 
 +nullglob off 
 +progcomp on 
 +progcomp_alias off 
 +promptvars on 
 +restricted_shell off 
 +shift_verbose off 
 +sourcepath on 
 +syslog_history off 
 +xpg_echo off
 </code> </code>
  
-Now press the <key>CTRL</key> and <key>a</key> keys, release the <key>a</key> key and press the <key>c</key> key in order to create a second **nested** screen.+===?(expression)===
  
-To return to the first screenuse the <key>CTRL</key> <key>a</key> <key>a</key> keysThis allows you to toggle between the last two screens used. +Create the files ff.txt, f123.txtf123123.txt, f123123123.txt :
- +
-To see the status of all active screensuse the **screen -ls** command:+
  
 <code> <code>
-[root@redhat9 ~]# screen -ls +[trainee@redhat9 training]$ touch f f.txt f123.txt f123123.txt f123123123.txt
-There is a screen on: +
-        3103.mysession  (Attached) +
-1 Socket in /run/screen/S-root.+
 </code> </code>
  
-Now enter the following commands:+Enter the following command:
  
 <code> <code>
-[root@redhat9 ~]# sleep 999 & +[trainee@redhat9 training]$ ls f?(123).txt 
-[1] 3153 +f123.txt f.txt
- +
-[root@redhat9 ~]# jobs -l +
-[1]+  3153 Running                 sleep 999 & +
- +
-[root@redhat9 ~]#+
 </code> </code>
  
-In order to detach the current screen press the <key>CTRL</key> and <key>a</key> keys, release the <key>a</key> key and press the <key>d</keykey:+<WRAP centre round important 60%> 
 +**Important**: Note here that the command displays files with names containing 0 or 1 occurrences of the string **123**. 
 +</WRAP>
  
-<code> +===*(expression)===
-[root@redhat9 ~]# screen -S mysession +
-[detached from 3103.mysession]+
  
-[root@redhat9 ~]# +Enter the following command:
-</code> +
- +
-To re-attach the screen, execute the following command:+
  
 <code> <code>
-[root@redhat9 ~]# screen -r+[trainee@redhat9 training]$ ls f*(123).txt 
 +f123123123.txt f123123.txt f123123.txt f.txt
 </code> </code>
  
-Using the jobs command, check if the process created by the sleep command is still running: +<WRAP centre round important 60%
- +**Important**: Note here that the command displays files with names containing from 0 up to x occurrences of the string **123**.
-<code+
-[root@redhat9 ~]# jobs -l +
-[1]+  3153 Running                 sleep 999 & +
- +
-[root@redhat9 ~]# +
-</code> +
- +
-To move forward or backwards between screens press the <key>CTRL</key> and <key>a</key> keys, release the <key>a</key> key and press the <key>n</key> key or press the <key>CTRL</key> and <key>a</key> keys, release the <key>a</key> key and press the <key>p</key> key. +
- +
-Once again detach the current screen by pressing the <key>CTRL</key> <key>a</key> keys, releasing the <key>a</key> key and then pressing <key>d</key>: +
- +
-<code> +
-[root@redhat9 ~]# screen -S mysession +
-[detached from 3103.mysession] +
- +
-[root@redhat9 ~]# +
-</code> +
- +
-Now create a new, non-nested screen: +
- +
-<code> +
-[root@redhat9 ~]# screen -S mysession1 +
-</code> +
- +
-Use the **screen -ls** command to see what has happened: +
- +
-<code> +
-[root@redhat9 ~]# screen -ls +
-There are screens on: +
-        3181.mysession1 (Attached) +
-        3103.mysession  (Detached) +
-2 Sockets in /run/screen/S-root. +
-</code> +
- +
-Note, however, that this screen 0 is not the same as the previous screen 0 in which you executed the sleep command+
- +
-<code> +
-[root@redhat9 ~]# jobs -l +
-[root@redhat9 ~]# +
-</code> +
- +
-To re-attach a specific screen, reference it by it's number: +
- +
-<code> +
-[root@redhat9 ~]# screen -r 3103 +
- +
-[root@redhat9 ~]# screen -ls +
-There are screens on: +
-        3181.mysession1 (Attached) +
-        3103.mysession  (Attached) +
-2 Sockets in /run/screen/S-root. +
-</code> +
- +
-Once again detach the current screen by pressing the <key>CTRL</key> <key>a</key> keys, releasing the <key>a</key> key and then pressing <key>d</key>: +
- +
-<code> +
-[root@redhat9 ~]# screen -S mysession1 +
-[detached from 3181.mysession1] +
- +
-[root@redhat9 ~]#  +
-</code> +
- +
-Now check which screen you are connected to+
- +
-<code> +
-[root@redhat9 ~]# screen -ls +
-There are screens on: +
-        3181.mysession1 (Detached) +
-        3103.mysession  (Attached) +
-2 Sockets in /run/screen/S-root. +
-</code> +
- +
-Finally, kill the two sessions: +
- +
-<code> +
-[root@redhat9 ~]# screen -ls +
-There are screens on: +
-        3181.mysession1 (Detached) +
-        3103.mysession  (Attached) +
-2 Sockets in /run/screen/S-root. +
-</code> +
- +
-Tuez maintenant les deux sessions : +
- +
-<code> +
-[root@redhat9 ~]# screen -XS 3181 quit +
- +
-[root@redhat9 ~]# screen -ls +
-There is a screen on: +
-        3103.mysession  (Detached) +
-1 Socket in /run/screen/S-root. +
- +
-[root@redhat9 ~]# screen -XS 3103 quit +
- +
-[root@redhat9 ~]# screen -ls +
-No Sockets found in /run/screen/S-root. +
- +
-</code> +
- +
-===Command Line Switches=== +
- +
-<WRAP center round todo 60%> +
-**To do** : Use the **--help** option of the **screen** command to view the command line switches.+
 </WRAP> </WRAP>
  
-=====LAB #2 - Switches and Arguments=====+===+(expression)===
  
-Switches under Linux can either be short or long. Several differences are important to note.  +Enter the following command:
- +
-Firstly short options are generally preceded by a single dash **-**, whilst long options are preceded by a double dash **- -**. +
- +
-An example is the help option used with most commands: +
- +
-  * -h +
-  * --help +
- +
-Secondly, Linux short switches can be combined whereas long switches cannot be combined. For example **ls -l -a -i** can also be written as **ls -lai**, **ls -lia** or **ls -ali**:+
  
 <code> <code>
-[root@redhat9 ~]ls -lai /tmp +[trainee@redhat9 training]ls f+(123).txt 
-total 12 +f123123123.txt f123123.txt f123.txt
- 33554561 drwxrwxrwt. 16 root root 4096 Sep 25 15:54 +
-      128 dr-xr-xr-x18 root root  235 Oct 19  2023 .. +
- 33786429 srwxrwxrwx.  1 gdm  gdm     0 Sep 25 12:30 dbus-G7skg3Wlpv +
- 33625153 srwxrwxrwx.  1 gdm  gdm     0 Sep 25 12:45 dbus-s2vBGtxTHi +
- 33554609 drwxrwxrwt.  2 root root    6 Sep 25 12:30 .font-unix +
- 34654589 drwxrwxrwt.  2 root root   18 Sep 25 12:44 .ICE-unix +
- 33625083 drwxr-xr-x.  2 root root   54 Sep 25 13:10 inode +
-100664689 drwx------.  3 root root   17 Sep 25 12:45 systemd-private-7e6b4544d8d34a9bb30a13aeb8e4e02a-colord.service-FfNuds +
-    10601 drwx------.  3 root root   17 Sep 25 12:44 systemd-private-7e6b4544d8d34a9bb30a13aeb8e4e02a-dbus-broker.service-VIpKgR +
- 67157623 drwx------.  3 root root   17 Sep 25 12:44 systemd-private-7e6b4544d8d34a9bb30a13aeb8e4e02a-kdump.service-0SbYbm +
- 67157622 drwx------.  3 root root   17 Sep 25 12:44 systemd-private-7e6b4544d8d34a9bb30a13aeb8e4e02a-ModemManager.service-k4DpLF +
- 67155430 drwx------.  3 root root   17 Sep 25 12:44 systemd-private-7e6b4544d8d34a9bb30a13aeb8e4e02a-power-profiles-daemon.service-mIx9S5 +
- 67155431 drwx------.  3 root root   17 Sep 25 12:44 systemd-private-7e6b4544d8d34a9bb30a13aeb8e4e02a-rtkit-daemon.service-2gD28Z +
- 67157618 drwx------.  3 root root   17 Sep 25 12:44 systemd-private-7e6b4544d8d34a9bb30a13aeb8e4e02a-switcheroo-control.service-rLbOK4 +
- 67157619 drwx------.  3 root root   17 Sep 25 12:44 systemd-private-7e6b4544d8d34a9bb30a13aeb8e4e02a-systemd-logind.service-uLNyfd +
- 67157620 drwx------.  3 root root   17 Sep 25 12:44 systemd-private-7e6b4544d8d34a9bb30a13aeb8e4e02a-upower.service-bIpAUN +
- 33625086 -r--r--r--.  1 gdm  gdm    11 Sep 25 12:45 .X1024-lock +
- 33625152 -r--r--r--.  1 gdm  gdm    11 Sep 25 12:45 .X1025-lock +
-  2074740 drwxrwxrwt.  2 root root   32 Sep 25 12:45 .X11-unix +
-    10599 drwxrwxrwt.  2 root root    6 Sep 25 12:30 .XIM-unix +
- +
-[root@redhat9 ~]# ls -ali /tmp +
-total 12 +
- 33554561 drwxrwxrwt. 16 root root 4096 Sep 25 15:54 . +
-      128 dr-xr-xr-x. 18 root root  235 Oct 19  2023 .. +
- 33786429 srwxrwxrwx.  1 gdm  gdm     0 Sep 25 12:30 dbus-G7skg3Wlpv +
- 33625153 srwxrwxrwx.  1 gdm  gdm     0 Sep 25 12:45 dbus-s2vBGtxTHi +
- 33554609 drwxrwxrwt.  2 root root    6 Sep 25 12:30 .font-unix +
- 34654589 drwxrwxrwt.  2 root root   18 Sep 25 12:44 .ICE-unix +
- 33625083 drwxr-xr-x.  2 root root   54 Sep 25 13:10 inode +
-100664689 drwx------.  3 root root   17 Sep 25 12:45 systemd-private-7e6b4544d8d34a9bb30a13aeb8e4e02a-colord.service-FfNuds +
-    10601 drwx------.  3 root root   17 Sep 25 12:44 systemd-private-7e6b4544d8d34a9bb30a13aeb8e4e02a-dbus-broker.service-VIpKgR +
- 67157623 drwx------.  3 root root   17 Sep 25 12:44 systemd-private-7e6b4544d8d34a9bb30a13aeb8e4e02a-kdump.service-0SbYbm +
- 67157622 drwx------.  3 root root   17 Sep 25 12:44 systemd-private-7e6b4544d8d34a9bb30a13aeb8e4e02a-ModemManager.service-k4DpLF +
- 67155430 drwx------.  3 root root   17 Sep 25 12:44 systemd-private-7e6b4544d8d34a9bb30a13aeb8e4e02a-power-profiles-daemon.service-mIx9S5 +
- 67155431 drwx------.  3 root root   17 Sep 25 12:44 systemd-private-7e6b4544d8d34a9bb30a13aeb8e4e02a-rtkit-daemon.service-2gD28Z +
- 67157618 drwx------.  3 root root   17 Sep 25 12:44 systemd-private-7e6b4544d8d34a9bb30a13aeb8e4e02a-switcheroo-control.service-rLbOK4 +
- 67157619 drwx------.  3 root root   17 Sep 25 12:44 systemd-private-7e6b4544d8d34a9bb30a13aeb8e4e02a-systemd-logind.service-uLNyfd +
- 67157620 drwx------.  3 root root   17 Sep 25 12:44 systemd-private-7e6b4544d8d34a9bb30a13aeb8e4e02a-upower.service-bIpAUN +
- 33625086 -r--r--r--.  1 gdm  gdm    11 Sep 25 12:45 .X1024-lock +
- 33625152 -r--r--r--.  1 gdm  gdm    11 Sep 25 12:45 .X1025-lock +
-  2074740 drwxrwxrwt.  2 root root   32 Sep 25 12:45 .X11-unix +
-    10599 drwxrwxrwt.  2 root root    6 Sep 25 12:30 .XIM-unix +
- +
-[root@redhat9 ~]# ls -ial /tmp +
-total 12 +
- 33554561 drwxrwxrwt. 16 root root 4096 Sep 25 15:54 . +
-      128 dr-xr-xr-x. 18 root root  235 Oct 19  2023 .. +
- 33786429 srwxrwxrwx.  1 gdm  gdm     0 Sep 25 12:30 dbus-G7skg3Wlpv +
- 33625153 srwxrwxrwx.  1 gdm  gdm     0 Sep 25 12:45 dbus-s2vBGtxTHi +
- 33554609 drwxrwxrwt.  2 root root    6 Sep 25 12:30 .font-unix +
- 34654589 drwxrwxrwt.  2 root root   18 Sep 25 12:44 .ICE-unix +
- 33625083 drwxr-xr-x.  2 root root   54 Sep 25 13:10 inode +
-100664689 drwx------.  3 root root   17 Sep 25 12:45 systemd-private-7e6b4544d8d34a9bb30a13aeb8e4e02a-colord.service-FfNuds +
-    10601 drwx------.  3 root root   17 Sep 25 12:44 systemd-private-7e6b4544d8d34a9bb30a13aeb8e4e02a-dbus-broker.service-VIpKgR +
- 67157623 drwx------.  3 root root   17 Sep 25 12:44 systemd-private-7e6b4544d8d34a9bb30a13aeb8e4e02a-kdump.service-0SbYbm +
- 67157622 drwx------.  3 root root   17 Sep 25 12:44 systemd-private-7e6b4544d8d34a9bb30a13aeb8e4e02a-ModemManager.service-k4DpLF +
- 67155430 drwx------.  3 root root   17 Sep 25 12:44 systemd-private-7e6b4544d8d34a9bb30a13aeb8e4e02a-power-profiles-daemon.service-mIx9S5 +
- 67155431 drwx------.  3 root root   17 Sep 25 12:44 systemd-private-7e6b4544d8d34a9bb30a13aeb8e4e02a-rtkit-daemon.service-2gD28Z +
- 67157618 drwx------.  3 root root   17 Sep 25 12:44 systemd-private-7e6b4544d8d34a9bb30a13aeb8e4e02a-switcheroo-control.service-rLbOK4 +
- 67157619 drwx------.  3 root root   17 Sep 25 12:44 systemd-private-7e6b4544d8d34a9bb30a13aeb8e4e02a-systemd-logind.service-uLNyfd +
- 67157620 drwx------.  3 root root   17 Sep 25 12:44 systemd-private-7e6b4544d8d34a9bb30a13aeb8e4e02a-upower.service-bIpAUN +
- 33625086 -r--r--r--.  1 gdm  gdm    11 Sep 25 12:45 .X1024-lock +
- 33625152 -r--r--r--.  1 gdm  gdm    11 Sep 25 12:45 .X1025-lock +
-  2074740 drwxrwxrwt.  2 root root   32 Sep 25 12:45 .X11-unix +
-    10599 drwxrwxrwt 2 root root    6 Sep 25 12:30 .XIM-unix+
 </code> </code>
  
-However **ls -l --all --inode** cannot be written **ls -l --allinode**: +<WRAP centre round important 60%> 
- +**Important** : Note here that the command displays files with names containing between 1 and x occurrences of the string **123**.
-<code> +
-[root@redhat9 ~]# ls -l --all --inode /tmp +
-total 12 +
- 33554561 drwxrwxrwt. 16 root root 4096 Sep 25 15:54 . +
-      128 dr-xr-xr-x. 18 root root  235 Oct 19  2023 .. +
- 33786429 srwxrwxrwx.  1 gdm  gdm     0 Sep 25 12:30 dbus-G7skg3Wlpv +
- 33625153 srwxrwxrwx.  1 gdm  gdm     0 Sep 25 12:45 dbus-s2vBGtxTHi +
- 33554609 drwxrwxrwt.  2 root root    6 Sep 25 12:30 .font-unix +
- 34654589 drwxrwxrwt.  2 root root   18 Sep 25 12:44 .ICE-unix +
- 33625083 drwxr-xr-x.  2 root root   54 Sep 25 13:10 inode +
-100664689 drwx------.  3 root root   17 Sep 25 12:45 systemd-private-7e6b4544d8d34a9bb30a13aeb8e4e02a-colord.service-FfNuds +
-    10601 drwx------.  3 root root   17 Sep 25 12:44 systemd-private-7e6b4544d8d34a9bb30a13aeb8e4e02a-dbus-broker.service-VIpKgR +
- 67157623 drwx------.  3 root root   17 Sep 25 12:44 systemd-private-7e6b4544d8d34a9bb30a13aeb8e4e02a-kdump.service-0SbYbm +
- 67157622 drwx------.  3 root root   17 Sep 25 12:44 systemd-private-7e6b4544d8d34a9bb30a13aeb8e4e02a-ModemManager.service-k4DpLF +
- 67155430 drwx------.  3 root root   17 Sep 25 12:44 systemd-private-7e6b4544d8d34a9bb30a13aeb8e4e02a-power-profiles-daemon.service-mIx9S5 +
- 67155431 drwx------.  3 root root   17 Sep 25 12:44 systemd-private-7e6b4544d8d34a9bb30a13aeb8e4e02a-rtkit-daemon.service-2gD28Z +
- 67157618 drwx------.  3 root root   17 Sep 25 12:44 systemd-private-7e6b4544d8d34a9bb30a13aeb8e4e02a-switcheroo-control.service-rLbOK4 +
- 67157619 drwx------.  3 root root   17 Sep 25 12:44 systemd-private-7e6b4544d8d34a9bb30a13aeb8e4e02a-systemd-logind.service-uLNyfd +
- 67157620 drwx------.  3 root root   17 Sep 25 12:44 systemd-private-7e6b4544d8d34a9bb30a13aeb8e4e02a-upower.service-bIpAUN +
- 33625086 -r--r--r--.  1 gdm  gdm    11 Sep 25 12:45 .X1024-lock +
- 33625152 -r--r--r--.  1 gdm  gdm    11 Sep 25 12:45 .X1025-lock +
-  2074740 drwxrwxrwt.  2 root root   32 Sep 25 12:45 .X11-unix +
-    10599 drwxrwxrwt.  2 root root    6 Sep 25 12:30 .XIM-unix +
- +
-[root@redhat9 ~]# ls -l --allinode /tmp +
-ls: unrecognized option '--allinode' +
-Try 'ls --help' for more information. +
-</code> +
- +
-<WRAP center round important 60%> +
-**Important** - You should **not** combine any short options that take an argument.+
 </WRAP> </WRAP>
  
-=====LAB #3 - Regular Expressions=====+===@(expression)===
  
-Text files play a very important role under Linux. For example, almost all configuration files are simple text files and being able to manipulate them is of great importance. Manipulating text files is essentially achieved by using **Regular Expressions**. There are two types of Regular Expressions: +Enter the following command:
- +
-  * The IEEE POSIX Basic Regular Expressions (**BRE**) understood by the commands **vi**, **grep**, **expr** and **sed**, +
-  * The IEEE POSIX Extended Regular Expressions (**ERE**) understood by the commands **egrep** ( grep -E ) and **awk**. +
- +
-Regular Expressions use **Metacharacters**. Certain are common to both BREs and EREs: +
- +
-^Metacharacter ^ Description ^ +
-| **%%^%%**//string// | Match lines beginning with //string// | +
-| //string//**$** | Match lines ending with //string// | +
-| **\**//Metacharacter// | Cancel any special effect associated with //Metacharacter//+
-| **[**//string//**]** | Match any of the characters within //string// | +
-| **[%%^%%**//string//**]**| Exclude any of the characters in //string// | +
-| **.** | Match any character except when at the end of a line | +
-| //character//***** | Match 0 or more occurrences of //character//+
-| \< | Match //string// at the beginning of a word | +
-| \> | Match //string// at the end of a word | +
- +
-===BREs=== +
- +
-Certain Metacharacters are specific to BREs: +
- +
-^Metacharacter ^ Description ^ +
-| **\{x,y\}** | Match from **x** to **y** occurrences of the preceeding element | +
-| **\{x\}** | Match exactly **x** occurrences of the preceeding element | +
-| **\{x,\}** | Match **x** or more occurrences of the preceeding element | +
-| \(BRE) | Commit to memory the BRE | +
-| \1 | Recall the first BRE committed to memory | +
-| \2, \3 ... | Recall the second BRE committed to memory, recall the third BRE committed to memory ... | +
- +
-===EREs=== +
- +
-Certain Metacharacters are specific to EREs: +
- +
-^Metacharacter ^ Description ^ +
-| {x,y} | Match from **x** to **y** occurrences of the preceeding element | +
-| {x} | Match exactly **x** occurrences of the preceeding element | +
-| {x,} | Match **x** or more occurrences of the preceeding element  +
-| ? | Matches 0 or 1 occurrence of the preceeding element | +
-| + | Matches 1 or more occurrence(s) of the preceeding element | +
-| %%|%% | Matches either the expression before or the expression after the operator | +
-| () | Combines the Reguler Expressions between the parentheses | +
- +
-=====Manipulating Text Files===== +
- +
-====Text-search Utilities==== +
- +
-===The grep Command=== +
- +
-The **grep** command can be used to find lines containing a string of characters in a group of files. The **-v** or **--invert-case** option can be stipulated to find lines that do **not** contain the specified string. +
- +
-The grep command is case sensitive. The **-i** or **--ignore-case** option can be specified in order to use grep in a non case sensitive search. +
- +
-The grep command can also use **BREs**. +
- +
-==Command Line Switches== +
- +
-<WRAP center round todo 60%> +
-**To do** : Use the **--help** option of the **grep** command to view the command line switches. +
-</WRAP> +
- +
-===The egrep Command=== +
- +
-The **egrep** command is identical to the **grep** command when used with the **-E** switch. Both can use EREs. +
- +
-==Command Line Switches== +
- +
-<WRAP center round todo 60%> +
-**To do** : Use the **--help** option of the **egrep** command to view the command line switches. +
-</WRAP> +
- +
-===The fgrep Command=== +
- +
-The **fgrep** command is identical to the **grep** command when used with the **-F** switch. Both have no knowledge of Regular Expressions. +
- +
-<WRAP center round todo 60%> +
-**To do** : Use the **--help** option of the **fgrep** command to view the command line switches. +
-</WRAP> +
- +
-===LAB #4 - Using grep, egrep and fgrep=== +
- +
-Create the following file: +
- +
-<code> +
-[root@redhat9 ~]# cd /tmp +
- +
-[root@redhat9 tmp]# vi greptest +
- +
-[root@redhat9 tmp]# cat greptest +
-fenestrOS +
-fenestros +
-555-5555 +
-+
-.fenestros +
-.fe +
-£ +
-</code> +
- +
- +
-Now use grep to search for lines containing at least one uppercase or lowercase letter: +
- +
-<code> +
-[root@redhat9 ~]# grep '[a-zA-Z]' /tmp/greptest +
-fenestrOS +
-fenestros +
-+
-.fenestros +
-.fe +
-</code> +
- +
-Next use grep to search for lines containing at least one uppercase or lowercase letter or a number: +
- +
-<code> +
-[root@redhat9 ~]# grep '[a-zA-Z0-9]' /tmp/greptest +
-fenestrOS +
-fenestros +
-555-5555 +
-+
-.fenestros +
-.fe +
-</code> +
- +
-To search for the NNN-NNNN pattern where N is a number, use the following command+
- +
-<code> +
-[root@redhat9 ~]# grep '[0-9]\{3\}-[0-9]\{4\}' /tmp/greptest +
-555-5555 +
-</code> +
- +
-Lines containing just one character have that character both at the beginning (**^**) and at the end (**$**) of the line:  +
- +
-<code> +
-[root@redhat9 ~]# grep '^.$' /tmp/greptest +
-+
-£ +
-</code> +
- +
-To search for a line containing a special character such as **.**, that character needs to be preceded by **\**:+
  
 <code> <code>
-[root@redhat9 ~]# grep '^\.' /tmp/greptest +[trainee@redhat9 training]$ ls f@(123).txt 
-.fenestros +f123.txt
-.fe+
 </code> </code>
  
 <WRAP center round important 60%> <WRAP center round important 60%>
-**Important** - The grep command can also be used to search for a string in all the files within a specific directory as follows **grep -rnw 'directory' -e "pattern"**. You can also search only within certain files by specifying the files extensions: **grep --include={*.doc,*.xls} -rnw 'directory' -e "pattern"**. Finally you can exclude certain file extensions as follows: **grep --exclude=*.doc -rnw 'directory' -e "pattern"**.+**Important**: Note here that the command displays files with names containing 1 single occurrence of the string **123**.
 </WRAP> </WRAP>
  
-Make the following changes to the greptest file:+===!(expression)===
  
-<code> +Enter the following command:
-[root@redhat9 tmp]# vi greptest +
-[root@redhat9 tmp]# cat greptest +
-# Starting comment +
-fenestrOS +
-fenestros +
-# Another comment +
-555-5555 +
-+
- +
-.fenestros +
- +
-.fe +
- +
-£ +
-# End comment +
-</code> +
- +
-Now use the **grep** command with the **-E** switch to remove all the comments and empty lines:+
  
 <code> <code>
-[root@redhat9 ~]# grep -E -v '^(#|$)' /tmp/greptest +[trainee@redhat9 training]$ ls f!(123).txt 
-fenestrOS +f123123123.txt f123123.txt f.txt
-fenestros +
-555-5555 +
-f +
-.fenestros +
-.fe +
-£+
 </code> </code>
  
 <WRAP center round important 60%> <WRAP center round important 60%>
-**Important** - The expression **'^(#|$)'** matches all lines beginning with the **#** character OR all lines with zero characters between the start and the end of the line.+**Important**: Note here that the command only displays files with a name that does **not** contain the string **123**.
 </WRAP> </WRAP>
  
-Now use the **egrep** command to do the same thing, this time redirecting the output to the file **/tmp/greptest1**:+====Protecting Metacharacters====
  
-<code> +In order to use a metacharacter in a literal context, an escape character must be usedThere are three escape characters:
-[root@redhat9 ~]# egrep -v '^(#|$)'  /tmp/greptest > /tmp/greptest1 +
-[root@redhat9 ~]# cat /tmp/greptest1 +
-fenestrOS +
-fenestros +
-555-5555 +
-+
-.fenestros +
-.fe +
-£ +
-</code>+
  
-<WRAP center round important 60%> +^ Character ^ Description ^ 
-**Important**: The above command is very useful when you want to quickly ascertain which directives are active in a very long configuration file. +| \ | Escapes the character which immediately follows | 
-</WRAP>+| ' ' | Protects any character between the two **'** | 
 +| " " | Protects any character between the two **"** except the following: **$**, **\** and **'** |
  
-Make the following changes to the greptest file:+To illustrate the use of escape characters, consider the following command:
  
-<code> +  echo * is a metacharacter [Enter].
-[root@redhat9 tmp]# vi greptest +
- +
-[root@redhat9 tmp]# cat greptest +
-# Starting comment +
-^ This line will be used to demonstrate the use of fgrep +
-fenestrOS +
-fenestros +
-# Another comment +
-555-5555 +
-+
- +
-.fenestros +
- +
-.fe +
- +
-£ +
-# End comment +
-</code> +
- +
-Now use fgrep to match the line starting with the **^** character: +
- +
-<code> +
-[root@redhat9 ~]# fgrep '^' /tmp/greptest +
-^ This line will be used to demonstrate the use of fgrep +
-</code>+
  
-Compare the above output to that when using the grep command:+When you enter this command in your **training** directory, you will get a window similar to this one:
  
 <code> <code>
-[root@redhat9 ~]# grep '^' /tmp/greptest +[trainee@redhat9 training]$ echo * is a metacharacter 
-# Starting comment +a100 f f1 f123123123.txt f123123.txt f123123.txt f2 f3 f4 f5 f52 f62 f.txt is a metacharacter
-^ This line will be used to demonstrate the use of fgrep +
-fenestrOS +
-fenestros +
-# Another comment +
-555-5555 +
-f+
  
-.fenestros+[trainee@redhat9 training]$ echo \* is a metacharacter 
 +* is a metacharacter
  
-.fe+[trainee@redhat9 training]$ echo "* is a metacharacter" 
 +* is a metacharacter
  
-£ +[trainee@redhat9 training]$ echo ‘* is a metacharacter’ 
-# End comment+* is a metacharacter
 </code> </code>
  
-As you can see, grep matched **every** line that had a //beginning//In order to get the same result as the grep command, you need to use the following command:+====1.9 - Exit codes====
  
-<code> +Each command returns an **exit status** when it is executed. This exit status is stored in a special variable: **$?**.
-[root@redhat9 ~]# grep '^\^' /tmp/greptest +
-This line will be used to demonstrate the use of fgrep +
-</code>+
  
-====The Stream EDitor SED==== +For example:
- +
-**sed** is an abbreviation of //Stream EDitor// and is a non-interactive text editor. sed's basic syntax is as follows: +
- +
-<file> +
-sed [address] command [arguments] file +
-</file> +
- +
-The specified commands are applied to each line in the file unless an //address// is specified. Sed prints all results to standard output and does not modify the source file. The address therefore specifies which lines are concerned by the command. +
- +
-sed's addresses are as follows: +
- +
-^address ^ Matching lines ^ +
-| x | Line number **x** | +
-| $ | The last line of the file | +
-| /BRE/ | Lines matching the specified BRE | +
-| x,y | From line **x** to line **y** | +
-| /ERb1/, /ERb2/ | All lines from the first line that matches the first BRE to the first line that matches the second BRE | +
- +
-sed's commands are as follows: +
- +
-^command ^ Description ^ +
-| d | Do not show the matching line(s) on standard output | +
-| p | Show the matching line(s) on standard output +
-| s | Do a substitution upon match | +
-| w | Write the matching line(s) to a file | +
-| = | Print the matching line's number | +
-| ! | Exclude the line(s) matching the address | +
- +
-===Command Line Switches=== +
- +
-<WRAP center round todo 60%> +
-**To do** : Use the **--help** option of the **fgrep** command to view the command line switches. +
-</WRAP> +
- +
-===LAB #5 - Using sed=== +
- +
-Start by displaying the contents of the file **/etc/services** whilst inhibiting the display of the first 10 lines:+
  
 <code> <code>
-[root@redhat9 ~]# sed '1,10d' /etc/services | more +[trainee@redhat9 training]$ cd .
-# are included, only the more common ones+[trainee@redhat9 ~]$ mkdir codes 
-# +[trainee@redhat9 ~]$ echo $? 
-# The latest IANA port assignments can be gotten from +
-#       http://www.iana.org/assignments/port-numbers +[trainee@redhat9 ~]$ touch codes/exit.txt 
-# The Well Known Ports are those from through 1023. +[trainee@redhat9 ~]$ rmdir codes 
-# The Registered Ports are those from 1024 through 49151 +rmdirfailed to remove ‘codes’: Directory not empty 
-# The Dynamic and/or Private Ports are those from 49152 through 65535 +[trainee@redhat9 ~]$ echo $? 
-# +1
-# Each line describes one service, and is of the form+
-+
-# service-name  port/protocol  [aliases ...]   [# comment+
- +
-tcpmux          1/tcp                           # TCP port service multiplexer +
-tcpmux          1/udp                           # TCP port service multiplexer +
-rje             5/tcp                           # Remote Job Entry +
-rje             5/udp                           # Remote Job Entry +
-echo            7/tcp +
-echo            7/udp +
-discard         9/tcp           sink null +
-discard         9/udp           sink null +
-systat          11/tcp          users +
-systat          11/udp          users +
-daytime         13/tcp +
---More--                    +
 </code> </code>
  
-Now display the same file without any commented lines:+In this example the **codes** directory was created successfully. The exit code stored in the $? variable is a zero.
  
-<code+Deleting the directory encountered an error because **codes** contained the file **return**. The exit code stored in the $? variable is **one**.
-[root@redhat9 ~]# sed '/^#/d' /etc/services | more+
  
-tcpmux          1/tcp                           # TCP port service multiplexer +If the exit code is **zero**, the last command was executed without error. 
-tcpmux          1/udp                           # TCP port service multiplexer +
-rje             5/tcp                           # Remote Job Entry +
-rje             5/udp                           # Remote Job Entry +
-echo            7/tcp +
-echo            7/udp +
-discard         9/tcp           sink null +
-discard         9/udp           sink null +
-systat          11/tcp          users +
-systat          11/udp          users +
-daytime         13/tcp +
-daytime         13/udp +
-qotd            17/tcp          quote +
-qotd            17/udp          quote +
-msp             18/tcp                          # message send protocol +
-msp             18/udp                          # message send protocol +
-chargen         19/tcp          ttytst source +
-chargen         19/udp          ttytst source +
-ftp-data        20/tcp +
-ftp-data        20/udp +
-ftp             21/tcp +
-ftp             21/udp          fsp fspd +
---More--                         +
-</code>+
  
-<WRAP center round important 60%> +If the exit code is **other than zero**, the last command was completed with an error
-**Important**: Note that the BRE is preceeded and followed by the **/** character. +
-</WRAP>+
  
-Continue by trying to just display the first two lines of **/etc/passwd**:+====1.10 - Redirections====
  
-<code> +Your dialogue with the Linux system uses input and output channels. The keyboard is called the **standard input channel** and the screen is called the **standard output channel**
-[root@redhat9 ~]# sed '1,2p' /etc/passwd +
-root:x:0:0:root:/root:/bin/bash +
-root:x:0:0:root:/root:/bin/bash +
-bin:x:1:1:bin:/bin:/sbin/nologin +
-bin:x:1:1:bin:/bin:/sbin/nologin +
-daemon:x:2:2:daemon:/sbin:/sbin/nologin +
-adm:x:3:4:adm:/var/adm:/sbin/nologin +
-lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin +
-... +
-</code>+
  
-<WRAP center round important 60%> +{{:free:stdin.png|}}
-**Important**As you can see in the above output, the command used displays not only the first two lines but **also** the entire file. As a result the first two lines are displayed twice. +
-</WRAP>+
  
-To force sed to **only** display the lines you specifyuse the **-n** switch:+In other words, when you type a command on the keyboardyou see the result of that command on the screen.
  
-<code> +Sometimeshowever, it is useful to redirect the standard output channel to a file. In this way, the result of a command such as **free** can be stored in a file for future reference:
-[root@redhat9 ~]# sed -n '1,2p' /etc/passwd +
-root:x:0:0:root:/root:/bin/bash +
-bin:x:1:1:bin:/bin:/sbin/nologin +
-</code>+
  
-Now you want to use sed to strip out the comments from **/etc/services** and save the result to **/tmp/sedtest** without displaying anything on standard output:+{{:free:redirection.png|}} 
  
-<code> +This effect is achieved by using a **redirection**:
-[root@redhat9 ~]# sed -n '/^#/!w /tmp/sedtest' /etc/services +
- +
-[root@redhat9 ~]# more /tmp/sedtest +
- +
-tcpmux          1/tcp                           # TCP port service multiplexer +
-tcpmux          1/udp                           # TCP port service multiplexer +
-rje             5/tcp                           # Remote Job Entry +
-rje             5/udp                           # Remote Job Entry +
-echo            7/tcp +
-echo            7/udp +
-discard         9/tcp           sink null +
-discard         9/udp           sink null +
-systat          11/tcp          users +
-systat          11/udp          users +
-daytime         13/tcp +
-daytime         13/udp +
-qotd            17/tcp          quote +
-qotd            17/udp          quote +
-msp             18/tcp                          # message send protocol +
-msp             18/udp                          # message send protocol +
-chargen         19/tcp          ttytst source +
-chargen         19/udp          ttytst source +
-ftp-data        20/tcp +
-ftp-data        20/udp +
-ftp             21/tcp +
-ftp             21/udp          fsp fspd +
---More--(0%) +
-</code> +
- +
-<WRAP center round important 60%> +
-**Important**: In the above command, we start by matching all lines in the /etc/services file that start with #. We then tell sed to write all non-matching lines to the file /tmp/sedtest. +
-</WRAP> +
- +
-Finally, create a file containing **user1,user2,user3**. Replace the commas by spaces:+
  
 <code> <code>
-[root@redhat9 ~]# echo "user1,user2,user3"/tmp/sedtest1 +[trainee@redhat9 ~]$ pwd 
-[root@redhat9 ~]cat /tmp/sedtest1 | sed 's/,/ /g' +/home/trainee 
-user1 user2 user3+[trainee@redhat9 ~]$ cd training 
 +[trainee@redhat9 training]$ free > file 
 +[trainee@redhat9 training]$ cat file 
 +               total        used        free      shared  buff/cache   available 
 +Mem:         7869560      996400     4964048       15324     2229600     6873160 
 +Swap:        5242876               5242876
 </code> </code>
  
-<WRAP center round important 60%> +If the target file does not exist, it is created and its contents will be the result of the free command
-**Important**: The above sed command has the following format **s/what is to be replaced (character, string or BRE)/replacement/g**. The use of the **g** character forces sed to replace all occurences that match. If **g** is not stipulated, only the first matching occurence is replaced. +
-</WRAP>+
  
-====The Text Processor AWK==== +On the other hand if the file already existsit will be overwritten :
- +
-===Presentation=== +
- +
-The **awk** command acts as a **filter** and uses the following syntax: +
- +
-  awk [-F seperator] '[condition] {action}' [file] +
- +
-===Field Separation=== +
- +
-A file or a text stream is treated by awk as a sequence of records. By default each line is a record. Awk analyzes each record, separating that record into fields and then storing the record and fields in variables: +
- +
-  * $0 contains the record, +
-  * $1 contains the first field, +
-  * $2 contains the second field, +
-  * e.t.c. +
- +
-Awk interprets a space as a separator between fields unless a different separator is specified with the **-F** option. +
- +
-Awk then checks if the condition is met for each record and if so, executes the action. +
- +
-For example, the following command takes the standard output of **ls -l** and prints fields 83 and 4 to standard output:+
  
 <code> <code>
-[root@redhat9 tmp]# ls -l | awk '{print $$3 $4}' +[trainee@redhat9 training]$ date > file 
- +[trainee@redhat9 training]cat file 
-05:23rootroot +Thu Sep 26 12:49:11 PM CEST 2024
-05:21rootroot +
-05:28rootroot +
-05:29rootroot +
-12:05rootroot+
 </code> </code>
  
-Since there is no condition, the action is applied to every record. +To add additional data to the same target filea **double redirect** must be used:
- +
-To make the output easier to readyou can include spaces between each field:+
  
 <code> <code>
-[root@redhat9 tmp]# ls -l | awk '{print $8 " " $3 " " $4}' +[trainee@redhat9 training]$ free >> file 
-   +[trainee@redhat9 training]free >> file 
-05:23 root root +[trainee@redhat9 training]cat file 
-05:21 root root +Thu Sep 26 12:49:11 PM CEST 2024 
-05:28 root root +               total        used        free      shared  buff/cache   available 
-05:29 root root +Mem        7869560      996392     4964048       15324     2229608     6873168 
-12:05 root root+Swap       5242876               5242876
 </code> </code>
  
-=== Conditions ===+This way, the output of the free command will be added to the end of your file after the information in the free command.
  
-==A regular expression applied to a record== +<WRAP centre round important 60%> 
- +**Important**: Note that the standard output can only be redirected in **one direction**. 
-  * Format: +
-    * /regular expression/ {action} +
-  * Exemple: +
-    * /hello/ {print $0} +
- +
-==A regular expression applied to a field== +
- +
-  * Format: +
-    * $n ~/regular expression/ {action} +
-    * $n!~/regular expression/ {action} +
-  * Examples: +
-    * $1 ~/hello/ {print $0} +
-    * $1!~/hello/ {print $0} +
- +
-==Comparisons== +
-  +
-  * Format: +
-    * $n operator criteria {action} +
-  * Example: +
-    * $1 > 20 {print $0} +
- +
-**Operators** +
- +
-^ Operator ^ Condition ^ +
-| < | Less than | +
-| <= | Less than or equal to | +
-| == | Equal to | +
-| != | Different | +
-| > | Greater than | +
-| >= | Greater than or equal to | +
- +
- +
-==Logical Operators== +
- +
-  * Format: +
-    * test1 logical operator test2 {action} +
-  * Example: +
-    * $1 ~/hello/ && $2 > 20 {print $0} +
- +
-**Operators** +
- +
-^ Operator ^ Condition ^ +
-| %%||%% | OR | +
-| && | AND | +
-| ! | NO | +
- +
-==Built-in Variables== +
- +
-  * Format: +
-    * expression1, expression2 {instruction} +
-  * Example: +
-    * NR==7, NR==10 {print $0} +
- +
-**Variables** +
- +
-^ Variable ^ Description ^ +
-| NR | Total number of records | +
-| NF | Total number of fields | +
-| FILENAME | Name of current input file | +
-| FS | The field separator, by default a **space** or **tab** | +
-| RS | The record separator, by default **newline** | +
-| OFS | Output field separator, by default a **space** | +
-| ORS | Output record separator, by default **newline** | +
-| OFMT | Numeric output format, by default"%.6g"+
- +
-===Awk Scripts=== +
- +
-To combine several //clauses// composed of //conditions// and //actions// in the same statement, it is advisable to create an //awk script//. Awk scripts are comprised of three sections: +
- +
-  * **BEGIN** +
-    * This section is executed once, prior to executing the body of the script +
-   * **BODY** +
-    * This sections contains the clauses to be applied to each line +
-  * **END** +
-    * This section is executed once, after executing the body of the script +
- +
-For example: +
- +
-<code> +
-[root@redhat9 tmp]# cat > scriptawk +
-BEGIN { +
-  print "List of mounted filesystems"+
-{print $0} +
-END { +
-  print "====================================="+
-[^D] +
-</code> +
- +
-Now apply the awk script to **/etc/fstab** : +
- +
-<code> +
-[root@redhat9 tmp]# awk -f scriptawk /etc/mtab +
-List of mounted filesystems +
-sysfs /sys sysfs rw,seclabel,nosuid,nodev,noexec,relatime 0 0 +
-proc /proc proc rw,nosuid,nodev,noexec,relatime 0 0 +
-devtmpfs /dev devtmpfs rw,seclabel,nosuid,size=1897604k,nr_inodes=474401,mode=755 0 0 +
-securityfs /sys/kernel/security securityfs rw,nosuid,nodev,noexec,relatime 0 0 +
-tmpfs /dev/shm tmpfs rw,seclabel,nosuid,nodev 0 0 +
-devpts /dev/pts devpts rw,seclabel,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000 0 0 +
-tmpfs /run tmpfs rw,seclabel,nosuid,nodev,mode=755 0 0 +
-tmpfs /sys/fs/cgroup tmpfs ro,seclabel,nosuid,nodev,noexec,mode=755 0 0 +
-cgroup /sys/fs/cgroup/systemd cgroup rw,seclabel,nosuid,nodev,noexec,relatime,xattr,release_agent=/usr/lib/systemd/systemd-cgroups-agent,name=systemd 0 0 +
-pstore /sys/fs/pstore pstore rw,seclabel,nosuid,nodev,noexec,relatime 0 0 +
-bpf /sys/fs/bpf bpf rw,nosuid,nodev,noexec,relatime,mode=700 0 0 +
-cgroup /sys/fs/cgroup/hugetlb cgroup rw,seclabel,nosuid,nodev,noexec,relatime,hugetlb 0 0 +
-cgroup /sys/fs/cgroup/devices cgroup rw,seclabel,nosuid,nodev,noexec,relatime,devices 0 0 +
-cgroup /sys/fs/cgroup/cpuset cgroup rw,seclabel,nosuid,nodev,noexec,relatime,cpuset 0 0 +
-cgroup /sys/fs/cgroup/cpu,cpuacct cgroup rw,seclabel,nosuid,nodev,noexec,relatime,cpu,cpuacct 0 0 +
-cgroup /sys/fs/cgroup/net_cls,net_prio cgroup rw,seclabel,nosuid,nodev,noexec,relatime,net_cls,net_prio 0 0 +
-cgroup /sys/fs/cgroup/rdma cgroup rw,seclabel,nosuid,nodev,noexec,relatime,rdma 0 0 +
-cgroup /sys/fs/cgroup/freezer cgroup rw,seclabel,nosuid,nodev,noexec,relatime,freezer 0 0 +
-cgroup /sys/fs/cgroup/perf_event cgroup rw,seclabel,nosuid,nodev,noexec,relatime,perf_event 0 0 +
-cgroup /sys/fs/cgroup/pids cgroup rw,seclabel,nosuid,nodev,noexec,relatime,pids 0 0 +
-cgroup /sys/fs/cgroup/blkio cgroup rw,seclabel,nosuid,nodev,noexec,relatime,blkio 0 0 +
-cgroup /sys/fs/cgroup/memory cgroup rw,seclabel,nosuid,nodev,noexec,relatime,memory 0 0 +
-none /sys/kernel/tracing tracefs rw,seclabel,relatime 0 0 +
-configfs /sys/kernel/config configfs rw,relatime 0 0 +
-/dev/sda3 / xfs rw,seclabel,relatime,attr2,inode64,logbufs=8,logbsize=32k,noquota 0 0 +
-selinuxfs /sys/fs/selinux selinuxfs rw,relatime 0 0 +
-systemd-1 /proc/sys/fs/binfmt_misc autofs rw,relatime,fd=36,pgrp=1,timeout=0,minproto=5,maxproto=5,direct,pipe_ino=1976 0 0 +
-debugfs /sys/kernel/debug debugfs rw,seclabel,relatime 0 0 +
-hugetlbfs /dev/hugepages hugetlbfs rw,seclabel,relatime,pagesize=2M 0 0 +
-mqueue /dev/mqueue mqueue rw,seclabel,relatime 0 0 +
-/dev/sda1 /boot ext4 rw,seclabel,relatime 0 0 +
-sunrpc /var/lib/nfs/rpc_pipefs rpc_pipefs rw,relatime 0 0 +
-tmpfs /run/user/1000 tmpfs rw,seclabel,nosuid,nodev,relatime,size=382740k,mode=700,uid=1000,gid=1000 0 0 +
-binfmt_misc /proc/sys/fs/binfmt_misc binfmt_misc rw,relatime 0 0 +
-tracefs /sys/kernel/debug/tracing tracefs rw,seclabel,relatime 0 0 +
-===================================== +
-</code> +
- +
-<WRAP center round important 60%> +
-**Important**: Note the use of the **-f** switch which instructs awk to use the script.+
 </WRAP> </WRAP>
  
-===The printf function===+Input and output channels are numbered:
  
-The integrated function **printf** is used to format output and has the following syntax:+  * 0 = The Standard Input Channel 
 +  1 = The Standard Output Channel 
 +  2 = The Error Channel
  
-<file> +The following command will create a file named **errorlog** that contains error messages from the execution of the **rmdir** command:
-printf ("string",expression1,expression2,...,expressionn) +
-</file> +
- +
-**string** contains as many formats as there are expressions. +
- +
-Examples of formats commonly used are: +
- +
-^ Format ^ Description ^ +
-| %30s | Displays a right-justified string of 30 characters | +
-| %-30s | Displays a left-justified string of 30 characters | +
-| %4d | Displays a right-justified decimal number of 4 digits | +
-| %-4d | Displays a left-justified decimal number of 4 digits | +
- +
-===Control Statements=== +
- +
-awk can use the following control statements: +
- +
-==if== +
- +
-<file> +
-if condition {  +
- +
-    command +
-    command +
-    ... +
-+
- +
-else { +
- +
-    command +
-    command +
-    ... +
-+
- +
-</file> +
- +
-or: +
- +
-<file> +
-if condition +
- +
-    command +
- +
-else +
- +
-    command +
- +
-</file> +
- +
-==for== +
- +
-<file> +
-for variable in list { +
- +
-    command +
-    command +
-    ... +
- +
-+
-</file> +
- +
-or: +
- +
-<file> +
-for variable in list +
- +
-    command +
- +
-</file> +
- +
-or in the case of table: +
- +
-<file+
-for key in table { +
- +
-    print key , table[key] +
- +
-+
-</file> +
- +
-==while== +
- +
-<file> +
-while condition { +
- +
-     command +
-     command +
-     ... +
- +
-+
-</file> +
- +
-==do-while== +
- +
-<file> +
-do { +
- +
-     command +
-     command +
-     ... +
- +
-} while condition +
-</file> +
- +
-===Command Line Switches=== +
- +
-<WRAP center round todo 60%> +
-**To do** : Use the **--help** option of the **awk** command to view the command line switches. +
-</WRAP> +
- +
-===LAB #6 - Using awk=== +
- +
-Create the file **sales.txt**:+
  
 <code> <code>
-[root@redhat9 tmp]# vi sales.txt +[trainee@redhat9 training]$ cd .
-[root@redhat9 tmp]cat sales.txt +[trainee@redhat9 ~]$ rmdir training/ 2>errorlog 
-# Annual sales by French department +[trainee@redhat9 ~]$ cat errorlog  
-# 83 +rmdir: failed to remove ‘training/’: Directory not empty
-Desktops§100 +
-Portables§50 +
-Servers§21 +
-Ipads§4 +
- +
-# 06 +
-Desktops§99 +
-Portables§60 +
-Servers§8 +
-Ipads§16 +
- +
-# 13 +
-Desktops§130 +
-Portables§65 +
-Servers§12 +
-Ipads§56+
 </code> </code>
  
-Now create the awk script **sales.awk**+In fact the error is generated because the **training** directory is not empty.
  
-<code> +You can join file descriptors using the **&** character:
-[root@redhat9 tmp]# vi sales.awk +
- +
-[root@redhat9 tmp]# cat sales.awk  +
-# BEGIN +
-BEGIN { +
-    FS="§" +
-+
-# TABLE +
-$1 !~ /^#/ && $1 !~ /^$/ { +
- sales[$1]+=$2 +
-+
-# END +
-END { +
- for (pc in sales) +
- printf("PC Type :  %s \t Sales (06+13+83) : %10d\n",pc,sales[pc]); +
-+
-</code> +
- +
-This script contains 13 lines. The purpose of this script is to calculate the total number of computers sold in the three French departments from the data present in the **sales** file: +
- +
-<file> +
-     1 # BEGIN +
-     2 BEGIN { +
-     3 FS="§" +
-     4 } +
-     5 # TABLE +
-     6 $1 !~ /^#/ && $1 !~ /^$/ { +
-     7 sales[$1]+=$2 +
-     8 } +
-     9 # END +
-    10 END { +
-    11 for (pc in sales) +
-    12 printf("PC Type :  %s \t Sales (06+13+83) : %10d\n",pc,sales[pc]); +
-    13 } +
-</file> +
- +
-It is important that you understand the key lines in the above script: +
- +
-  Line **3**, +
-    * Defines a new field seperator in a BEGIN section. +
-  * Line **6**, +
-    * Discards all commented and empty lines. +
-  * Line **7**, +
-    * The table's key is **$1**, in other words the different types of computers. Against each key, the number of each type of computer sold is stored in **$2**. The **+=** characters indicate that the value stored in $2 is incremental. +
-  * Line **12**, +
-    * Uses printf to format the output of each line in the table. +
- +
-Now execute the script and check the output is correct:+
  
 <code> <code>
-[root@redhat9 tmp]# awk -f /tmp/sales.awk /tmp/sales.txt +[trainee@redhat9 ~]$ free > file 2>&1
-PC Type :  Portables     Sales (06+13+83) :        175 +
-PC Type :  Ipads         Sales (06+13+83) :         76 +
-PC Type :  Desktops      Sales (06+13+83) :        329 +
-PC Type :  Servers       Sales (06+13+83) :         41+
 </code> </code>
  
-====LAB #7 - Other Useful Commands====+The syntax **2>&1** sends the output of channel 2 to the same place as channel 1, namely the file named **file**.
  
-===7.1 - The expand Command=== +It is possible to modify the standard input channel in order to read information from a file.  In this case the redirection is obtained by using the **<** character:
- +
-The **expand** command converts tabulations in a file to spaces and prints the results to STDOUTWith no file as an argument or with the **-** character as an argument, the command takes it's input from STDIN. +
- +
-Create the following file:+
  
 <code> <code>
-[root@redhat9 tmp]# vi expand +[trainee@redhat9 ~]$ wc -w < errorlog 
- +8
-[root@redhat9 tmp]# cat expand +
-un deux trois quatre cinq +
-un deux trois quatre cinq +
-un deux trois quatre cinq +
-un deux trois quatre cinq +
-un deux trois quatre cinq +
-un deux trois quatre cinq +
-un deux trois quatre cinq +
-un deux trois quatre cinq +
-un deux trois quatre cinq +
-un deux trois quatre cinq+
 </code> </code>
  
-Now use the **-vet** switches of the **cat** command to view the non-printable characters:+In this example the wc command counts the number of words ( -w ) in the errorlog file and displays it on the screen :
  
-<code> +Other redirections exist:
-[root@redhat9 tmp]# cat -vet expand +
-un^Ideux^Itrois^Iquatre^Icinq$ +
-un^Ideux^Itrois^Iquatre^Icinq$ +
-un^Ideux^Itrois^Iquatre^Icinq$ +
-un^Ideux^Itrois^Iquatre^Icinq$ +
-un^Ideux^Itrois^Iquatre^Icinq$ +
-un^Ideux^Itrois^Iquatre^Icinq$ +
-un^Ideux^Itrois^Iquatre^Icinq$ +
-un^Ideux^Itrois^Iquatre^Icinq$ +
-un^Ideux^Itrois^Iquatre^Icinq$ +
-un^Ideux^Itrois^Iquatre^Icinq$ +
-</code>+
  
-<WRAP center round important 60%> +^ Redirection  ^ Definition 
-**Important** : As you can see the tabulations are shown as **^I** and the end of each line as **$**+| %%&>%% | Join file descriptors 1 and 2. |  
-</WRAP>+| %%<<%% | Takes the text typed on the next lines as standard input until EOF is found at the beginning of a line| 
 +| %%<>%% | Allows the use of the same file as STDIN and STDOUT. |
  
-Now use the **expand** command to convert the tabulations into spaces and send the result to the **expand1** file:+====1.11 - Pipes====
  
-<code> +It is also possible to link commands using a **|** pipe. 
-[root@redhat9 ~]# expand expand > expand1 +
-</code>+
  
-View the resulting **expand1** file with the **cat** command and the **-vet** switches:+In this case, the output channel of the command to the left of the pipe is sent to the input channel of the command to the right of the pipe :
  
 <code> <code>
-[root@redhat9 ~]# cat -vet expand1 +[trainee@redhat9 ~]$ ls | wc -w 
-un      deux    trois   quatre  cinq$ +17
-un      deux    trois   quatre  cinq$ +
-un      deux    trois   quatre  cinq$ +
-un      deux    trois   quatre  cinq$ +
-un      deux    trois   quatre  cinq$ +
-un      deux    trois   quatre  cinq$ +
-un      deux    trois   quatre  cinq$ +
-un      deux    trois   quatre  cinq$ +
-un      deux    trois   quatre  cinq$ +
-un      deux    trois   quatre  cinq$+
 </code> </code>
  
-<WRAP center round important 60%> +This command, run in your home directorytakes the output of the **ls** command and asks the **wc** command to count the number of words included in the output of ls:
-**Important** : As you can see, the tabulations have been changed into spaces. +
-</WRAP> +
- +
-==Command Line Switches== +
- +
-<WRAP center round todo 60%> +
-**To do** : Use the **--help** option of the **expand** command to view the command line switches. +
-</WRAP> +
- +
-===7.2 - The unexpand Command=== +
- +
-The **expand** command converts spaces in a file to tabulations and prints the results to STDOUT. With no file as an argument or with the **-** character as an argument, the command takes it's input from STDIN. +
- +
-Now use the **expand** command to convert the spaces in the **expand1** file into tabulations and send the result to the **expand2** file: +
- +
-<code> +
-[root@redhat9 ~]# cat -vet expand1 +
-un      deux    trois   quatre  cinq$ +
-un      deux    trois   quatre  cinq$ +
-un      deux    trois   quatre  cinq$ +
-un      deux    trois   quatre  cinq$ +
-un      deux    trois   quatre  cinq$ +
-un      deux    trois   quatre  cinq$ +
-un      deux    trois   quatre  cinq$ +
-un      deux    trois   quatre  cinq$ +
-un      deux    trois   quatre  cinq$ +
-un      deux    trois   quatre  cinq$ +
- +
-[root@redhat9 ~]# unexpand -a expand1 > expand2 +
- +
-[root@redhat9 ~]# cat -vet expand2 +
-un^Ideux^Itrois^Iquatre^Icinq$ +
-un^Ideux^Itrois^Iquatre^Icinq$ +
-un^Ideux^Itrois^Iquatre^Icinq$ +
-un^Ideux^Itrois^Iquatre^Icinq$ +
-un^Ideux^Itrois^Iquatre^Icinq$ +
-un^Ideux^Itrois^Iquatre^Icinq$ +
-un^Ideux^Itrois^Iquatre^Icinq$ +
-un^Ideux^Itrois^Iquatre^Icinq$ +
-un^Ideux^Itrois^Iquatre^Icinq$ +
-un^Ideux^Itrois^Iquatre^Icinq$ +
-</code>+
  
 <WRAP center round important 60%> <WRAP center round important 60%>
-**Important** : Note that the spaces have been replaced by tabulations.+**Important**: Note that it is possible to link several tubes in the same command.
 </WRAP> </WRAP>
  
-==Command Line Switches== +Remember that the standard output can only be redirected in one directionIn order to be able to redirect the standard output to file **and** view it on screen, we need to use the **tee** command with a pipe:
- +
-<WRAP center round todo 60%> +
-**To do** : Use the **--help** option of the **unexpand** command to view the command line switches. +
-</WRAP> +
- +
-===7.3 - The cut Command=== +
- +
-The cut command splits each line of a file into columns starting with column 1. Each column contains one characterThe command can also be used to split lines into fields where the default seperator is tablulation. The default seperator can be changed by using the **-d** switch. +
- +
-Select the first 7 columns of the **/etc/passwd** file:+
  
 <code> <code>
-[root@redhat9 tmp]# cut -c1-7 /etc/passwd +[trainee@redhat9 ~]$ date | tee file1 
-root:x+Thu Sep 26 12:54:36 PM CEST 2024 
-bin:x:1 +[trainee@redhat9 ~]$ cat file1 
-daemon: +Thu Sep 26 12:54:36 PM CEST 2024
-adm:x:3 +
-lp:x:4: +
-sync:x: +
-shutdow +
-halt:x: +
-mail:x: +
-operato +
-games:x +
-ftp:x:1 +
-nobody: +
-systemd +
-dbus:x: +
-polkitd +
-avahi:x +
-tss:x:5 +
-colord: +
-clevis: +
-rtkit:x +
-sssd:x: +
-geoclue +
-libstor +
-systemd +
-setroub +
-pipewir +
-flatpak +
-gdm:x:4 +
-cockpit +
-cockpit +
-gnome-i +
-sshd:x: +
-chrony: +
-dnsmasq +
-tcpdump +
-trainee+
 </code> </code>
  
-In order to select columns 1 to 5, columns 10 to 15 and columns 30 and higher, us the following command:+This same technique allows us to create **two files**:
  
 <code> <code>
-[root@redhat9 tmp]# cut -c1-5,10-15,30- /etc/passwd +[trainee@redhat9 ~]$ date | tee file1 file2 
-root:0:rootsh +[trainee@redhat9 ~]$ cat file1 
-bin:x:bin:/gin +Thu Sep 26 12:55:11 PM CEST 2024 
-daemo2:2:dain/nologin +[trainee@redhat9 ~]$ cat file2 
-adm:x:adm:/nologin +Thu Sep 26 12:55:11 PM CEST 2024
-lp:x:lp:/vabin/nologin +
-sync:0:syncnc +
-shutdx:6:0::/sbin/shutdown +
-halt:0:haltalt +
-mail:12:maiail:/sbin/nologin +
-operax:11:0t:/sbin/nologin +
-games2:100:es:/sbin/nologin +
-ftp:x50:FTP:/sbin/nologin +
-nobod65534:verflow User:/:/sbin/nologin +
-systeoredumstemd Core Dumper:/:/sbin/nologin +
-dbus::81:Syus:/:/sbin/nologin +
-polki:998:9lkitd:/:/sbin/nologin +
-avahi0:70:ASD Stack:/var/run/avahi-daemon:/sbin/nologin +
-tss:x59:AccTPM access:/dev/null:/sbin/nologin +
-color997:99ord:/var/lib/colord:/sbin/nologin +
-clevi996:99ption Framework unprivileged user:/var/cache/clevis:/usr/sbin/nologin +
-rtkit72:172proc:/sbin/nologin +
-sssd:5:991:/:/sbin/nologin +
-geocl:994:9oclue:/var/lib/geoclue:/sbin/nologin +
-libstemgmt:on account for libstoragemgmt:/:/usr/sbin/nologin +
-systeom:x:9 Userspace OOM Killer:/:/usr/sbin/nologin +
-setroshoot:nux troubleshoot server:/var/lib/setroubleshoot:/sbin/nologin +
-pipewx:985:ystem Daemon:/var/run/pipewire:/sbin/nologin +
-flatp:984:9atpak system helper:/:/sbin/nologin +
-gdm:x42::/vin/nologin +
-cockps:x:98 cockpit web service:/nonexisting:/sbin/nologin +
-cockpsinstaUser for cockpit-ws instances:/nonexisting:/sbin/nologin +
-gnometial-s::/run/gnome-initial-setup/:/sbin/nologin +
-sshd::74:Prted SSH:/usr/share/empty.sshd:/sbin/nologin +
-chron980:97m user:/var/lib/chrony:/sbin/nologin +
-dnsma:979:9P and DNS server:/var/lib/dnsmasq:/sbin/nologin +
-tcpdu:72:72gin +
-train:1000:home/trainee:/bin/bash +
-</code> +
- +
-In order to select the 2nd, 4th and 6th column, use the following command: +
- +
-<code+
-[root@redhat9 tmp]# cut -d: -f2,4,6 /etc/passwd +
-x:0:/root +
-x:1:/bin +
-x:2:/sbin +
-x:4:/var/adm +
-x:7:/var/spool/lpd +
-x:0:/sbin +
-x:0:/sbin +
-x:0:/sbin +
-x:12:/var/spool/mail +
-x:0:/root +
-x:100:/usr/games +
-x:50:/var/ftp +
-x:65534:/ +
-x:997:/ +
-x:81:/ +
-x:996:/ +
-x:70:/var/run/avahi-daemon +
-x:59:/dev/null +
-x:993:/var/lib/colord +
-x:992:/var/cache/clevis +
-x:172:/proc +
-x:991:/ +
-x:990:/var/lib/geoclue +
-x:988:/ +
-x:987:/ +
-x:986:/var/lib/setroubleshoot +
-x:984:/var/run/pipewire +
-x:983:/ +
-x:42:/var/lib/gdm +
-x:982:/nonexisting +
-x:981:/nonexisting +
-x:980:/run/gnome-initial-setup/ +
-x:74:/usr/share/empty.sshd +
-x:979:/var/lib/chrony +
-x:978:/var/lib/dnsmasq +
-x:72:/ +
-x:1000:/home/trainee +
-</code> +
- +
-==Command Line Switches== +
- +
-<WRAP center round todo 60%> +
-**To do** : Use the **--help** option of the **cut** command to view the command line switches. +
-</WRAP> +
- +
-===7.4 - The uniq Command=== +
- +
-The following command is used to extract the Primary Group GIDs from the **/etc/passwd** file: +
- +
-<code> +
-[root@redhat9 tmp]# cut -d: -f4 /etc/passwd | sort -n | uniq +
-+
-+
-+
-+
-7 +
-12 +
-42 +
-50 +
-59 +
-70 +
-72 +
-74 +
-81 +
-100 +
-172 +
-978 +
-979 +
-980 +
-981 +
-982 +
-983 +
-984 +
-986 +
-987 +
-988 +
-990 +
-991 +
-992 +
-993 +
-996 +
-997 +
-1000 +
-65534+
 </code> </code>
  
 <WRAP center round important 60%> <WRAP center round important 60%>
-**Important**: Note the use of the **uniq** command to remove duplicates from the list.+**Important**: By default the tee command overwrites the destination file. To add additional data to the same target file, the **-a** option to the tee command should be used.
 </WRAP> </WRAP>
  
-==Command Line Switches==+====1.12 - Command substitutions====
  
-<WRAP center round todo 60%> +It is sometimes interesting, particularly in scripts, to replace a command with its output valueTo illustrate this point, let's consider the following commands:
-**To do** : Use the **--help** option of the **uniq** command to view the command line switches. +
-</WRAP> +
- +
-===7.5 - The tr Command=== +
- +
-The **tr** command is used to substitute certain characters by other characters. This command **only** accepts data from standard input (hence the pipe):+
  
 <code> <code>
-[root@redhat9 tmp]# cat /etc/passwd | tr "[a-z]" "[A-Z]" +[trainee@redhat9 ~]$ echo date 
-ROOT:X:0:0:ROOT:/ROOT:/BIN/BASH +date
-BIN:X:1:1:BIN:/BIN:/SBIN/NOLOGIN +
-DAEMON:X:2:2:DAEMON:/SBIN:/SBIN/NOLOGIN +
-ADM:X:3:4:ADM:/VAR/ADM:/SBIN/NOLOGIN +
-LP:X:4:7:LP:/VAR/SPOOL/LPD:/SBIN/NOLOGIN +
-SYNC:X:5:0:SYNC:/SBIN:/BIN/SYNC +
-SHUTDOWN:X:6:0:SHUTDOWN:/SBIN:/SBIN/SHUTDOWN +
-HALT:X:7:0:HALT:/SBIN:/SBIN/HALT +
-MAIL:X:8:12:MAIL:/VAR/SPOOL/MAIL:/SBIN/NOLOGIN +
-OPERATOR:X:11:0:OPERATOR:/ROOT:/SBIN/NOLOGIN +
-GAMES:X:12:100:GAMES:/USR/GAMES:/SBIN/NOLOGIN +
-FTP:X:14:50:FTP USER:/VAR/FTP:/SBIN/NOLOGIN +
-NOBODY:X:65534:65534:KERNEL OVERFLOW USER:/:/SBIN/NOLOGIN +
-SYSTEMD-COREDUMP:X:999:997:SYSTEMD CORE DUMPER:/:/SBIN/NOLOGIN +
-DBUS:X:81:81:SYSTEM MESSAGE BUS:/:/SBIN/NOLOGIN +
-POLKITD:X:998:996:USER FOR POLKITD:/:/SBIN/NOLOGIN +
-AVAHI:X:70:70:AVAHI MDNS/DNS-SD STACK:/VAR/RUN/AVAHI-DAEMON:/SBIN/NOLOGIN +
-TSS:X:59:59:ACCOUNT USED FOR TPM ACCESS:/DEV/NULL:/SBIN/NOLOGIN +
-COLORD:X:997:993:USER FOR COLORD:/VAR/LIB/COLORD:/SBIN/NOLOGIN +
-CLEVIS:X:996:992:CLEVIS DECRYPTION FRAMEWORK UNPRIVILEGED USER:/VAR/CACHE/CLEVIS:/USR/SBIN/NOLOGIN +
-RTKIT:X:172:172:REALTIMEKIT:/PROC:/SBIN/NOLOGIN +
-SSSD:X:995:991:USER FOR SSSD:/:/SBIN/NOLOGIN +
-GEOCLUE:X:994:990:USER FOR GEOCLUE:/VAR/LIB/GEOCLUE:/SBIN/NOLOGIN +
-LIBSTORAGEMGMT:X:988:988:DAEMON ACCOUNT FOR LIBSTORAGEMGMT:/:/USR/SBIN/NOLOGIN +
-SYSTEMD-OOM:X:987:987:SYSTEMD USERSPACE OOM KILLER:/:/USR/SBIN/NOLOGIN +
-SETROUBLESHOOT:X:986:986:SELINUX TROUBLESHOOT SERVER:/VAR/LIB/SETROUBLESHOOT:/SBIN/NOLOGIN +
-PIPEWIRE:X:985:984:PIPEWIRE SYSTEM DAEMON:/VAR/RUN/PIPEWIRE:/SBIN/NOLOGIN +
-FLATPAK:X:984:983:USER FOR FLATPAK SYSTEM HELPER:/:/SBIN/NOLOGIN +
-GDM:X:42:42::/VAR/LIB/GDM:/SBIN/NOLOGIN +
-COCKPIT-WS:X:983:982:USER FOR COCKPIT WEB SERVICE:/NONEXISTING:/SBIN/NOLOGIN +
-COCKPIT-WSINSTANCE:X:982:981:USER FOR COCKPIT-WS INSTANCES:/NONEXISTING:/SBIN/NOLOGIN +
-GNOME-INITIAL-SETUP:X:981:980::/RUN/GNOME-INITIAL-SETUP/:/SBIN/NOLOGIN +
-SSHD:X:74:74:PRIVILEGE-SEPARATED SSH:/USR/SHARE/EMPTY.SSHD:/SBIN/NOLOGIN +
-CHRONY:X:980:979:CHRONY SYSTEM USER:/VAR/LIB/CHRONY:/SBIN/NOLOGIN +
-DNSMASQ:X:979:978:DNSMASQ DHCP AND DNS SERVER:/VAR/LIB/DNSMASQ:/SBIN/NOLOGIN +
-TCPDUMP:X:72:72::/:/SBIN/NOLOGIN +
-TRAINEE:X:1000:1000:TRAINEE:/HOME/TRAINEE:/BIN/BASH +
-</code>+
  
-==Command Line Switches== +[trainee@redhat9 ~]$ echo $(date) 
- +Thu Sep 26 12:56:02 PM CEST 2024
-<WRAP center round todo 60%> +
-**To do** : Use the **--help** option of the **tr** command to view the command line switches. +
-</WRAP> +
- +
-===7.6 - The paste Command=== +
- +
-The **paste** command concatenates lines from n files. For example: +
- +
-<code> +
-[root@redhat9 tmp]# paste -d: /etc/passwd /etc/shadow +
-root:x:0:0:root:/root:/bin/bash:root:$6$AbCPA3HFsB/NDBkA$q2T8XLo83bPWCid/WHo.i0m9dgjdfQWiZAkqD/ajOjZ8gHdKFYX5y8kuTvIYY/qMjmu9beCk3BZV8ewL/Q15D1::0:99999:7::: +
-bin:x:1:1:bin:/bin:/sbin/nologin:bin:*:19347:0:99999:7::: +
-daemon:x:2:2:daemon:/sbin:/sbin/nologin:daemon:*:19347:0:99999:7::: +
-adm:x:3:4:adm:/var/adm:/sbin/nologin:adm:*:19347:0:99999:7::: +
-lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin:lp:*:19347:0:99999:7::: +
-sync:x:5:0:sync:/sbin:/bin/sync:sync:*:19347:0:99999:7::: +
-shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown:shutdown:*:19347:0:99999:7::: +
-halt:x:7:0:halt:/sbin:/sbin/halt:halt:*:19347:0:99999:7::: +
-mail:x:8:12:mail:/var/spool/mail:/sbin/nologin:mail:*:19347:0:99999:7::: +
-operator:x:11:0:operator:/root:/sbin/nologin:operator:*:19347:0:99999:7::: +
-games:x:12:100:games:/usr/games:/sbin/nologin:games:*:19347:0:99999:7::: +
-ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin:ftp:*:19347:0:99999:7::: +
-nobody:x:65534:65534:Kernel Overflow User:/:/sbin/nologin:nobody:*:19347:0:99999:7::: +
-systemd-coredump:x:999:997:systemd Core Dumper:/:/sbin/nologin:systemd-coredump:!!:19649:::::: +
-dbus:x:81:81:System message bus:/:/sbin/nologin:dbus:!!:19649:::::: +
-polkitd:x:998:996:User for polkitd:/:/sbin/nologin:polkitd:!!:19649:::::: +
-avahi:x:70:70:Avahi mDNS/DNS-SD Stack:/var/run/avahi-daemon:/sbin/nologin:avahi:!!:19649:::::: +
-tss:x:59:59:Account used for TPM access:/dev/null:/sbin/nologin:tss:!!:19649:::::: +
-colord:x:997:993:User for colord:/var/lib/colord:/sbin/nologin:colord:!!:19649:::::: +
-clevis:x:996:992:Clevis Decryption Framework unprivileged user:/var/cache/clevis:/usr/sbin/nologin:clevis:!!:19649:::::: +
-rtkit:x:172:172:RealtimeKit:/proc:/sbin/nologin:rtkit:!!:19649:::::: +
-sssd:x:995:991:User for sssd:/:/sbin/nologin:sssd:!!:19649:::::: +
-geoclue:x:994:990:User for geoclue:/var/lib/geoclue:/sbin/nologin:geoclue:!!:19649:::::: +
-libstoragemgmt:x:988:988:daemon account for libstoragemgmt:/:/usr/sbin/nologin:libstoragemgmt:!*:19649:::::: +
-systemd-oom:x:987:987:systemd Userspace OOM Killer:/:/usr/sbin/nologin:systemd-oom:!*:19649:::::: +
-setroubleshoot:x:986:986:SELinux troubleshoot server:/var/lib/setroubleshoot:/sbin/nologin:setroubleshoot:!!:19649:::::: +
-pipewire:x:985:984:PipeWire System Daemon:/var/run/pipewire:/sbin/nologin:pipewire:!!:19649:::::: +
-flatpak:x:984:983:User for flatpak system helper:/:/sbin/nologin:flatpak:!!:19649:::::: +
-gdm:x:42:42::/var/lib/gdm:/sbin/nologin:gdm:!!:19649:::::: +
-cockpit-ws:x:983:982:User for cockpit web service:/nonexisting:/sbin/nologin:cockpit-ws:!!:19649:::::: +
-cockpit-wsinstance:x:982:981:User for cockpit-ws instances:/nonexisting:/sbin/nologin:cockpit-wsinstance:!!:19649:::::: +
-gnome-initial-setup:x:981:980::/run/gnome-initial-setup/:/sbin/nologin:gnome-initial-setup:!!:19649:::::: +
-sshd:x:74:74:Privilege-separated SSH:/usr/share/empty.sshd:/sbin/nologin:sshd:!!:19649:::::: +
-chrony:x:980:979:chrony system user:/var/lib/chrony:/sbin/nologin:chrony:!!:19649:::::: +
-dnsmasq:x:979:978:Dnsmasq DHCP and DNS server:/var/lib/dnsmasq:/sbin/nologin:dnsmasq:!!:19649:::::: +
-tcpdump:x:72:72::/:/sbin/nologin:tcpdump:!!:19649:::::: +
-trainee:x:1000:1000:trainee:/home/trainee:/bin/bash:trainee:$6$RTR0r5su3SinU2DK$dt/TI6LByO3SKM04nopxI33O7.eE62rPQ0DlO2HRH2PUtPM4c1pvh3koznv6nE6Z0oCoM0Fq7IUdt8cbjXUMh0::0:99999:7::: +
-</code> +
- +
-==Command Line Switches== +
- +
-<WRAP center round todo 60%> +
-**To do** : Use the **--help** option of the **paste** command to view the command line switches. +
-</WRAP> +
- +
-===7.7 - The split Command=== +
- +
-The split command is used to divide a large file into smaller segments. Create an empty 250 MB file as follows: +
- +
-<code> +
-[root@redhat9 tmp]# dd if=/dev/zero of=/file bs=1024k count=250 +
-250+0 records in +
-250+0 records out +
-262144000 bytes (262 MB, 250 MiB) copied, 0.132123 s, 2.0 GB/s +
-</code>  +
- +
-Now use the split command to divide the file into 5 smaller files each of 50: +
- +
-<code> +
-[root@redhat9 tmp]# split -b 50m /file filepart+
  
-[root@redhat9 tmp]# ls -l | grep filepart +[trainee@redhat9 ~]$ echo `date` 
--rw-r--r--. 1 root root 52428800 Sep 25 16:17 filepartaa +Thu Sep 26 12:56:17 PM CEST 2024
--rw-r--r--. 1 root root 52428800 Sep 25 16:17 filepartab +
--rw-r--r--. 1 root root 52428800 Sep 25 16:17 filepartac +
--rw-r--r--. 1 root root 52428800 Sep 25 16:17 filepartad +
--rw-r--r--. 1 root root 52428800 Sep 25 16:17 filepartae+
 </code> </code>
  
 <WRAP center round important 60%> <WRAP center round important 60%>
-**Important**: Note that the 5 files were created in the current working directory.+**Important**: Note the format of each **$(command)** or **`commande`** substitution. On a French keyboard, the anti-coast is accessed using the <key>Alt Gr</key> and <key>7</key><key>7</key> keys.
 </WRAP> </WRAP>
  
-You can re-construct the original file by using the **cat** command:+====1.13 Command chaining====
  
-<code> +It is possible to group commands together using a sub-shell :
-[root@redhat9 tmp]# cat fileparta* > newfile +
-[root@redhat9 tmp]# ls -l | grep newf +
--rw-r--r--. 1 root root 262144000 Sep 25 16:18 newfile +
-[root@redhat9 tmp]# ls -l / | grep file +
--rw-r--r--.   1 root root 262144000 Sep 25 16:17 file +
-</code>+
  
-==Command Line Switches==+  $ (ls -l; ps; who) > list [Enter]
  
-<WRAP center round todo 60%> +This example sends the results of the three commands to the **list** file, processing them in the background
-**To do** : Use the **--help** option of the **split** command to view the command line switches. +
-</WRAP>+
  
-===7.8 - The diff Command===+The commands can also be chained according to the exit code of the previous command.
  
-The diff command compares two fles and indicates what changes need to be made to the first file in order that it be identical to the second file.+**&&** is used to ensure that the second command is executed if the output status value is 0, i.e. there were no errors
  
-Copy the **/etc/passwd** file to the **/root** directory:+**||** is used to ensure the reverse.
  
-<code> +The syntax of this command is :
-[root@redhat9 ~]# cp /etc/passwd /root +
-</code>+
  
-Edit the ***/root/passwd** file as shown:+  Command1 && Command2
  
-<file> +In this case, Command2 is only executed if Command1 has run without error.
-... +
-trainee10:x:1000:1000:trainee:/home/trainee:/bin/bash +
-... +
-</file>+
  
-Delete the **tcpdump** entry and add the following line to the end of **/root/passwd**:+Or :
  
-<file> +  Command1 || Command2
-... +
-Linux est super! +
-</file>+
  
-Now compare the two files:+In this case, Command2 is executed if Command1 has encountered an error.
  
-<code> +====1.14 Displaying shell variables====
-[root@redhat9 tmp]# diff /etc/passwd /root/passwd +
-26,27c26 +
-< tcpdump:x:72:72::/:/sbin/nologin +
-< trainee:x:1000:1000:trainee:/home/trainee:/bin/bash +
---- +
-> trainee10:x:1000:1000:trainee:/home/trainee:/bin/bash +
-36a36 +
-> Linux est super! +
-</code>+
  
-In this output you will notice the **<** and **>** characters. The first makes reference to the first file, /etc/passwd, whist the second makes reference to the second file, /root/passwd.+A shell variable can be displayed using the command :
  
-The output **26,27c26** means that line 27 needs to be changed in /etc/passwd so that is the same as line 26 in /root/passwd.+  $ echo $VARIABLE [Input]
  
-The output **36a36** means that at line 36 in /etc/passwd line 36 from /root/passwd needs to be added.+=== Main variables ===
  
-==Command Line Switches==+^ Variable ^ Description ^ 
 +| BASH | Complete path to current shell. | 
 +| BASH_VERSION |Shell version. | 
 +| EUID | EUID of the current user. | 
 +| UID | UID of the current user. | 
 +| PPID | PID of the parent of the current process. | 
 +| PWD | The current directory. | 
 +| OLDPWD | The previous current directory ( like the **cd -**command ).| 
 +| RANDOM | A random number between 0 and 32767. | 
 +| SECONDS | The numbers of seconds since the shell was started.| 
 +| LINES | The number of lines in a screen. | 
 +| COLUMNS | The number of columns in a screen . | 
 +| HISTFILE | The history file. | 
 +| HISTFILESIZE | The history file size. | 
 +| HISTSIZE | The number of commands that can be saved to the history file. | 
 +| HISTCMD | The current command's number in the History. | 
 +| HISTCONTROL | **ignorespace** or **ignoredups** or **ignoreboth** | 
 +| HOME | The user's home directory. | 
 +| HOSTTYPE | Machine type. | 
 +| OSTYPE | The OS type. | 
 +| MAIL | The file containing the user's mail. | 
 +| MAILCHECK | Frequency in seconds that a user's mail is checked. | 
 +| PATH | The paths to executables. | 
 +| PROMPT_COMMAND | Command executed before each prompt is displayed. | 
 +| PS1 | User's default prompt. | 
 +| PS2 | User's 2nd level default prompt. | 
 +| PS3 | User's 3rd level  prompt. | 
 +| PS4 | User's 4th level  prompt. | 
 +| SHELL | User's current shell. | 
 +| SHLVL | The number of shell instances. | 
 +| TMOUT | The number of seconds less 60 before an unused terminal gets sent the **exit** command. |
  
-<WRAP center round todo 60%> +=== Internationalization and Localization Variables ===
-**To do** : Use the **--help** option of the **diff** command to view the command line switches. +
-</WRAP>+
  
-===7.9 - The cmp Command===+**Internationalization**, also known as **i18n** because there are 18 letters between the letter **I** and the letter **n** in the word //Internationalization//, involves adapting software to parameters that vary from one region to another: 
  
-The **cmp** command compares two files character by character. By defaultthe command stops after finding the first difference:+  Text processing differences,  
 +  Writing direction,  
 +  Different systems of numerals,  
 +  Telephone numbersaddresses and international postal codes,  
 +  * Weights and measures,  
 +  * Date/time format, 
 +  * Paper sizes,  
 +  * Keyboard layout, 
 +  * etc ...
  
-<code> +The **Localization**, also called **l10n** because there are 10 letters between the letter **L** and the letter n in the word //Localization//, consists of modifying the internalisation according to a specific region. 
-[root@redhat9 tmp]# cmp /root/passwd /etc/passwd +
-/root/passwd /etc/passwd differ: byte 1300line 26 +
-</code>+
  
-The **-l** switch shows all of the differences in a three column format:+The complete country code takes the following form: **language-PAYS.character_set**. For example, for the English language the language-PAYS values are :
  
-<code> +  * en_GB = Great Britain,  
-[root@redhat9 tmp]# cmp -l /root/passwd /etc/passwd | more +  * en_US = USA,  
-cmp: EOF on /root/passwd after byte 1931 +  * en_AU = Australia,  
-1300 162 143 +  * en_NZ = New Zealand,  
-1301 141 160 +  * en_ZA = South Africa,  
-1302 151 144 +  * en_CA = Canada.
-1303 156 165 +
-1304 145 155 +
-1305 145 160 +
-1306  61  72 +
-1307  60 170 +
-1309 170  67 +
-1310  72  62 +
-1311  61  72 +
-1312  60  67 +
-1313  60  62 +
-1314  60  72 +
-1316  61  57 +
-1317  60  72 +
-1318  60  57 +
-1319  60 163 +
-1320  72 142 +
-1321 164 151 +
-1322 162 156 +
-1323 141  57 +
-1324 151 156 +
---More-- +
-</code>+
  
-The first column represents the character **number**, the second column represents the **ASCII octal value** of the character in the **/root/passwd** file and the third column represents the **ASCII octal value** of the character in the **/etc/passwd** file. +The most important system variables containing regionalisation information are :
  
-==Command Line Switches==+^ Variable ^ Description ^ 
 +| LC_ALL | With a non-zero value, this takes precedence over the value of all other internationalisation variables. | 
 +| LANG | Provides a default value for environment variables whose value is null or undefined. | 
 +| LC_CTYPE | Determines the regional parameters for interpreting the sequence of bytes of text data in characters. |
  
-<WRAP center round todo 60%> +For example:
-**To do** : Use the **--help** option of the **cmp** command to view the command line switches. +
-</WRAP> +
- +
-===7.10 - The patch Command=== +
- +
-La commande **patch** est utilisée pour appliquer des modifications à un fichier à partir d'un fichier patch qui contient les The **patch** command is used to apply modifications contained within a patch file to an older version of a file so that it becomes the newer version of the file. +
- +
-The **patch** command is not installed by default in RHEL 9:+
  
 <code> <code>
-[root@redhat9 ~]# dnf install patch -y +[trainee@redhat9 ~]$ echo $LC_ALL
-</code>+
  
-If you recall, you made some changes to the /tmp/greptest et /tmp/greptest1 files:+[trainee@redhat9 ~]$ echo $LC_CTYPE
  
-<code> +[trainee@redhat9 ~]$ echo $LANG 
-[root@redhat9 tmp]# cat /tmp/greptest +en_US.UTF-8 
-# Starting comment +[trainee@redhat9 ~]$ locale 
-^ This line will be used to demonstrate the use of fgrep +LANG=en_US.UTF-8 
-fenestrOS +LC_CTYPE="en_US.UTF-8’ 
-fenestros +LC_NUMERIC="en_US.UTF-8’ 
-# Another comment +LC_TIME="en_US.UTF-8’ 
-555-5555 +LC_COLLATE="en_US.UTF-8’ 
-f +LC_MONETARY="en_US.UTF-8 
- +LC_MESSAGES="en_US.UTF-8’ 
-.fenestros +LC_PAPER="en_US.UTF-8’ 
- +LC_NAME="en_US.UTF-8’ 
-.fe +LC_ADDRESS="en_US.UTF-8’ 
- +LC_TELEPHONE="en_US.UTF-8’ 
-£ +LC_MEASUREMENT="en_US.UTF-8’ 
-# End comment +LC_IDENTIFICATION="en_US.UTF-8 
- +LC_ALL=
-[root@redhat9 tmp]# cat /tmp/greptest1 +
-fenestrOS +
-fenestros +
-555-5555 +
-f +
-.fenestros +
-.fe +
-£+
 </code> </code>
  
-Now create a patch file containing the modifications that need to be applied to /tmp/greptest in order for it to be identical to /tmp/greptest1:+===Special variables===
  
-<code> +^ Variable ^ Description ^ 
-[root@redhat9 tmp]# diff -u greptest greptest1 > greptest.patch +| $LINENO | Contains the current line number of the script or function being executed | 
-</code>+| $$ | Contains the PID of the current process | 
 +| $PPID | Contains the PID of the parent of the current process | 
 +| $0 | Contains the name of the current script | 
 +| $1, $2 ... | Contains respectively the 1st, 2nd etc arguments passed to the script | 
 +| $# | Contains the total number of arguments passed to the script | 
 +| $* | Contains all of the arguments passed to the script | 
 +| $@ | Contains all of the arguments passed to the script |
  
-A look at the patch file shows the chnages that need to be made to the **greptest** file:+====1.15 - The env command ====
  
-<code> +The **env** command sends the values of the system variables in the environment of the user invoking it to the standard output:
-[root@redhat9 tmp]# cat greptest.patch +
---- greptest 2021-04-20 05:23:52.710188632 -0400 +
-+++ greptest1 2021-04-20 05:21:55.189882834 -0400 +
-@@ -1,14 +1,7 @@ +
--# Starting comment +
--^ This line will be used to demonstrate the use of fgrep +
- fenestrOS +
- fenestros +
--# Another comment +
- 555-5555 +
- f +
-+
- .fenestros +
-+
- .fe +
-+
- £ +
--# End comment +
-</code> +
- +
-Now apply the patch file:+
  
 <code> <code>
-[root@redhat9 tmp]# patch < greptest.patch +[trainee@redhat9 ~]$ env 
-patching file greptest+SHELL=/bin/bash 
 +HISTCONTROL=ignoredups 
 +HISTSIZE=1000 
 +HOSTNAME=redhat9.ittraining.loc 
 +PWD=/home/trainee 
 +LOGNAME=trainee 
 +XDG_SESSION_TYPE=tty 
 +MOTD_SHOWN=pam 
 +HOME=/home/trainee 
 +LANG=en_US.UTF-8 
 +LS_COLORS=rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=01;37;41:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.zst=01;31:*.tzst=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.wim=01;31:*.swm=01;31:*.dwm=01;31:*.esd=01;31:*.jpg=01;35:*.jpeg=01;35:*.mjpg=01;35:*.mjpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.webp=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=01;36:*.au=01;36:*.flac=01;36:*.m4a=01;36:*.mid=01;36:*.midi=01;36:*.mka=01;36:*.mp3=01;36:*.mpc=01;36:*.ogg=01;36:*.ra=01;36:*.wav=01;36:*.oga=01;36:*.opus=01;36:*.spx=01;36:*.xspf=01;36: 
 +SSH_CONNECTION=10.0.2.1 37578 10.0.2.101 22 
 +XDG_SESSION_CLASS=user 
 +SELINUX_ROLE_REQUESTED= 
 +TERM=xterm-256color 
 +LESSOPEN=||/usr/bin/lesspipe.sh %s 
 +USER=trainee 
 +SELINUX_USE_CURRENT_RANGE= 
 +SHLVL=1 
 +XDG_SESSION_ID=4 
 +XDG_RUNTIME_DIR=/run/user/1000 
 +SSH_CLIENT=10.0.2.1 37578 22 
 +which_declare=declare -f 
 +XDG_DATA_DIRS=/home/trainee/.local/share/flatpak/exports/share:/var/lib/flatpak/exports/share:/usr/local/share:/usr/share 
 +PATH=/home/trainee/.local/bin:/home/trainee/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin 
 +SELINUX_LEVEL_REQUESTED= 
 +DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus 
 +MAIL=/var/spool/mail/trainee 
 +SSH_TTY=/dev/pts/
 +BASH_FUNC_which%%=() {  ( alias; 
 + eval ${which_declare} ) | /usr/bin/which --tty-only --read-alias --read-functions --show-tilde --show-dot $@ 
 +
 +_=/usr/bin/env 
 +OLDPWD=/home/trainee/training
 </code> </code>
  
-Finallycheck the contents of the patched **greptest** file:+The command can also be used to set a variable when executing a command. For exampleto run **xterm** with the EDITOR variable set to **vi**:
  
-<code> +  $ env EDITOR=vim xterm
-[root@redhat9 tmp]# cat greptest +
-fenestrOS +
-fenestros +
-555-5555 +
-+
-.fenestros +
-.fe +
-£ +
-</code>+
  
-==Command Line Switches==+====1.16 - Bash Shell options====
  
-<WRAP center round todo 60%> +To view the bash shell options, use the **set** command:
-**To do** : Use the **--help** option of the **patch** command to view the command line switches. +
-</WRAP>+
  
-===7.11 The strings Command===+  $ set -o [Enter]
  
-The **strings** Command is used to extract any printable string in one or more object files or executables. An object fie is an intermediary file used when compiling. +For example:
- +
-The format of an object file is **ELF** (Executable and Linkable Format). This same format is also used for: +
- +
-  * executables, +
-  * shared libraries, +
-  * core dumps. +
- +
-Used as is, the command extracts all strings greater than 4 characters in length:+
  
 <code> <code>
-[root@redhat9 tmp]# strings /usr/bin/passwd | more +[trainee@redhat9 ~]$ set -o 
-/lib64/ld-linux-x86-64.so.2 +allexport off 
-libuser.so.1 +braceexpand on 
-g_value_get_int64 +emacs on 
-is_selinux_enabled +errexit off 
-_ITM_deregisterTMCloneTable +errtrace off 
-g_free +functrace off 
-g_value_array_get_nth +hashall on 
-audit_open +histexpand on 
-__gmon_start__ +history on 
-g_value_get_string +ignoreeof off 
-g_type_check_value_holds +interactive-comments on 
-g_value_get_long +keyword off 
-freecon +monitor on 
-audit_log_acct_message +noclobber off 
-_ITM_registerTMCloneTable +noexec off 
-lu_ent_set_string +noglob off 
-lu_ent_get_first_value_strdup +nolog off 
-lu_error_free +notify off 
-lu_user_lock +nounset off 
-lu_strerror +onecmd off 
-lu_ent_free +physical off 
-lu_ent_new +pipefail off 
-lu_user_modify +posix off 
---More--+privileged off 
 +verbose off 
 +vi off 
 +xtrace off
 </code> </code>
  
-Print the offset within the file before each string:+To activate an option it is again convenient to use the **set** command:
  
 <code> <code>
-[root@redhat9 tmp]# strings -t d /usr/bin/passwd | more +[trainee@redhat9 ~]$ set -o allexport 
-    624 /lib64/ld-linux-x86-64.so.2 +[trainee@redhat9 ~]$ set -o 
-   2809 libuser.so.1 +allexport on 
-   2822 g_value_get_int64 +braceexpand on 
-   2840 is_selinux_enabled +emacs on 
-   2859 _ITM_deregisterTMCloneTable +errexit off 
-   2887 g_free +errtrace off 
-   2894 g_value_array_get_nth +functrace off 
-   2916 audit_open +hashall on 
-   2927 __gmon_start__ +histexpand on 
-   2942 g_value_get_string +history on 
-   2961 g_type_check_value_holds +ignoreeof off 
-   2986 g_value_get_long +interactive-comments on 
-   3003 freecon +keyword off 
-   3011 audit_log_acct_message +monitor on 
-   3034 _ITM_registerTMCloneTable +noclobber off 
-   3060 lu_ent_set_string +noexec off 
-   3078 lu_ent_get_first_value_strdup +noglob off 
-   3108 lu_error_free +nolog off 
-   3122 lu_user_lock +notify off 
-   3135 lu_strerror +nounset off 
-   3147 lu_ent_free +onecmd off 
-   3159 lu_ent_new +physical off 
-   3170 lu_user_modify +pipefail off 
---More--+posix off 
 +privileged off 
 +verbose off 
 +vi off 
 +xtrace off
 </code> </code>
  
-The **-t** switch can take one of three arguments that specify the numbering system to use:+Note that the **allexport** option has been enabled.
  
-^ Argument ^ Numbering System ^ +To disable an option, we use the **set** command with the **+o** option:
-| d | Decimal | +
-| Octal | +
-| x | Hexadecimal |+
  
-The **-n** switch prints sequences of characters that are at least **min-len** characters long, instead of the default 4:+  $ set +o allexport [Enter]
  
 <code> <code>
-[root@redhat9 tmp]# strings -t d -n 15 /usr/bin/passwd | more +[trainee@redhat9 ~]$ set +o allexport 
-    624 /lib64/ld-linux-x86-64.so.2 +[trainee@redhat9 ~]$ set -o 
-   2822 g_value_get_int64 +allexport off 
-   2840 is_selinux_enabled +braceexpand on 
-   2859 _ITM_deregisterTMCloneTable +emacs on 
-   2894 g_value_array_get_nth +errexit off 
-   2942 g_value_get_string +errtrace off 
-   2961 g_type_check_value_holds +functrace off 
-   2986 g_value_get_long +hashall on 
-   3011 audit_log_acct_message +histexpand on 
-   3034 _ITM_registerTMCloneTable +history on 
-   3060 lu_ent_set_string +ignoreeof off 
-   3078 lu_ent_get_first_value_strdup +interactive-comments on 
-   3185 lu_prompt_console +keyword off 
-   3212 lu_user_lookup_name +monitor on 
-   3239 lu_ent_set_long +noclobber off 
-   3281 lu_user_removepass +noexec off 
-   3300 libgobject-2.0.so.0 +noglob off 
-   3320 libglib-2.0.so.0 +nolog off 
-   3379 poptHelpOptions +notify off 
-   3435 poptSetOtherOptionHelp +nounset off 
-   3543 libpam_misc.so.0 +onecmd off 
-   3584 audit_log_user_avc_message +physical off 
-   3611 libselinux.so.1 +pipefail off 
---More--+posix off 
 +privileged off 
 +verbose off 
 +vi off 
 +xtrace off
 </code> </code>
  
-The **-f** switch prints the name of the file before each string:+These are the most interesting options:
  
-<code> +^ Option ^ Default value ^ Description ^ 
-[root@redhat9 tmp]# strings -f /bin/grep "(c)" +allexport | off | The shell automatically exports all variables | 
-/bin/btrace: # Copyright (c) 2005 Silicon Graphics, Inc. +| emacs | on | emacs editing mode | 
-/bin/buildah: 0,1,2,3,4,5,6,7,8,9,(a)(b)(c)(d)(e)(f)(g)(h)(i)(j)(k)(l)(m)(n)(o)(p)(q)(r)(s)(t)(u)(v)(w)(x)(y)(z) +| noclobber  | off | Simple re-directions do not squash the target file if it exists | 
-/bin/buildah: B!!B!?B..B0,B0.B1,B1.B10B11B12B13B14B15B16B17B18B19B2,B2.B20B21B22B23B24B25B26B27B28B29B3,B3.B30B31B32B33B34B35B36B37B38B39B4,B4.B40B41B42B43B44B45B46B47B48B49B5,B5.B50B6,B6.B7,B7.B8,B8.B9,B9.B==B?!B??BAUBBqBCDBDJBDZBDzBGBBGyBHPBHVBHgBHzBIIBIJBIUBIVBIXBKBBKKBKMBLJBLjBMBBMCBMDBMRBMVBMWBNJBNjBNoBPHBPRBPaBRsBSDBSMBSSBSvBTMBVIBWCBWZBWbBXIBccBcdBcmBdBBdaBdlBdmBdzBeVBffBfiBflBfmBhaBiiBijBinBivBixBkABkVBkWBkgBklBkmBktBljBlmBlnBlxBm2Bm3BmABmVBmWBmbBmgBmlBmmBmsBnABnFBnVBnWBnjBnmBnsBoVBpABpFBpVBpWBpcBpsBsrBstBviBxiC(1)C(2)C(3)C(4)C(5)C(6)C(7)C(8)C(9)C(A)C(B)C(C)C(D)C(E)C(F)C(G)C(H)C(I)C(J)C(K)C(L)C(M)C(N)C(O)C(P)C(Q)C(R)C(S)C(T)C(U)C(V)C(W)C(X)C(Y)C(Z)C(a)C(b)C(c)C(d)C(e)C(f)C(g)C(h)C(i)C(j)C(k)C(l)C(m)C(n)C(o)C(p)C(q)C(r)C(s)C(t)C(u)C(v)C(w)C(x)C(y)C(z)C...C10.C11.C12.C13.C14.C15.C16.C17.C18.C19.C20.C::=C===CCo.CFAXCGHzCGPaCIIICLTDCL +| noglob | off | Turns off metacharacters | 
-/bin/cdda-player: (c) 1997-98 Gerd Knorr <kraxel@goldbach.in-berlin.de> +| nounset | off | The shell will return an error if the variable is not set | 
-/bin/cdda-player: (c) 2005-2006, 2017 Rocky Bernstein <rocky@gnu.org> +| verbose | off | Echos back the typed command | 
-/bin/cd-drive: Copyright (c) 2003-2005, 2007-2008, 2011-2015, 2017 R. Bernstein +| vi | off | vi editing mode |
-/bin/cd-info: Copyright (c) 2003-2005, 2007-2008, 2011-2015, 2017 R. Bernstein +
-/bin/cd-read: Copyright (c) 2003-2005, 2007-2008, 2011-2015, 2017 R. Bernstein +
-/bin/chcat:         if len(c) > 0 and (c[0] == "+" or c[0] == "-"): +
-/bin/chcat:                 if len(c) > 0 and c[0] == "+": +
-/bin/chcat:                 if len(c) > 0 and c[0] == "-": +
-/bin/clevis: # Copyright (c) 2017 Red Hat, Inc. +
-/bin/clevis-decrypt: # Copyright (c) 2017 Red Hat, Inc. +
-/bin/clevis-decrypt-null: # Copyright (c) 2017 Red Hat, Inc. +
-/bin/clevis-decrypt-tang: # Copyright (c) 2017 Red Hat, Inc. +
-/bin/clevis-decrypt-tpm2: # Copyright (c) 2017 Red Hat, Inc. +
-/bin/clevis-encrypt-null: # Copyright (c) 2017 Red Hat, Inc. +
-/bin/clevis-encrypt-tang: # Copyright (c) 2017 Red Hat, Inc. +
-/bin/clevis-encrypt-tpm2: # Copyright (c) 2017 Red Hat, Inc. +
-/bin/clevis-luks-bind: # Copyright (c) 2016 Red Hat, Inc. +
-/bin/clevis-luks-common-functions: # Copyright (c) 2019 Red Hat, Inc. +
-/bin/clevis-luks-edit: # Copyright (c) 2020 Red Hat, Inc. +
-/bin/clevis-luks-list: # Copyright (c) 2017-2019 Red Hat, Inc. +
-/bin/clevis-luks-pass: # Copyright (c) 2019 Red Hat, Inc. +
-/bin/clevis-luks-regen: # Copyright (c) 2020 Red Hat, Inc. +
-/bin/clevis-luks-report: # Copyright (c) 2018, 2020 Red Hat, Inc. +
-/bin/clevis-luks-unbind: # Copyright (c) 2017 Red Hat, Inc. +
-/bin/clevis-luks-unlock: # Copyright (c) 2016 Red Hat, Inc. +
-/bin/diffpp: # Copyright (c) 1996-1998 Markku Rossi +
-/bin/gnome-control-center: NM_IS_REMOTE_CONNECTION (c) +
-/bin/ibus-setup: # Copyright (c) 2007-2010 Peng Huang <shawn.p.huang@gmail.com> +
-/bin/ibus-setup: # Copyright (c) 2018-2019 Takao Fujiwara <takao.fujiwara1@gmail.com> +
-/bin/ibus-setup: # Copyright (c) 2007-2018 Red Hat, Inc. +
-/bin/iso-info: Copyright (c) 2003-2005, 2007-2008, 2011-2015, 2017 R. Bernstein +
-/bin/iso-read: Copyright (c) 2003-2005, 2007-2008, 2011-2015, 2017 R. Bernstein +
-/bin/itstool: # Copyright (c) 2010-2018 Shaun McCance <shaunm@gnome.org> +
-/bin/lsusb.py: # Copyright (c) 2009 Kurt Garloff <garloff@suse.de> +
-/bin/lsusb.py: # Copyright (c) 2013,2018 Kurt Garloff <kurt@garloff.de> +
-/bin/mmc-tool: Copyright (c) 2003-2005, 2007-2008, 2011-2015, 2017 R. Bernstein +
-/bin/orca: __copyright__ = "Copyright (c) 2010-2012 The Orca Team" \ +
-/bin/orca:                 "Copyright (c) 2012 Igalia, S.L." +
-/bin/pinentry: # Copyright (c) 2006 SUSE LINUX Products GmbH, Nuernberg, Germany. +
-/bin/pinentry: # Copyright (c) 2009 Fedora Project +
-/bin/pinentry: # Copyright (c) 2014-2015 Red Hat +
-/bin/pkgconf: Copyright (c) 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020 +
-/bin/pod2usage: # Copyright (c) 1996-2000 by Bradford Appleton. All rights reserved. +
-/bin/pod2usage: # Copyright (c) 2001-2016 by Marek Rouchal. +
-/bin/podman: 0,1,2,3,4,5,6,7,8,9,(a)(b)(c)(d)(e)(f)(g)(h)(i)(j)(k)(l)(m)(n)(o)(p)(q)(r)(s)(t)(u)(v)(w)(x)(y)(z) +
-/bin/podman: B!!B!?B..B0,B0.B1,B1.B10B11B12B13B14B15B16B17B18B19B2,B2.B20B21B22B23B24B25B26B27B28B29B3,B3.B30B31B32B33B34B35B36B37B38B39B4,B4.B40B41B42B43B44B45B46B47B48B49B5,B5.B50B6,B6.B7,B7.B8,B8.B9,B9.B==B?!B??BAUBBqBCDBDJBDZBDzBGBBGyBHPBHVBHgBHzBIIBIJBIUBIVBIXBKBBKKBKMBLJBLjBMBBMCBMDBMRBMVBMWBNJBNjBNoBPHBPRBPaBRsBSDBSMBSSBSvBTMBVIBWCBWZBWbBXIBccBcdBcmBdBBdaBdlBdmBdzBeVBffBfiBflBfmBhaBiiBijBinBivBixBkABkVBkWBkgBklBkmBktBljBlmBlnBlxBm2Bm3BmABmVBmWBmbBmgBmlBmmBmsBnABnFBnVBnWBnjBnmBnsBoVBpABpFBpVBpWBpcBpsBsrBstBviBxiC(1)C(2)C(3)C(4)C(5)C(6)C(7)C(8)C(9)C(A)C(B)C(C)C(D)C(E)C(F)C(G)C(H)C(I)C(J)C(K)C(L)C(M)C(N)C(O)C(P)C(Q)C(R)C(S)C(T)C(U)C(V)C(W)C(X)C(Y)C(Z)C(a)C(b)C(c)C(d)C(e)C(f)C(g)C(h)C(i)C(j)C(k)C(l)C(m)C(n)C(o)C(p)C(q)C(r)C(s)C(t)C(u)C(v)C(w)C(x)C(y)C(z)C...C10.C11.C12.C13.C14.C15.C16.C17.C18.C19.C20.C::=C===CCo.CFAXCGHzCGPaCIIICLTDCL +
-/bin/podmansh: 0,1,2,3,4,5,6,7,8,9,(a)(b)(c)(d)(e)(f)(g)(h)(i)(j)(k)(l)(m)(n)(o)(p)(q)(r)(s)(t)(u)(v)(w)(x)(y)(z) +
-/bin/podmansh: B!!B!?B..B0,B0.B1,B1.B10B11B12B13B14B15B16B17B18B19B2,B2.B20B21B22B23B24B25B26B27B28B29B3,B3.B30B31B32B33B34B35B36B37B38B39B4,B4.B40B41B42B43B44B45B46B47B48B49B5,B5.B50B6,B6.B7,B7.B8,B8.B9,B9.B==B?!B??BAUBBqBCDBDJBDZBDzBGBBGyBHPBHVBHgBHzBIIBIJBIUBIVBIXBKBBKKBKMBLJBLjBMBBMCBMDBMRBMVBMWBNJBNjBNoBPHBPRBPaBRsBSDBSMBSSBSvBTMBVIBWCBWZBWbBXIBccBcdBcmBdBBdaBdlBdmBdzBeVBffBfiBflBfmBhaBiiBijBinBivBixBkABkVBkWBkgBklBkmBktBljBlmBlnBlxBm2Bm3BmABmVBmWBmbBmgBmlBmmBmsBnABnFBnVBnWBnjBnmBnsBoVBpABpFBpVBpWBpcBpsBsrBstBviBxiC(1)C(2)C(3)C(4)C(5)C(6)C(7)C(8)C(9)C(A)C(B)C(C)C(D)C(E)C(F)C(G)C(H)C(I)C(J)C(K)C(L)C(M)C(N)C(O)C(P)C(Q)C(R)C(S)C(T)C(U)C(V)C(W)C(X)C(Y)C(Z)C(a)C(b)C(c)C(d)C(e)C(f)C(g)C(h)C(i)C(j)C(k)C(l)C(m)C(n)C(o)C(p)C(q)C(r)C(s)C(t)C(u)C(v)C(w)C(x)C(y)C(z)C...C10.C11.C12.C13.C14.C15.C16.C17.C18.C19.C20.C::=C===CCo.CFAXCGHzCGPaCIIICLTDCL +
-/bin/qemu-ga: Copyright (c) 2003-2023 Fabrice Bellard and the QEMU Project developers +
-/bin/rescan-scsi-bus.sh: # (c) 1998--2010 Kurt Garloff <kurt@garloff.de>, GNU GPL v2 or v3 +
-/bin/rescan-scsi-bus.sh: # (c) 2006--2018 Hannes Reinecke, GNU GPL v2 or later +
-/bin/rhc: 0,1,2,3,4,5,6,7,8,9,(a)(b)(c)(d)(e)(f)(g)(h)(i)(j)(k)(l)(m)(n)(o)(p)(q)(r)(s)(t)(u)(v)(w)(x)(y)(z) +
-/bin/rhc: B!!B!?B..B0,B0.B1,B1.B10B11B12B13B14B15B16B17B18B19B2,B2.B20B21B22B23B24B25B26B27B28B29B3,B3.B30B31B32B33B34B35B36B37B38B39B4,B4.B40B41B42B43B44B45B46B47B48B49B5,B5.B50B6,B6.B7,B7.B8,B8.B9,B9.B==B?!B??BAUBBqBCDBDJBDZBDzBGBBGyBHPBHVBHgBHzBIIBIJBIUBIVBIXBKBBKKBKMBLJBLjBMBBMCBMDBMRBMVBMWBNJBNjBNoBPHBPRBPaBRsBSDBSMBSSBSvBTMBVIBWCBWZBWbBXIBccBcdBcmBdBBdaBdlBdmBdzBeVBffBfiBflBfmBhaBiiBijBinBivBixBkABkVBkWBkgBklBkmBktBljBlmBlnBlxBm2Bm3BmABmVBmWBmbBmgBmlBmmBmsBnABnFBnVBnWBnjBnmBnsBoVBpABpFBpVBpWBpcBpsBsrBstBviBxiC(1)C(2)C(3)C(4)C(5)C(6)C(7)C(8)C(9)C(A)C(B)C(C)C(D)C(E)C(F)C(G)C(H)C(I)C(J)C(K)C(L)C(M)C(N)C(O)C(P)C(Q)C(R)C(S)C(T)C(U)C(V)C(W)C(X)C(Y)C(Z)C(a)C(b)C(c)C(d)C(e)C(f)C(g)C(h)C(i)C(j)C(k)C(l)C(m)C(n)C(o)C(p)C(q)C(r)C(s)C(t)C(u)C(v)C(w)C(x)C(y)C(z)C...C10.C11.C12.C13.C14.C15.C16.C17.C18.C19.C20.C::=C===CCo.CFAXCGHzCGPaCIIICLTDCL +
-/bin/screen: Copyright (c) 2018-2020 Alexander Naumov, Amadeusz Slawinski +
-/bin/screen: Copyright (c) 2015-2017 Juergen Weigert, Alexander Naumov, Amadeusz Slawinski +
-/bin/screen: Copyright (c) 2010-2014 Juergen Weigert, Sadrul Habib Chowdhury +
-/bin/screen: Copyright (c) 2008-2009 Juergen Weigert, Michael Schroeder, Micah Cowan, Sadrul Habib Chowdhury +
-/bin/screen: Copyright (c) 1993-2007 Juergen Weigert, Michael Schroeder +
-/bin/screen: Copyright (c) 1987 Oliver Laumann +
-/bin/scsi-rescan: # (c) 1998--2010 Kurt Garloff <kurt@garloff.de>, GNU GPL v2 or v3 +
-/bin/scsi-rescan: # (c) 2006--2018 Hannes Reinecke, GNU GPL v2 or later +
-/bin/sg_test_rwbuf: (c) Douglas Gilbert, Kurt Garloff, 2000-2007, GNU GPL +
-/bin/slabinfo: slabinfo 4/15/2011. (c) 2007 sgi/(c) 2011 Linux Foundation. +
-/bin/sliceprint: # Copyright (c) 1996-1999 Markku Rossi +
-/bin/soundstretch:     Copyright (c) Olli Parviainen +
-/bin/soundstretch:    SoundStretch v%s -  Copyright (c) Olli Parviainen +
-/bin/ssh-copy-id: # Copyright (c) 1999-2020 Philip Hands <phil@hands.com> +
-/bin/strace: Copyright (c) 1991-%s The strace developers <%s>+
-/bin/strace-log-merge: # Copyright (c) 2012-2021 The strace developers. +
-/bin/tree: $Version: $ tree v1.8.0 (c) 1996 - 2018 by Steve Baker, Thomas Moore, Francesc Rocher, Florian Sesser, Kyosuke Tokoro $ +
-/bin/usb-devices: # Copyright (c) 2009 Greg Kroah-Hartman <greg@kroah.com> +
-/bin/usb-devices: # Copyright (c) 2009 Randy Dunlap <rdunlap@xenotime.net> +
-/bin/usb-devices: # Copyright (c) 2009 Frans Pop <elendil@planet.nl> +
-/bin/vm-support: # Copyright (c) 2006-2022 VMware, Inc. All rights reserved. +
-/bin/wavpack:  Copyright (c) 1998 - 2020 David Bryant.  All Rights Reserved. +
-/bin/wvgain:  Copyright (c) 2005 - 2020 David Bryant.  All Rights Reserved. +
-/bin/wvtag:  Copyright (c) 2018 - 2020 David Bryant.  All Rights Reserved. +
-/bin/wvunpack:  Copyright (c) 1998 - 2020 David Bryant.  All Rights Reserved. +
-/bin/xgettext: UNICODE_VALUE (c) >= 0 && UNICODE_VALUE (c) < 0x110000 +
-/bin/zip: Copyright (c) 1990-2008 Info-ZIP - Type '%s "-L"' for software license. +
-/bin/zip: Copyright (c) 1990-2008 Info-ZIP.  All rights reserved. +
-/bin/zip:     bzip2 code and library copyright (c) Julian     (See the bzip2 license for t> +
-/bin/zipcloak: Copyright (c) 1990-2008 Info-ZIP - Type '%s "-L"' for software license. +
-/bin/zipcloak: Copyright (c) 1990-2008 Info-ZIP.  All rights reserved. +
-/bin/zipnote: Copyright (c) 1990-2008 Info-ZIP - Type '%s "-L"' for software license. +
-/bin/zipnote: Copyright (c) 1990-2008 Info-ZIP.  All rights reserved. +
-/bin/zipsplit: Copyright (c) 1990-2008 Info-ZIP - Type '%s "-L"' for software license. +
-/bin/zipsplit: Copyright (c) 1990-2008 Info-ZIP.  All rights reserved. +
-</code>+
  
-==Command Line Switches==+===Examples===
  
-<WRAP center round todo 60%> +==noclobber==
-**To do** : Use the **--help** option of the **strings** command to view the command line switches. +
-</WRAP> +
- +
-===7.12 - The comm Command=== +
- +
-This command compares two text files and prints the differences to standard output:+
  
 <code> <code>
-[root@redhat9 tmp]# comm /etc/passwd /root/passwd +[trainee@redhat9 ~]$ set -o noclobber 
- root:x:0:0:root:/root:/bin/bash +[trainee@redhat9 ~]$ pwd > file 
- bin:x:1:1:bin:/bin:/sbin/nologin +-bashfilecannot overwrite existing file 
- daemon:x:2:2:daemon:/sbin:/sbin/nologin +[trainee@redhat9 ~]$ pwd >| file 
- adm:x:3:4:adm:/var/adm:/sbin/nologin +[trainee@redhat9 ~]$ cat file 
- lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin +/home/trainee 
- sync:x:5:0:sync:/sbin:/bin/sync +[trainee@redhat9 ~]$ set +o noclobber
- shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown +
- halt:x:7:0:halt:/sbin:/sbin/halt +
- mail:x:8:12:mail:/var/spool/mail:/sbin/nologin +
- operator:x:11:0:operator:/root:/sbin/nologin +
- games:x:12:100:games:/usr/games:/sbin/nologin +
- ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin +
- nobody:x:65534:65534:Kernel Overflow User:/:/sbin/nologin +
- dbus:x:81:81:System message bus:/:/sbin/nologin +
- systemd-coredump:x:999:997:systemd Core Dumper:/:/sbin/nologin +
- systemd-resolve:x:193:193:systemd Resolver:/:/sbin/nologin +
- tss:x:59:59:Account used by the trousers package to sandbox the tcsd daemon:/dev/null:/sbin/nologin +
- polkitd:x:998:996:User for polkitd:/:/sbin/nologin +
- unbound:x:997:994:Unbound DNS resolver:/etc/unbound:/sbin/nologin +
- libstoragemgmt:x:996:993:daemon account for libstoragemgmt:/var/run/lsm:/sbin/nologin +
- cockpit-ws:x:995:991:User for cockpit-ws:/nonexisting:/sbin/nologin +
- sssd:x:994:990:User for sssd:/:/sbin/nologin +
- setroubleshoot:x:993:989::/var/lib/setroubleshoot:/sbin/nologin +
- sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin +
- chrony:x:992:988::/var/lib/chrony:/sbin/nologin +
-tcpdump:x:72:72::/:/sbin/nologin +
- trainee10:x:1000:1000:trainee:/home/trainee:/bin/bash +
-comm: file 2 is not in sorted order +
- cockpit-wsinstance:x:991:987:User for cockpit-ws instances:/nonexisting:/sbin/nologin +
- rngd:x:990:986:Random Number Generator Daemon:/var/lib/rngd:/sbin/nologin +
- gluster:x:989:985:GlusterFS daemons:/run/gluster:/sbin/nologin +
- qemu:x:107:107:qemu user:/:/sbin/nologin +
- rpc:x:32:32:Rpcbind Daemon:/var/lib/rpcbind:/sbin/nologin +
- rpcuser:x:29:29:RPC Service User:/var/lib/nfs:/sbin/nologin +
- saslauth:x:988:76:Saslauthd user:/run/saslauthd:/sbin/nologin +
- radvd:x:75:75:radvd user:/:/sbin/nologin +
- dnsmasq:x:983:983:Dnsmasq DHCP and DNS server:/var/lib/dnsmasq:/sbin/nologin +
- Linux est super! +
-trainee:x:1000:1000:trainee:/home/trainee:/bin/bash +
-comm: file 1 is not in sorted order +
-cockpit-wsinstance:x:991:987:User for cockpit-ws instances:/nonexisting:/sbin/nologin +
-rngd:x:990:986:Random Number Generator Daemon:/var/lib/rngd:/sbin/nologin +
-gluster:x:989:985:GlusterFS daemons:/run/gluster:/sbin/nologin +
-qemu:x:107:107:qemu user:/:/sbin/nologin +
-rpc:x:32:32:Rpcbind Daemon:/var/lib/rpcbind:/sbin/nologin +
-rpcuser:x:29:29:RPC Service User:/var/lib/nfs:/sbin/nologin +
-saslauth:x:988:76:Saslauthd user:/run/saslauthd:/sbin/nologin +
-radvd:x:75:75:radvd user:/:/sbin/nologin +
-dnsmasq:x:983:983:Dnsmasq DHCP and DNS server:/var/lib/dnsmasq:/sbin/nologin+
 </code> </code>
  
 <WRAP center round important 60%> <WRAP center round important 60%>
-**Important**: The lines to the left are those that only appear in the first file. The lines on the right are those that exist in both files. The lines in the middle are those that only exist in the second file.+**Important**: Note that the **noclobber** option can be bypassed by using the redirect followed by the **|** character.
 </WRAP> </WRAP>
  
-If you only want to see the lines common to both files, use the following command:+==noglob==
  
 <code> <code>
-[root@redhat9 tmp]# comm -12 /etc/passwd /root/passwd +[trainee@redhat9 ~]$ set -o noglob 
-root:x:0:0:root:/root:/bin/bash +[trainee@redhat9 ~]$ echo * 
-bin:x:1:1:bin:/bin:/sbin/nologin +* 
-daemon:x:2:2:daemon:/sbin:/sbin/nologin +[trainee@redhat9 ~]$ set +o noglob 
-adm:x:3:4:adm:/var/adm:/sbin/nologin +[trainee@redhat9 ~]$ echo * 
-lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin +aac abc bca codes Desktop Documents Downloads errorlog file file1 file2 list Music Pictures Public Templates training Videos vitext xyz
-sync:x:5:0:sync:/sbin:/bin/sync +
-shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown +
-halt:x:7:0:halt:/sbin:/sbin/halt +
-mail:x:8:12:mail:/var/spool/mail:/sbin/nologin +
-operator:x:11:0:operator:/root:/sbin/nologin +
-games:x:12:100:games:/usr/games:/sbin/nologin +
-ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin +
-nobody:x:65534:65534:Kernel Overflow User:/:/sbin/nologin +
-dbus:x:81:81:System message bus:/:/sbin/nologin +
-systemd-coredump:x:999:997:systemd Core Dumper:/:/sbin/nologin +
-systemd-resolve:x:193:193:systemd Resolver:/:/sbin/nologin +
-tss:x:59:59:Account used by the trousers package to sandbox the tcsd daemon:/dev/null:/sbin/nologin +
-polkitd:x:998:996:User for polkitd:/:/sbin/nologin +
-unbound:x:997:994:Unbound DNS resolver:/etc/unbound:/sbin/nologin +
-libstoragemgmt:x:996:993:daemon account for libstoragemgmt:/var/run/lsm:/sbin/nologin +
-cockpit-ws:x:995:991:User for cockpit-ws:/nonexisting:/sbin/nologin +
-sssd:x:994:990:User for sssd:/:/sbin/nologin +
-setroubleshoot:x:993:989::/var/lib/setroubleshoot:/sbin/nologin +
-sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin +
-chrony:x:992:988::/var/lib/chrony:/sbin/nologin +
-comm: file 2 is not in sorted order +
-comm: file 1 is not in sorted order+
 </code> </code>
-==Command Line Switches== 
  
-<WRAP center round todo 60%> +<WRAP center round important 60%> 
-**To do** : Use the **--help** option of the **comm** command to view the command line switches.+**Important**: Note that the effect of the metacharacter is cancelled under the influence of the **noglob** option.
 </WRAP> </WRAP>
  
-===7.13 - The head Command=== +==nounset==
- +
-The **head** command is used to display the first **x** lines of a file. The default value of x is 10:+
  
 <code> <code>
-[root@redhat9 tmp]# head /etc/passwd +[trainee@redhat9 ~]$ set -o nounset 
-root:x:0:0:root:/root:/bin/bash +[trainee@redhat9 ~]$ echo $FENESTROS 
-bin:x:1:1:bin:/bin:/sbin/nologin +-bash: FENESTROSunbound variable 
-daemon:x:2:2:daemon:/sbin:/sbin/nologin +[trainee@redhat9 ~]$ set +o nounset 
-adm:x:3:4:adm:/var/adm:/sbin/nologin +[trainee@redhat9 ~]$ echo $FENESTROS
-lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin +
-sync:x:5:0:sync:/sbin:/bin/sync +
-shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown +
-halt:x:7:0:halt:/sbin:/sbin/halt +
-mail:x:8:12:mail:/var/spool/mail:/sbin/nologin +
-operator:x:11:0:operator:/root:/sbin/nologin +
-</code>+
  
-You can change the default value of x by using the **-n** switch: +[trainee@redhat9 ~]$
- +
-<code> +
-[root@redhat9 tmp]# head -n 15 /etc/passwd +
-root:x:0:0:root:/root:/bin/bash +
-bin:x:1:1:bin:/bin:/sbin/nologin +
-daemon:x:2:2:daemon:/sbin:/sbin/nologin +
-adm:x:3:4:adm:/var/adm:/sbin/nologin +
-lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin +
-sync:x:5:0:sync:/sbin:/bin/sync +
-shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown +
-halt:x:7:0:halt:/sbin:/sbin/halt +
-mail:x:8:12:mail:/var/spool/mail:/sbin/nologin +
-operator:x:11:0:operator:/root:/sbin/nologin +
-games:x:12:100:games:/usr/games:/sbin/nologin +
-ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin +
-nobody:x:65534:65534:Kernel Overflow User:/:/sbin/nologin +
-dbus:x:81:81:System message bus:/:/sbin/nologin +
-systemd-coredump:x:999:997:systemd Core Dumper:/:/sbin/nologin +
-</code> +
- +
-The command can also be used to display the first **y** bytes of a file by using the **-c** switch: +
- +
-<code> +
-[root@redhat9 tmp]# head -c 150 /etc/passwd +
-root:x:0:0:root:/root:/bin/bash +
-bin:x:1:1:bin:/bin:/sbin/nologin +
-daemon:x:2:2:daemon:/sbin:/sbin/nologin +
-adm:x:3:4:adm:/var/adm:/sbin/nologin +
-lp:x:4:7[root@redhat9 tmp]#  +
-</code> +
- +
-If the value of **y** is negative, head displays all bytes in the file **except** the last y bytes: +
- +
-<code> +
-[root@redhat9 tmp]# head -c -150 /etc/passwd +
-root:x:0:0:root:/root:/bin/bash +
-bin:x:1:1:bin:/bin:/sbin/nologin +
-daemon:x:2:2:daemon:/sbin:/sbin/nologin +
-adm:x:3:4:adm:/var/adm:/sbin/nologin +
-lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin +
-sync:x:5:0:sync:/sbin:/bin/sync +
-shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown +
-halt:x:7:0:halt:/sbin:/sbin/halt +
-mail:x:8:12:mail:/var/spool/mail:/sbin/nologin +
-operator:x:11:0:operator:/root:/sbin/nologin +
-games:x:12:100:games:/usr/games:/sbin/nologin +
-ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin +
-nobody:x:65534:65534:Kernel Overflow User:/:/sbin/nologin +
-dbus:x:81:81:System message bus:/:/sbin/nologin +
-systemd-coredump:x:999:997:systemd Core Dumper:/:/sbin/nologin +
-systemd-resolve:x:193:193:systemd Resolver:/:/sbin/nologin +
-tss:x:59:59:Account used by the trousers package to sandbox the tcsd daemon:/dev/null:/sbin/nologin +
-polkitd:x:998:996:User for polkitd:/:/sbin/nologin +
-unbound:x:997:994:Unbound DNS resolver:/etc/unbound:/sbin/nologin +
-libstoragemgmt:x:996:993:daemon account for libstoragemgmt:/var/run/lsm:/sbin/nologin +
-cockpit-ws:x:995:991:User for cockpit-ws:/nonexisting:/sbin/nologin +
-sssd:x:994:990:User for sssd:/:/sbin/nologin +
-setroubleshoot:x:993:989::/var/lib/setroubleshoot:/sbin/nologin +
-sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin +
-chrony:x:992:988::/var/lib/chrony:/sbin/nologin +
-tcpdump:x:72:72::/:/sbin/nologin +
-trainee:x:1000:1000:trainee:/home/trainee:/bin/bash +
-cockpit-wsinstance:x:991:987:User for cockpit-ws instances:/nonexisting:/sbin/nologin +
-rngd:x:990:986:Random Number Generator Daemon:/var/lib/rngd:/sbin/nologin +
-gluster:x:989:985:GlusterFS daemons:/run/gluster:/sbin/nologin +
-qemu:x:107:107:qemu user:/:/sbin/nologin +
-rpc:x:32:32:Rpcbind Daemon:/var/lib/rpcbind:/sbin/nologin +
-rpcuser:x:29:29:RPC Service User:/var/lib/nfs:/sbin/nologin +
-saslauth:x:988:76:Saslauthd us[root@redhat9 tmp]#  +
-</code> +
- +
-Both x and y can accept multipliers: +
- +
-<code> +
-[root@redhat9 tmp]# head -c 1b /etc/passwd +
-root:x:0:0:root:/root:/bin/bash +
-bin:x:1:1:bin:/bin:/sbin/nologin +
-daemon:x:2:2:daemon:/sbin:/sbin/nologin +
-adm:x:3:4:adm:/var/adm:/sbin/nologin +
-lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin +
-sync:x:5:0:sync:/sbin:/bin/sync +
-shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown +
-halt:x:7:0:halt:/sbin:/sbin/halt +
-mail:x:8:12:mail:/var/spool/mail:/sbin/nologin +
-operator:x:11:0:operator:/root:/sbin/nologin +
-games:x:12:100:games:/usr/games:/sbin/nologin +
-ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin +
-nobody:x:65534:65534:Kernel Overflow [root@redhat9 tmp]#  +
- +
-[root@redhat9 tmp]# head -c 512 /etc/passwd +
-root:x:0:0:root:/root:/bin/bash +
-bin:x:1:1:bin:/bin:/sbin/nologin +
-daemon:x:2:2:daemon:/sbin:/sbin/nologin +
-adm:x:3:4:adm:/var/adm:/sbin/nologin +
-lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin +
-sync:x:5:0:sync:/sbin:/bin/sync +
-shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown +
-halt:x:7:0:halt:/sbin:/sbin/halt +
-mail:x:8:12:mail:/var/spool/mail:/sbin/nologin +
-operator:x:11:0:operator:/root:/sbin/nologin +
-games:x:12:100:games:/usr/games:/sbin/nologin +
-ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin +
-nobody:x:65534:65534:Kernel Overflow [root@redhat9 tmp]#  +
-</code> +
- +
-The common multipliers are: +
- +
-^ Multiplier ^ Number of bytes ^ +
-| b | 512 | +
-| KB | 1000 | +
-| K | 1024 | +
-| MB | 1000*1000 | +
-| M | 1024*1024 | +
-| GB | 1000*1000*1000 | +
-| G | 1024*1024*1024 | +
- +
-==Command Line Switches== +
- +
-<WRAP center round todo 60%> +
-**To do** : Use the **--help** option of the **head** command to view the command line switches. +
-</WRAP> +
- +
-===7.14 - The tail Command=== +
- +
-The **tail** command is used to display the last **x** lines of a file. The default value of x is 10: +
- +
-<code> +
-[root@redhat9 tmp]# tail /etc/passwd +
-trainee:x:1000:1000:trainee:/home/trainee:/bin/bash +
-cockpit-wsinstance:x:991:987:User for cockpit-ws instances:/nonexisting:/sbin/nologin +
-rngd:x:990:986:Random Number Generator Daemon:/var/lib/rngd:/sbin/nologin +
-gluster:x:989:985:GlusterFS daemons:/run/gluster:/sbin/nologin +
-qemu:x:107:107:qemu user:/:/sbin/nologin +
-rpc:x:32:32:Rpcbind Daemon:/var/lib/rpcbind:/sbin/nologin +
-rpcuser:x:29:29:RPC Service User:/var/lib/nfs:/sbin/nologin +
-saslauth:x:988:76:Saslauthd user:/run/saslauthd:/sbin/nologin +
-radvd:x:75:75:radvd user:/:/sbin/nologin +
-dnsmasq:x:983:983:Dnsmasq DHCP and DNS server:/var/lib/dnsmasq:/sbin/nologin +
-</code> +
- +
-You can change the default value of x by using the **-n** switch: +
- +
-<code> +
-root@redhat9 tmp]# tail -n 15 /etc/passwd +
-sssd:x:994:990:User for sssd:/:/sbin/nologin +
-setroubleshoot:x:993:989::/var/lib/setroubleshoot:/sbin/nologin +
-sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin +
-chrony:x:992:988::/var/lib/chrony:/sbin/nologin +
-tcpdump:x:72:72::/:/sbin/nologin +
-trainee:x:1000:1000:trainee:/home/trainee:/bin/bash +
-cockpit-wsinstance:x:991:987:User for cockpit-ws instances:/nonexisting:/sbin/nologin +
-rngd:x:990:986:Random Number Generator Daemon:/var/lib/rngd:/sbin/nologin +
-gluster:x:989:985:GlusterFS daemons:/run/gluster:/sbin/nologin +
-qemu:x:107:107:qemu user:/:/sbin/nologin +
-rpc:x:32:32:Rpcbind Daemon:/var/lib/rpcbind:/sbin/nologin +
-rpcuser:x:29:29:RPC Service User:/var/lib/nfs:/sbin/nologin +
-saslauth:x:988:76:Saslauthd user:/run/saslauthd:/sbin/nologin +
-radvd:x:75:75:radvd user:/:/sbin/nologin +
-dnsmasq:x:983:983:Dnsmasq DHCP and DNS server:/var/lib/dnsmasq:/sbin/nologin +
-</code> +
- +
-The command can also be used to display the last **y** bytes of a file by using the **-c** switch: +
- +
-<code> +
-[root@redhat9 tmp]# tail -c 150 /etc/passwd +
-er:/run/saslauthd:/sbin/nologin +
-radvd:x:75:75:radvd user:/:/sbin/nologin +
-dnsmasq:x:983:983:Dnsmasq DHCP and DNS server:/var/lib/dnsmasq:/sbin/nologin +
-</code> +
- +
-If the value of **y** is positive, tail displays all bytes in the file after the yth byte: +
- +
-<code> +
-[root@redhat9 tmp]# tail -c +150 /etc/passwd +
-7:lp:/var/spool/lpd:/sbin/nologin +
-sync:x:5:0:sync:/sbin:/bin/sync +
-shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown +
-halt:x:7:0:halt:/sbin:/sbin/halt +
-mail:x:8:12:mail:/var/spool/mail:/sbin/nologin +
-operator:x:11:0:operator:/root:/sbin/nologin +
-games:x:12:100:games:/usr/games:/sbin/nologin +
-ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin +
-nobody:x:65534:65534:Kernel Overflow User:/:/sbin/nologin +
-dbus:x:81:81:System message bus:/:/sbin/nologin +
-systemd-coredump:x:999:997:systemd Core Dumper:/:/sbin/nologin +
-systemd-resolve:x:193:193:systemd Resolver:/:/sbin/nologin +
-tss:x:59:59:Account used by the trousers package to sandbox the tcsd daemon:/dev/null:/sbin/nologin +
-polkitd:x:998:996:User for polkitd:/:/sbin/nologin +
-unbound:x:997:994:Unbound DNS resolver:/etc/unbound:/sbin/nologin +
-libstoragemgmt:x:996:993:daemon account for libstoragemgmt:/var/run/lsm:/sbin/nologin +
-cockpit-ws:x:995:991:User for cockpit-ws:/nonexisting:/sbin/nologin +
-sssd:x:994:990:User for sssd:/:/sbin/nologin +
-setroubleshoot:x:993:989::/var/lib/setroubleshoot:/sbin/nologin +
-sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin +
-chrony:x:992:988::/var/lib/chrony:/sbin/nologin +
-tcpdump:x:72:72::/:/sbin/nologin +
-trainee:x:1000:1000:trainee:/home/trainee:/bin/bash +
-cockpit-wsinstance:x:991:987:User for cockpit-ws instances:/nonexisting:/sbin/nologin +
-rngd:x:990:986:Random Number Generator Daemon:/var/lib/rngd:/sbin/nologin +
-gluster:x:989:985:GlusterFS daemons:/run/gluster:/sbin/nologin +
-qemu:x:107:107:qemu user:/:/sbin/nologin +
-rpc:x:32:32:Rpcbind Daemon:/var/lib/rpcbind:/sbin/nologin +
-rpcuser:x:29:29:RPC Service User:/var/lib/nfs:/sbin/nologin +
-saslauth:x:988:76:Saslauthd user:/run/saslauthd:/sbin/nologin +
-radvd:x:75:75:radvd user:/:/sbin/nologin +
-dnsmasq:x:983:983:Dnsmasq DHCP and DNS server:/var/lib/dnsmasq:/sbin/nologin +
-</code> +
- +
-Both x and y can accept multipliers: +
- +
-<code> +
-[root@redhat9 tmp]# tail -c 1b /etc/passwd +
-nstances:/nonexisting:/sbin/nologin +
-rngd:x:990:986:Random Number Generator Daemon:/var/lib/rngd:/sbin/nologin +
-gluster:x:989:985:GlusterFS daemons:/run/gluster:/sbin/nologin +
-qemu:x:107:107:qemu user:/:/sbin/nologin +
-rpc:x:32:32:Rpcbind Daemon:/var/lib/rpcbind:/sbin/nologin +
-rpcuser:x:29:29:RPC Service User:/var/lib/nfs:/sbin/nologin +
-saslauth:x:988:76:Saslauthd user:/run/saslauthd:/sbin/nologin +
-radvd:x:75:75:radvd user:/:/sbin/nologin +
-dnsmasq:x:983:983:Dnsmasq DHCP and DNS server:/var/lib/dnsmasq:/sbin/nologin +
- +
-[root@redhat9 tmp]# tail -c 512 /etc/passwd +
-nstances:/nonexisting:/sbin/nologin +
-rngd:x:990:986:Random Number Generator Daemon:/var/lib/rngd:/sbin/nologin +
-gluster:x:989:985:GlusterFS daemons:/run/gluster:/sbin/nologin +
-qemu:x:107:107:qemu user:/:/sbin/nologin +
-rpc:x:32:32:Rpcbind Daemon:/var/lib/rpcbind:/sbin/nologin +
-rpcuser:x:29:29:RPC Service User:/var/lib/nfs:/sbin/nologin +
-saslauth:x:988:76:Saslauthd user:/run/saslauthd:/sbin/nologin +
-radvd:x:75:75:radvd user:/:/sbin/nologin +
-dnsmasq:x:983:983:Dnsmasq DHCP and DNS server:/var/lib/dnsmasq:/sbin/nologin +
-</code> +
- +
-The common multipliers are: +
- +
-^ Multiplier ^ Number of bytes ^ +
-| b | 512 | +
-| KB | 1000 | +
-| K | 1024 | +
-| MB | 1000*1000 | +
-| M | 1024*1024 | +
-| GB | 1000*1000*1000 | +
-| G | 1024*1024*1024 | +
- +
-A useful switch to use with the tail command is **-f**. This switch continually updates the output: +
- +
-<code> +
-[root@redhat9 tmp]# tail -f /var/log/messages +
-Sep 25 15:59:09 redhat9 systemd[1]: packagekit.service: Consumed 27.056s CPU time. +
-Sep 25 16:21:00 redhat9 systemd[1]: Started /usr/bin/systemctl start man-db-cache-update. +
-Sep 25 16:21:00 redhat9 systemd[1]: Starting man-db-cache-update.service... +
-Sep 25 16:21:01 redhat9 systemd[1]: Starting PackageKit Daemon... +
-Sep 25 16:21:01 redhat9 systemd[1]: Started PackageKit Daemon. +
-Sep 25 16:21:01 redhat9 dbus-broker[743]: A security policy denied :1.25 to send method call /org/freedesktop/PackageKit:org.freedesktop.DBus.Properties.GetAll to :1.99. +
-Sep 25 16:21:04 redhat9 systemd[1]: man-db-cache-update.service: Deactivated successfully. +
-Sep 25 16:21:04 redhat9 systemd[1]: Finished man-db-cache-update.service. +
-Sep 25 16:21:04 redhat9 systemd[1]: run-r92bee130695b430689098f98ad81e47d.service: Deactivated successfully. +
-Sep 25 16:26:07 redhat9 systemd[1]: packagekit.service: Deactivated successfully. +
-^C +
-</code> +
- +
-==Command Line Switches== +
- +
-<WRAP center round todo 60%> +
-**To do** : Use the **--help** option of the **head** command to view the command line switches. +
-</WRAP> +
- +
-====LAB #8 - Use the grep, tr and cut to extract your IPv4 address from the output of ifconfig==== +
- +
-<code> +
-[root@redhat9 tmp]# ifconfig ens18 +
-ens18: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500 +
-        inet 10.0.2.101  netmask 255.255.255.0  broadcast 10.0.2.255 +
-        inet6 fe80::9086:d7ff:fe66:e75a  prefixlen 64  scopeid 0x20<link> +
-        ether 92:86:d7:66:e7:5a  txqueuelen 1000  (Ethernet) +
-        RX packets 63639  bytes 160337691 (152.9 MiB) +
-        RX errors 0  dropped 0  overruns 0  frame 0 +
-        TX packets 52302  bytes 7554310 (7.2 MiB) +
-        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0 +
- +
-[root@redhat9 tmp]# ifconfig ens18 | grep "inet" +
-        inet 10.0.2.101  netmask 255.255.255.0  broadcast 10.0.2.255 +
-        inet6 fe80::9086:d7ff:fe66:e75a  prefixlen 64  scopeid 0x20<link> +
- +
-[root@redhat9 tmp]# ifconfig ens18 | grep "inet" | grep -v "inet6" +
-        inet 10.0.2.101  netmask 255.255.255.0  broadcast 10.0.2.255 +
- +
-[root@redhat9 tmp]# ifconfig ens18 | grep "inet" | grep -v "inet6" | tr -s " " ":" +
-:inet:10.0.2.101:netmask:255.255.255.0:broadcast:10.0.2.255 +
- +
-[root@redhat9 tmp]# ifconfig ens18 | grep "inet" | grep -v "inet6" | tr -s " " ":" | cut -d: -f3 +
-10.0.2.101+
 </code> </code>
  
 <WRAP center round important 60%> <WRAP center round important 60%>
-**Important** : Note the use of the **-s** switch with the **tr** commandThis switch replaces a string of x identical characters with a single character+**Important**: Note that the non-existent variable **$FENESTROS** is identified as such under the influence of the **nounset** optionNow the usual behavior of Linux is to return an empty line which does not indicate whether the variable does not exist or whether it is simply empty.
 </WRAP> </WRAP>
- 
-====LAB #9 - Use the grep, awk and sed to extract your IPv4 address from the output of ip==== 
- 
-<code> 
-[root@redhat9 tmp]# ip addr show ens18 
-2: ens18: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000 
-    link/ether 92:86:d7:66:e7:5a brd ff:ff:ff:ff:ff:ff 
-    altname enp0s18 
-    inet 10.0.2.101/24 brd 10.0.2.255 scope global noprefixroute ens18 
-       valid_lft forever preferred_lft forever 
-    inet6 fe80::9086:d7ff:fe66:e75a/64 scope link noprefixroute  
-       valid_lft forever preferred_lft forever 
- 
-[root@redhat9 tmp]# ip addr show ens18 | grep "inet" 
-    inet 10.0.2.101/24 brd 10.0.2.255 scope global noprefixroute ens18 
-    inet6 fe80::9086:d7ff:fe66:e75a/64 scope link noprefixroute  
- 
-[root@redhat9 tmp]# ip addr show ens18 | grep "inet" | grep -v "inet6" 
-    inet 10.0.2.101/24 brd 10.0.2.255 scope global noprefixroute ens18 
- 
-[root@redhat9 tmp]# ip addr show ens18 | grep "inet" | grep -v "inet6" | awk '{ print $2; }' 
-10.0.2.101/24 
- 
-[root@redhat9 tmp]# ip addr show ens18 | grep "inet" | grep -v "inet6" | awk '{ print $2; }' | sed 's/\/.*$//' 
-10.0.2.101 
-</code> 
  
 ----- -----
 Copyright © 2024 Hugh Norris. Copyright © 2024 Hugh Norris.
Menu