0% found this document useful (0 votes)
20 views

LPIC Course

Uploaded by

MAHDI
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views

LPIC Course

Uploaded by

MAHDI
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 373

Linux Foundation Certified System

Administrator Exam Details


Pre-Requisites

none.
8 of 60 12 of 60

System Architecture Linux Installation and


Package Management

Exam Objectives
26 of 60 14 of 60

GNU and Unix Commands Devices, Linux


Filesystems,
Filesystem Hierarchy
Standard
LPIC-1 101 Exam Details

90 minutes 200.00 USD


Valid for 5
years

60 Multiple-choice Online
and fill in the proctored and
blank in-person
Determine and Configure
Hardware Settings
BIOS/UEFI

BIOS Basic Input/Output System

UEFI Unified Extensible Firmware Interface

POST Power-On Self-Test


BIOS/UEFI

Set the date and time for the hardware clock

Disable or enable integrated peripherals

Configure error protection

Change hardware settings like IRQs and DMA

Choose the order of boot devices


Inspecting Devices in Linux

>_
$ sudo lspci
00:00.0 Host bridge: Intel Corporation 440FX - 82441FX PMC [Natoma] (rev 02)

00:01.0 ISA bridge: Intel Corporation 82371SB PIIX3 ISA [Natoma/Triton II]

00:01.1 IDE interface: Intel Corporation 82371AB/EB/MB PIIX4 IDE (rev 01)

00:02.0 VGA compatible controller: VMware SVGA II Adapter

00:03.0 Ethernet controller: Intel Corporation 82540EM Gigabit Ethernet Controller (rev 02)

00:04.0 System peripheral: InnoTek Systemberatung GmbH VirtualBox Guest Service

00:07.0 Bridge: Intel Corporation 82371AB/EB/MB PIIX4 ACPI (rev 08)

00:0c.0 USB controller: Intel Corporation 7 Series/C210 Series Chipset Family USB xHCI Host Controller

00:0d.0 SATA controller: Intel Corporation 82801HM/HEM (ICH8M/ICH8M-E) SATA Controller [AHCI mode] (rev 02)
Inspecting Devices in Linux

>_
$ sudo lspci -s 00:03.0 -v
00:03.0 Ethernet controller: Intel Corporation 82540EM Gigabit Ethernet Controller (rev 02)

Subsystem: Intel Corporation PRO/1000 MT Desktop Adapter

Flags: bus master, 66MHz, medium devsel, latency 64, IRQ 19

Memory at f0200000 (32-bit, non-prefetchable) [size=128K]

I/O ports at d020 [size=8]

Capabilities: [dc] Power Management version 2

Capabilities: [e4] PCI-X non-bridge device

Kernel driver in use: e1000

Kernel modules: e1000


Inspecting Devices in Linux

>_
$ sudo lspci -s 00:03.0 -k
00:03.0 Ethernet controller: Intel Corporation 82540EM Gigabit Ethernet Controller (rev 02)

Subsystem: Intel Corporation PRO/1000 MT Desktop Adapter

Kernel driver in use: e1000

Kernel modules: e1000


Inspecting Devices in Linux

>_
$ sudo lsusb
Bus 001 Device 029: ID 1781:0c9f Multiple Vendors USBtiny
Bus 001 Device 028: ID 093a:2521 Pixart Imaging, Inc. Optical Mouse
Bus 001 Device 020: ID 1131:1001 Integrated System Solution Corp. KY-BT100
Bluetooth Adapter
Bus 001 Device 011: ID 04f2:0402 Chicony Electronics Co., Ltd Genius LuxeMate i200
Keyboard
Bus 001 Device 007: ID 0424:7800 Standard Microsystems Corp.
Bus 001 Device 003: ID 0424:2514 Standard Microsystems Corp. USB 2.0 Hub
Bus 001 Device 002: ID 0424:2514 Standard Microsystems Corp. USB 2.0 Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Inspecting Devices in Linux

>_
$ sudo lsusb -v -d 1781:0c9f
Bus 001 Device 029: ID 1781:0c9f Multiple Vendors USBtiny
Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 1.01
bDeviceClass 255 Vendor Specific Class
bDeviceSubClass 0
bDeviceProtocol 0
bMaxPacketSize0 8
idVendor 0x1781 Multiple Vendors
idProduct 0x0c9f USBtiny
bcdDevice 1.04
iManufacturer 0
iProduct 2 USBtiny
iSerial 0
bNumConfigurations 1
Inspecting Devices in Linux

>_
$ sudo lsusb -t
/: Bus 01.Port 1: Dev 1, Class=root_hub, Driver=dwc_otg/1p, 480M
|__ Port 1: Dev 2, If 0, Class=Hub, Driver=hub/4p, 480M
|__ Port 1: Dev 3, If 0, Class=Hub, Driver=hub/3p, 480M
|__ Port 2: Dev 11, If 1, Class=Human Interface Device, Driver=usbhid, 1.5M
|__ Port 2: Dev 11, If 0, Class=Human Interface Device, Driver=usbhid, 1.5M
|__ Port 3: Dev 20, If 0, Class=Wireless, Driver=btusb, 12M
|__ Port 3: Dev 20, If 1, Class=Wireless, Driver=btusb, 12M
|__ Port 3: Dev 20, If 2, Class=Application Specific Interface,Driver=, 12M
|__ Port 1: Dev 7, If 0, Class=Vendor Specific Class, Driver=lan78xx, 480M
|__ Port 2: Dev 28, If 0, Class=Human Interface Device, Driver=usbhid, 1.5M
|__ Port 3: Dev 29, If 0, Class=Vendor Specific Class, Driver=, 1.5M
Inspecting Devices in Linux

>_
$ sudo lsusb -s 01:20
Bus 001 Device 020: ID 1131:1001 Integrated System Solution Corp. KY-BT100
Bluetooth Adapter
Kernel Modules

>_
$ sudo lsmod
Module Size Used by

tls 110592 0

uinput 20480 0

nls_utf8 16384 1

isofs 49152 1

snd_seq_dummy 16384 0

snd_hrtimer 16384 1

snd_seq 86016 7 snd_seq_dummy

snd_timer 49152 2 snd_seq,snd_hrtimer

snd_seq_device 16384 1 snd_seq

snd 114688 5 snd_seq,snd_seq_device,snd_timer


Kernel Modules

>_
$ sudo lsmod | fgrep -i snd
snd_seq_dummy 16384 0

snd_hrtimer 16384 1

snd_seq 86016 7 snd_seq_dummy

snd_timer 49152 2 snd_seq,snd_hrtimer

snd_seq_device 16384 1 snd_seq

snd 114688 5 snd_seq,snd_seq_device,snd_timer

soundcore 16384 1 snd


Kernel Modules

>_
$ sudo modprobe -r snd-hda-intel
Kernel Modules

>_
$ sudo modinfo snd
filename: /lib/modules/5.14.0-70.26.1.el9_0.x86_64/kernel/sound/core/snd.ko.xz

alias: char-major-116-*

license: GPL

description: Advanced Linux Sound Architecture driver for soundcards.

author: Jaroslav Kysela <[email protected]>


Kernel Modules

>_
/etc/modprobe.conf
$ sudo modinfo -p snd
max_user_ctl_alloc_size:Max allocation size for user controls (int)
/etc/modprobe.d/snd.conf
slots:Module names assigned to the slots. (array of charp)
/etc/modprobe.d/blacklist.conf
major:Major # for sound driver. (int)

cards_limit:Count of auto-loadable soundcards. (int) blacklilst snd


Information and Device Files

/proc
/sys
Special directories that exist in RAM
Used by the kernel to store information on running processes
Boot the System
Boot the System

BIOS
or
UEFI

Bootloader

Kernel

Init
BIOS

440 bytes 512 bytes


1st device MBR
Bootstrap DOS partition
Partition table
BIOS

POST Identifies simple hardware failures


• Activates basic components like video output, the
keyboard, and storage
• Loads the bootstrap from the MBR
• Loads the second stage of the bootloader and pass options
to the kernel
UEFI

NVRAM
EFI applications
FAT filesystems or ISO-9660
EFI System Partition (ESP)
EFI directory
UEFI

POST Identifies simple hardware failures


• Activates basic components like video output, the keyboard,
and storage
• Executes EFI applications stored in the ESP partition, such as
the bootloader
• The bootloader loads the kernel
• Also supports Secure Boot
Bootloader

GRUB Grand Unified Bootloader

BIOS SHIFT

UEFI ESC
Bootloader

acpi Enable or disable ACPI support acpi=off disables


init Set system init Example: init=/bin/bash
systemd.unit Set systemd target Example: system.unit=graphical.target
mem Set available system RAM Example: mem=512M
maxcpus Limits processors or cores Example: maxcpus=0 or maxcpus=2
quiet Hides boot messages
vga Selects a video mode Example: vga=ask
root Sets the root partition Example: root=/dev/sda3
rootflags Mount options for the root filesystem
ro Mount root filesystem read-only
rw Mount root filesystem read/write
Init

Kernel loaded into RAM

initramfs initial RAM filesystem

Kernel mounts all filesystems configured in /etc/fstab

Kernel loads init. First program that starts all others.

initramfs is removed from RAM.


Init

SysV standard Controls daemons using runlevels. Runlevels numbered 0 to 6.

systemd Modern service manager with concurrent structure. Common default.

Upstart Parallel startup. Formerly used by Ubuntu, replaced by systemd.


Init

>_
$ dmesg
[ 5.262389] EXT4-fs (sda1): mounted filesystem with ordered data mode.
Opts:
(null)
[ 5.449712] ip_tables: (C) 2000-2006 Netfilter Core Team
[ 5.460286] systemd[1]: systemd 237 running in system mode.
[ 5.480138] systemd[1]: Detected architecture x86-64.
[ 5.481767] systemd[1]: Set hostname to <torre>.
[ 5.636607] systemd[1]: Reached target User and Group Name Lookups.
[ 5.636866] systemd[1]: Created slice System Slice.
[ 5.637000] systemd[1]: Listening on Journal Audit Socket.
[ 5.637085] systemd[1]: Listening on Journal Socket.
[ 5.637827] systemd[1]: Mounting POSIX Message Queue File System...
[ 5.638639] systemd[1]: Started Read required files in advance.
[ 5.641661] systemd[1]: Starting Load Kernel Modules...
[ 5.661672] EXT4-fs (sda1): re-mounted. Opts: errors=remount-ro
[ 5.694322] lp: driver loaded but no devices found
[ 5.702609] ppdev: user-space parallel port driver
[ 5.705384] parport_pc 00:02: reported by Plug and Play ACPI
[ 5.705468] parport0: PC-style at 0x378 (0x778), irq 7, dma 3
[PCSPP,TRISTATE,COMPAT,EPP,ECP,DMA]
[ 5.800146] lp0: using parport0 (interrupt-driven).
[ 5.897421] systemd-journald[352]: Received request to flush runtime
journal
from PID 1
Init

>_
$ journalctl --list-boots
-4 9e5b3eb4952845208b841ad4dbefa1a6 Thu 2019-10-03 13:39:23 -03—Thu 2019-
10-03
13:40:30 -03
-3 9e3d79955535430aa43baa17758f40fa Thu 2019-10-03 13:41:15 -03—Thu 2019-
10-03
14:56:19 -03
-2 17672d8851694e6c9bb102df7355452c Thu 2019-10-03 14:56:57 -03—Thu 2019-
10-03
19:27:16 -03
-1 55c0d9439bfb4e85a20a62776d0dbb4d Thu 2019-10-03 19:27:53 -03—Fri 2019-
10-04
00:28:47 -03
0 08fbbebd9f964a74b8a02bb27b200622 Fri 2019-10-04 00:31:01 -03—Fri 2019-
10-04
10:17:01 -03
Init

>_
$ journalctl -b 0
oct 04 00:31:01 ubuntu-host kernel: EXT4-fs (sda1): mounted filesystem
with ordered
data mode. Opts: (null)
oct 04 00:31:01 ubuntu-host kernel: ip_tables: (C) 2000-2006 Netfilter
Core Team
oct 04 00:31:01 ubuntu-host systemd[1]: systemd 237 running in system
mode.
oct 04 00:31:01 ubuntu-host systemd[1]: Detected architecture x86-64.
oct 04 00:31:01 ubuntu-host systemd[1]: Set hostname to <torre>.
oct 04 00:31:01 ubuntu-host systemd[1]: Reached target User and Group Name
Lookups.
oct 04 00:31:01 ubuntu-host systemd[1]: Created slice System Slice.
oct 04 00:31:01 ubuntu-host systemd[1]: Listening on Journal Audit Socket.
oct 04 00:31:01 ubuntu-host systemd[1]: Listening on Journal Socket.
oct 04 00:31:01 ubuntu-host systemd[1]: Mounting POSIX Message Queue File
System...
oct 04 00:31:01 ubuntu-host systemd[1]: Started Read required files in
advance.
oct 04 00:31:01 ubuntu-host systemd[1]: Starting Load Kernel Modules...
oct 04 00:31:01 ubuntu-host kernel: EXT4-fs (sda1): re-mounted. Opts:
commit=300,barrier=0,errors=remount-ro
oct 04 00:31:01 ubuntu-host kernel: lp: driver loaded but no devices found
oct 04 00:31:01 ubuntu-host kernel: ppdev: user-space parallel port driver
oct 04 00:31:01 ubuntu-host kernel: parport_pc 00:02: reported by Plug and
Play
Init

>_
/var/log/ Initialization and system logs.

$ journalctl -D /var/log/other_directory
Change Runlevels
and Boot Targets
SysVinit

PID 1 The service manager process.


Runlevel A group of services for a purpose. Numbered 0 to 6.
Runlevel 0 System shutdown.
Runlevel 1 Single-user mode, without networking. Maintenance mode.
Runlevel 2,3,4 Mulit-user mode. Networking available. 2 and 4 often unused.
Runlevel 5 Multi-user mode with graphical login.
Runlevel 6 System restart.
/sbin/init Manages runlevels and services.
SysVinit

/etc/inittab Defines each runlevel.

/etc/init.d/ Contains scrips for each runlevel.

id:runlevels:action:process

boot Executed during system initialization. Ignores runlevels field.


Executed during system initialization and init waits until finished.
bootwait
Ignores runlevels field.
sysinit Executed after system initialization. Ignores runlevels field.

wait Executed for the given runlevels. Init waits until finished.

respawn Process will be restarted if terminated.

ctrlaltdel Executed when init receives SIGINT, triggered by CTRL+ALT+DEL.

id:x:initdefault Defines default runlevel.


SysVinit

>_ /etc/inittab
$ sudo vi /etc/inittab # Default runlevel
id:3:initdefault:
# Configuration script executed during boot
$ sudo telnit q si::sysinit:/etc/init.d/rcS
# Action taken on runlevel S (single user)
~:S:wait:/sbin/sulogin
# Configuration for each execution level
l0:0:wait:/etc/init.d/rc 0
l1:1:wait:/etc/init.d/rc 1
l2:2:wait:/etc/init.d/rc 2
l3:3:wait:/etc/init.d/rc 3
l4:4:wait:/etc/init.d/rc 4
l5:5:wait:/etc/init.d/rc 5
l6:6:wait:/etc/init.d/rc 6
# Action taken upon ctrl+alt+del keystroke
ca::ctrlaltdel:/sbin/shutdown -r now
# Enable consoles for runlevels 2 and 3
1:23:respawn:/sbin/getty tty1 VC linux
2:23:respawn:/sbin/getty tty2 VC linux
3:23:respawn:/sbin/getty tty3 VC linux
4:23:respawn:/sbin/getty tty4 VC linux
# For runlevel 3, also enable serial
# terminals ttyS0 and ttyS1 (modem) consoles
S0:3:respawn:/sbin/getty -L 9600 ttyS0 vt320
S1:3:respawn:/sbin/mgetty -x0 -D ttyS1
SysVinit

Files that start with K kill services when they run


>_
Files that start with S start services when they run
$ ls /etc/init.d/
rc0.d/
rc1.d/
rc2.d/
rc3.d/
rc4.d/
rc5.d/
rc6.d/

$ runlevel
N 3

$ sudo telinit 1
systemd

httpd.service (Red Hat) or apache2.service (Debian)


service Active system resources. Can be initiated, interrupted, and reloaded.
socket Filesystem or network socket.
device A hardware device identified by the kernel.
mount A mount point defined in /etc/fstab.
automount A mount point mounted automatically.
target A group of units managed as a single unit.
snapshot A saved stated of the systemd manager.
systemd

>_
$ sudo systemctl start unit.service

$ sudo systemctl stop unit.service

$ sudo systemctl restart unit.service

$ sudo systemctl status unit.service

$ sudo systemctl is-active unit.service

$ sudo systemctl enable unit.service

$ sudo systemctl disable unit.service

$ sudo systemctl is-enabled unit.service


systemd

>_
$ sudo systemctl isolate multi-user.target

$ sudo systemctl set-default multi-user.target

$ sudo systemctl get-default


graphical.target
systemd

>_ /lib/systemd/system/ contains unit files for


every unit
$ sudo systemctl list-unit-files
/etc/systemd/logind.conf defines actions
associated with power events

$ sudo systemctl list-unit-files --type=service Can also be found in separate files in


/etc/systemd/logind.conf/d/ if no other power
manager like acpid is running on the system

$ sudo systemctl list-unit-files --type=target

$ sudo systemctl suspend

$ sudo systemctl hibernate


Upstart

>_ /etc/init/ contains initialization scripts for


Upstart
$ sudo initctl list
avahi-cups-reload stop/waiting
avahi-daemon start/running, process 1123
mountall-net stop/waiting
mountnfs-bootclean.sh start/running
nmbd start/running, process 3085
passwd stop/waiting
rc stop/waiting
rsyslog start/running, process 1095
tty4 start/running, process 1761
udev start/running, process 1073
upstart-udev-bridge start/running, process 1066
console-setup stop/waiting
irqbalance start/running, process 1842
plymouth-log stop/waiting
smbd start/running, process 1457
tty5 start/running, process 1764
failsafe stop/waiting
Upstart

>_
$ sudo start tty6

$ sudo status tty6


tty6 start/running, process 3282

$ sudo stop tty6


Shutdown and Restart

>_
$ sudo shutdown [option] time [message]

$ sudo shutdown 02:00

$ sudo shutdown +20

$ sudo shutdown now

$ sudo syestemctl reboot

$ sudo syestemctl poweroff

$ sudo wall 'System going into maintenance mode in 5 minutes!'


Configure and Manage Swap Space
Create and Manage Swap Space

4GB

video editor 2GB chrome

audio editor 2GB

RAM swap partition


Create and Manage Swap Space

>_
$ swapon --show
NAME TYPE SIZE USED PRIO
/dev/dm-1 partition 2G 0B -2

$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
vda 8:0 0 20G 0 disk
├─vda1 8:1 0 1G 0 part /boot
└─vda2 8:2 0 19G 0 part
├─cs-root 253:0 0 17G 0 lvm /
└─cs-swap 253:1 0 2G 0 lvm [SWAP]
vdb 8:16 0 10G 0 disk
├─vdb1 8:17 0 4G 0 part
├─vdb2 8:18 0 4G 0 part
└─vdb3 8:19 0 2G 0 part
Create and Manage Swap Space

>_
$ sudo mkswap /dev/vdb3
Setting up swapspace version 1, size = 2 GiB (2146430976 bytes)
no label, UUID=6d6f451e-5fa4-4cd5-b627-b0f39c810002

$ sudo swapon --verbose /dev/vdb3


swapon: /dev/vdb3: found signature [pagesize=4096, signature=swap]
swapon: /dev/vdb3: pagesize=4096, swapsize=2146435072, devsize=2146435072
swapon /dev/vdb3

$ swapon --show
NAME TYPE SIZE USED PRIO
/dev/dm-1 partition 2G 0B -2
/dev/vdb3 partition 2G 0B -3
Create and Manage Swap Space

>_
$ sudo swapoff /dev/vdb3

$ sudo dd if=/dev/zero of=/swap bs=1M count=128

$ sudo dd if=/dev/zero of=/swap bs=1M count=2048 status=progress


1436549120 bytes (1.4 GB, 1.3 GiB) copied, 2 s, 717 MB/s
2048+0 records in
2048+0 records out
2147483648 bytes (2.1 GB, 2.0 GiB) copied, 2.71801 s, 790 MB/s

$ sudo chmod 600 /swap


Create and Manage Swap Space

>_
$ sudo mkswap /swap
Setting up swapspace version 1, size = 2 GiB (2147479552 bytes)
no label, UUID=cff8e9dc-54fa-4661-a48e-497610b2f07b

$ sudo swapon --verbose /swap


swapon: /swap: found signature [pagesize=4096, signature=swap]
swapon: /swap: pagesize=4096, swapsize=2147483648, devsize=2147483648
swapon /swap

$ swapon --show
NAME TYPE SIZE USED PRIO
/dev/dm-1 partition 2G 268K -2
/swap file 2G 0B -3
GRUB Legacy
Install GRUB Legacy

>_
$ sudo grub-install /dev/sda

$ sudo grub-install /dev/sda --boot-directory=/other/directory


Install GRUB Legacy

>_
c
grub> root (hd0,0)

grub> find /boot/grub/stage1


(hd0,0)

grub> setup (hd0)


Configure GRUB Legacy

>_ /boot/grub/menu.lst

$ sudo vi /boot/grub/menu.lst # This line is a comment


title My Linux Distribution
root (hd0,0)
kernel /vmlinuz root=/dev/hda1

# This line is a comment


title My Linux Distribution
kernel (hd0,0)/vmlinuz root=/dev/hda1

# This line is a comment


title My Linux Distribution
root (hd0,0)
kernel /vmlinuz root=/dev/hda1
initrd /initrd.img
module /boot/grub/i386-pc/915resolution.mod
Chainloading

>_ /boot/grub/menu.lst

$ sudo vi /boot/grub/menu.lst # This line is a comment


title My Linux Distribution
root (hd0,0)
kernel /vmlinuz root=/dev/hda1

# Load Windows
title Windows XP
root (hd0,1)
makeactive
chainload +1
boot
Manage Shared Libraries
Libraries

Software libraries collections of code to be used by many different programs

Compiler : turns the source code into machine code stored in object files

Linker : combines object files and links them to libraries to generate


an executable file

Linking : either static or dynamic


Library Types

Static libraries Merged with the program at link time.


No runtime dependencies.

Shared libraries Not merged with the program at link time.


Must be available at run time.
Naming Conventions

>_ soname
$ ls -l /lib/x86_64-linux-gnu/libc.so.6 Library name (lib prefix)
rwxrwxrwx 1 root root 12 feb 6 22:17 /lib/x86_64-linux-gnu/libc.so.6 ->
libc-2.24.so so (shared object)
Version number
Example: libpthread.so.0
Example: libpthread.a
Common Locations

/lib

/lib32

/lib64

/usr/lib

/usr/local/lib
Configure Shared Library Paths

>_ ld.so or ld-linux.so


$ cat /etc/ld.so.conf /etc/ld.so.conf
include /etc/ld.so.conf.d/*.conf
/etc/ld.so.conf.d/

$ ls /etc/ld.so.conf.d/
libc.conf x86_64-linux-gnu.conf

$ cat /etc/ld.so.conf.d/x86_64-linux-gnu.conf
# Multiarch support
/lib/x86_64-linux-gnu
/usr/lib/x86_64-linux-gnu
ldconfig

>_
$ sudo ldconfig -v
/usr/local/lib:
/lib/x86_64-linux-gnu:
libnss_myhostname.so.2 -> libnss_myhostname.so.2
libfuse.so.2 -> libfuse.so.2.9.7
libidn.so.11 -> libidn.so.11.6.16
libnss_mdns4.so.2 -> libnss_mdns4.so.2
libparted.so.2 -> libparted.so.2.0.1
(...)
ldconfig

>_
$ sudo ldconfig -p
1094 libs found in the cache `/etc/ld.so.cache'
libzvbi.so.0 (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libzvbi.so.0
libzvbi-chains.so.0 (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libzvbi-chains.so.0
libzmq.so.5 (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libzmq.so.5
libzeitgeist-2.0.so.0 (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libzeitgeist-2.0.so.0
(...)

$ sudo ldconfig -p | grep libfuse


libfuse.so.2 (libc6,x86-64) => /lib/x86_64-linux-gnu/libfuse.so.2

$ ls -l /lib/x86_64-linux-gnu/libfuse.so.2
lrwxrwxrwx 1 root root 16 Aug 21 2018 /lib/x86_64-linux-gnu/libfuse.so.2 ->
libfuse.so.2.9.7
ldconfig

>_
$ LD_LIBRARY_PATH=/usr/local/mylib

$ echo $LD_LIBRARY_PATH
/usr/local/mylib

$ export LD_LIBRARY_PATH=/usr/local/mylib

$ unset LD_LIBRARY_PATH

$ echo export LD_LIBRARY_PATH=/usr/local/mylib >> ~/.bashrc


Dependencies

>_
$ ldd /usr/bin/git
linux-vdso.so.1 => (0x00007ffcbb310000)
libpcre.so.3 => /lib/x86_64-linux-gnu/libpcre.so.3 (0x00007f18241eb000)
libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f1823fd1000)
libresolv.so.2 => /lib/x86_64-linux-gnu/libresolv.so.2 (0x00007f1823db6000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f1823b99000)
librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f1823991000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f18235c7000)
/lib64/ld-linux-x86-64.so.2 (0x00007f182445b000)

$ ldd /lib/x86_64-linux-gnu/libc.so.6
/lib64/ld-linux-x86-64.so.2 (0x00007fbfed578000)
linux-vdso.so.1 (0x00007fffb7bf5000)

$ ldd -u /usr/bin/git
Unused direct dependencies:
/lib/x86_64-linux-gnu/libz.so.1
/lib/x86_64-linux-gnu/libpthread.so.0
/lib/x86_64-linux-gnu/librt.so.1
Debian Package Management: dpkg
dpkg

Early software: source code in compressed files like .tar and .gz

Users had to unpack and compile software manually

Increasing complexity led to package managers

Debian package format uses .deb files and the package tool dpkg
dpkg

>_
$ sudo dpkg -i mypackage.deb
dpkg

>_ fonts-cantarell
$ sudo dpkg -i openshot-qt_2.4.3+dfsg1-1_all.deb python3-openshot
(Reading database ... 269630 files and directories currently installed.)
Preparing to unpack openshot-qt_2.4.3+dfsg1-1_all.deb ...
Unpacking openshot-qt (2.4.3+dfsg1-1) over (2.4.3+dfsg1-1) ...
python3-pyqt5
dpkg: dependency problems prevent configuration of openshot-qt:
openshot-qt depends on fonts-cantarell; however: python3-pyqt5.qtsvg
Package fonts-cantarell is not installed.
openshot-qt depends on python3-openshot; however:
Package python3-openshot is not installed. python3-pyqt5.qtwebkit
openshot-qt depends on python3-pyqt5; however:
Package python3-pyqt5 is not installed.
openshot-qt depends on python3-pyqt5.qtsvg; however:
python3-zmq
Package python3-pyqt5.qtsvg is not installed.
openshot-qt depends on python3-pyqt5.qtwebkit; however:
Package python3-pyqt5.qtwebkit is not installed.
openshot-qt depends on python3-zmq; however:
Package python3-zmq is not installed.
dpkg: error processing package openshot-qt (--install):
dependency problems - leaving unconfigured
Processing triggers for mime-support (3.60ubuntu1) ...
Processing triggers for gnome-menus (3.32.0-1ubuntu1) ...
Processing triggers for desktop-file-utils (0.23-4ubuntu1) ...
Processing triggers for hicolor-icon-theme (0.17-2) ...
Processing triggers for man-db (2.8.5-2) ...
Errors were encountered while processing:
openshot-qt
dpkg

>_
$ sudo dpkg -r unrar
(Reading database ... 269630 files and directories currently installed.)
Removing unrar (1:5.6.6-2) ...
Processing triggers for man-db (2.8.5-2) ...

$ sudo dpkg -r p7zip


# dpkg -r p7zip
dpkg: dependency problems prevent removal of p7zip:
winetricks depends on p7zip; however:
Package p7zip is to be removed.
p7zip-full depends on p7zip (= 16.02+dfsg-6).
dpkg: error processing package p7zip (--remove):
dependency problems - not removing
Errors were encountered while processing:
p7zip
dpkg

>_
$ sudo dpkg -r unrar p7zip

$ sudo dpkg -P unrar p7zip

$ sudo dpkg -i --force openshot-qt_2.4.3+dfsg1-1_all.deb


dpkg

>_
$ sudo dpkg -I google-chrome-stable_current_amd64.deb
new Debian package, version 2.0.
size 59477810 bytes: control archive=10394 bytes.
1222 bytes, 13 lines control
16906 bytes, 457 lines * postinst #!/bin/sh
12983 bytes, 344 lines * postrm #!/bin/sh
1385 bytes, 42 lines * prerm #!/bin/sh
Package: google-chrome-stable
Version: 76.0.3809.100-1
Architecture: amd64
Maintainer: Chrome Linux Team <[email protected]>
Installed-Size: 205436
Pre-Depends: dpkg (>= 1.14.0)
Depends: ca-certificates, fonts-liberation, libappindicator3-1, libasound2 (>=
1.0.16), libatk-bridge2.0-0 (>= 2.5.3), libatk1.0-0 (>= 2.2.0), libatspi2.0-0 (>=
2.9.90), libc6 (>= 2.16), libcairo2 (>= 1.6.0), libcups2 (>= 1.4.0), libdbus-1-3
(>= 1.5.12), libexpat1 (>= 2.0.1), libgcc1 (>= 1:3.0), libgdk-pixbuf2.0-0 (>=
2.22.0), libglib2.0-0 (>= 2.31.8), libgtk-3-0 (>= 3.9.10), libnspr4 (>= 2:4.9-2~),
libnss3 (>= 2:3.22), libpango-1.0-0 (>= 1.14.0), libpangocairo-1.0-0 (>= 1.14.0),
libuuid1 (>= 2.16), libx11-6 (>= 2:1.4.99.1), libx11-xcb1, libxcb1 (>= 1.6),
libxcomposite1 (>= 1:0.3-1), libxcursor1 (>> 1.1.2), libxdamage1 (>= 1:1.1),
libxext6, libxfixes3, libxi6 (>= 2:1.2.99.4), libxrandr2 (>= 2:1.2.99.3),
libxrender1, libxss1, libxtst6, lsb-release, wget, xdg-utils (>= 1.0.2)
Recommends: libu2f-udev
Provides: www-browser
Section: web
Priority: optional
Description: The web browser from Google
Google Chrome is a browser that combines a minimal design with sophisticated
technology to make the web faster, safer, and easier.
dpkg

>_
$ sudo dpkg --get-selections

$ sudo dpkg -L unrar


.
/usr
/usr/bin
/usr/bin/unrar-nonfree
/usr/share
/usr/share/doc
/usr/share/doc/unrar
/usr/share/doc/unrar/changelog.Debian.gz
/usr/share/doc/unrar/copyright
/usr/share/man
/usr/share/man/man1
/usr/share/man/man1/unrar-nonfree.1.gz

$ sudo dpkg-query -S /usr/bin/unrar-nonfree


unrar: /usr/bin/unrar-nonfree
dpkg

>_
$ sudo dpkg-recongifure tzdata
Debian Package Management: apt
APT

APT: Advanced Package Tool

Features:
• Advanced search and automatic dependency resolution
• Not a substitute for dpkg (Think of this as a front end)
• Works with software repositories
• Repositories may be local, a remote server, or a CD-ROM
• Distributions like Debian and Ubuntu maintain their own
repositories
• Other repositories are maintained by users or groups to provide
software not available in the main distribution repositories
APT

>_
$ sudo apt-get Download, install, upgrade, and remove

$ sudo apt-cache Searches in the package index

$ sudo apt-file Searches for files inside of packages

$ sudo apt Combines features of apt-get and apt-cache


APT

>_
$ sudo apt-get update
apt-get update
Ign:1 http://dl.google.com/linux/chrome/deb stable InRelease
Hit:2 https://repo.skype.com/deb stable InRelease
Hit:3 http://us.archive.ubuntu.com/ubuntu disco InRelease
Hit:4 http://repository.spotify.com stable InRelease
Hit:5 http://dl.google.com/linux/chrome/deb stable Release
Hit:6 http://apt.pop-os.org/proprietary disco InRelease
Hit:7 http://ppa.launchpad.net/system76/pop/ubuntu disco InRelease
Hit:8 http://us.archive.ubuntu.com/ubuntu disco-security InRelease
Hit:9 http://us.archive.ubuntu.com/ubuntu disco-updates InRelease
Hit:10 http://us.archive.ubuntu.com/ubuntu disco-backports InRelease
Reading package lists... Done
APT

>_
$ sudo apt-get install xournal
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
xournal
0 upgraded, 1 newly installed, 0 to remove and 75 not upgraded.
Need to get 285 kB of archives.
After this operation, 1041 kB of additional disk space will be used.
APT

>_
$ sudo apt-get remove xournal
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages will be REMOVED:
xournal
0 upgraded, 0 newly installed, 1 to remove and 75 not upgraded.
After this operation, 1041 kB disk space will be freed.
Do you want to continue? [Y/n]
APT

>_
$ sudo apt-get remove p7zip
Reading package lists... Done
Building dependency tree
The following packages will be REMOVED:
android-libbacktrace android-libunwind android-libutils
android-libziparchive android-sdk-platform-tools fastboot p7zip p7zip-full
0 upgraded, 0 newly installed, 8 to remove and 75 not upgraded.
After this operation, 6545 kB disk space will be freed.
Do you want to continue? [Y/n]

$ sudo apt-get purge p7zip

$ sudo apt-get remove --purge p7zip


APT

>_
$ sudo dpkg -i --force openshot-qt_2.4.3+dfsg1-1_all.deb
(Reading database ... 269630 files and directories currently installed.)
Preparing to unpack openshot-qt_2.4.3+dfsg1-1_all.deb ...
Unpacking openshot-qt (2.4.3+dfsg1-1) over (2.4.3+dfsg1-1) ...
dpkg: dependency problems prevent configuration of openshot-qt:
openshot-qt depends on fonts-cantarell; however:
Package fonts-cantarell is not installed.
openshot-qt depends on python3-openshot; however:
Package python3-openshot is not installed.
openshot-qt depends on python3-pyqt5; however:
Package python3-pyqt5 is not installed.
openshot-qt depends on python3-pyqt5.qtsvg; however:
Package python3-pyqt5.qtsvg is not installed.
openshot-qt depends on python3-pyqt5.qtwebkit; however:
Package python3-pyqt5.qtwebkit is not installed.
openshot-qt depends on python3-zmq; however:
Package python3-zmq is not installed.

$ sudo apt-get install -f


APT

>_
$ sudo apt-get update
Hit:1 http://us.archive.ubuntu.com/ubuntu disco InRelease
Hit:2 http://us.archive.ubuntu.com/ubuntu disco-security InRelease
Hit:3 http://us.archive.ubuntu.com/ubuntu disco-updates InRelease
Hit:4 http://us.archive.ubuntu.com/ubuntu disco-backports InRelease
Reading package lists... Done

$ sudo apt-get upgrade


# apt-get upgrade
Reading package lists... Done
Building dependency tree
Reading state information... Done
Calculating upgrade... Done
The following packages have been kept back:
gnome-control-center
The following packages will be upgraded:
cups cups-bsd cups-client cups-common cups-core-drivers cups-daemon
cups-ipp-utils cups-ppdc cups-server-common firefox-locale-ar (...)
74 upgraded, 0 newly installed, 0 to remove and 1 not upgraded.
Need to get 243 MB of archives.
After this operation, 30.7 kB of additional disk space will be used.
Do you want to continue? [Y/n]
APT

>_
$ sudo apt-get upgrade unrar
APT

>_ /var/cache/apt/archives
$ sudo apt-get clean
/var/cache/apt/archives/partial
APT

>_
$ sudo apt-cache search p7zip
liblzma-dev - XZ-format compression library - development files
liblzma5 - XZ-format compression library
forensics-extra - Forensics Environment - extra console components
(metapackage)
p7zip - 7zr file archiver with high compression ratio
p7zip-full - 7z and 7za file archivers with high compression ratio
p7zip-rar - non-free rar module for p7zip
APT

>_
$ sudo apt-cache show liblzma5
# apt-cache show liblzma5
Package: liblzma5
Architecture: amd64
Version: 5.2.4-1
Multi-Arch: same
Priority: required
Section: libs
Source: xz-utils
Origin: Ubuntu
Maintainer: Ubuntu Developers <[email protected]>
Original-Maintainer: Jonathan Nieder <[email protected]>
Bugs: https://bugs.launchpad.net/ubuntu/+filebug
Installed-Size: 259
Depends: libc6 (>= 2.17)
Breaks: liblzma2 (<< 5.1.1alpha+20110809-3~)
Filename: pool/main/x/xz-utils/liblzma5_5.2.4-1_amd64.deb
Size: 92352
MD5sum: 223533a347dc76a8cc9445cfc6146ec3
SHA1: 8ed14092fb1caecfebc556fda0745e1e74ba5a67
SHA256: 01020b5a0515dbc9a7c00b464a65450f788b0258c3fbb733ecad0438f5124800
Homepage: https://tukaani.org/xz/
Description-en: XZ-format compression library
XZ is the successor to the Lempel-Ziv/Markov-chain Algorithm
compression format, which provides memory-hungry but powerful
compression (often better than bzip2) and fast, easy decompression.
.
The native format of liblzma is XZ; it also supports raw (headerless)
streams and the older LZMA format used by lzma. (For 7-Zip's related
format, use the p7zip package instead.)
APT

/etc/apt/sources.list
deb http://us.archive.ubuntu.com/ubuntu/ disco main restricted universe multiverse

main: officially supported open-source packages

restricted: officially supported closed-source software, like device drivers

universe: community maintained open-source software

multiverse: unsupported closed-source or patented software

main: complies with Debian Free Software Guidelines (DFSG)

contrib: DFSG-compliant packages with dependencies not in main

non-free: not compliant with DFSG

security: security updates

backports: more recent than main


APT

>_ buster-backports.list

$ sudo vi /etc/apt/sources.list.d/buster-backports.list deb http://deb.debian.org/debian buster-backports


main contrib non-free
deb-src http://deb.debian.org/debian buster-backports
main contrib non-free
APT

>_
$ sudo apt-get install apt-file

$ sudo apt-file update

$ sudo apt-file list unrar


unrar: /usr/bin/unrar-nonfree
unrar: /usr/share/doc/unrar/changelog.Debian.gz
unrar: /usr/share/doc/unrar/copyright
unrar: /usr/share/man/man1/unrar-nonfree.1.gz

$ sudo apt-file search libSDL2.so


libsdl2-dev: /usr/lib/x86_64-linux-gnu/libSDL2.so
Package Management Using zypper
zypper

>_
$ sudo zypper refresh $ sudo zypper se -u httpd

$ sudo zypper se gnumeric


Loading repository data...
Reading installed packages...
S | Name | Summary | Type
--+----------------+-----------------------------------+--------
| gnumeric | Spreadsheet Application | package
| gnumeric-devel | Spreadsheet Application | package
| gnumeric-doc | Documentation files for Gnumeric | package
| gnumeric-lang | Translations for package gnumeric | packag

$ sudo zypper se -i

$ sudo zypper se -i firefox


Loading repository data...
Reading installed packages...
S | Name | Summary | Type
--+------------------------------------+-------------------------+--------
i | MozillaFirefox | Mozilla Firefox Web B-> | package
i | MozillaFirefox-branding-openSUSE | openSUSE branding of -> | package
i | MozillaFirefox-translations-common | Common translations f-> | package
zypper

>_
$ sudo zypper in unrar
zypper in unrar
Loading repository data...
Reading installed packages...
Resolving package dependencies...
The following NEW package is going to be installed:
unrar
1 new package to install.
Overall download size: 141.2 KiB. Already cached: 0 B. After the operation,
additional 301.6 KiB will be used.
Continue? [y/n/v/...? shows all options] (y): y
Retrieving package unrar-5.7.5-lp151.1.1.x86_64
(1/1), 141.2 KiB (301.6 KiB unpacked)
Retrieving: unrar-5.7.5-lp151.1.1.x86_64.rpm .......................[done]
Checking for file conflicts: .......................................[done]
(1/1) Installing: unrar-5.7.5-lp151.1.1.x86_64 .....................[done]

$ sudo zypper in /home/aaron/nomachine.rpm


zypper

>_
$ sudo zypper rm unrar
Loading repository data...
Reading installed packages...
Resolving package dependencies...
The following package is going to be REMOVED:
unrar
1 package to remove.
After the operation, 301.6 KiB will be freed.
Continue? [y/n/v/...? shows all options] (y): y
(1/1) Removing unrar-5.7.5-lp151.1.1.x86_64 ........................[done]
zypper

>_
$ sudo zypper rm libgimp-2_0-0
Loading repository data...
Warning: No repositories defined. Operating only with the installed resolvables.
Nothing can be installed.
Reading installed packages...
Resolving package dependencies...
The following 6 packages are going to be REMOVED:
gimp gimp-help gimp-lang gimp-plugins-python libgimp-2_0-0
libgimpui-2_0-0
6 packages to remove.
After the operation, 98.0 MiB will be freed.
Continue? [y/n/v/...? shows all options] (y):
zypper

>_
$ sudo zypper repos
Repository priorities are without effect. All enabled repositories share the same
priority.
# | Alias | Name | Enabled | GPG Check | Refresh
---+---------------------------+------------------------------------+---------+
-----------+--------
1 | openSUSE-Leap-15.1-1 | openSUSE-Leap-15.1-1 | No |
---- | ----
2 | repo-debug | Debug Repository | No |
---- | ----
3 | repo-debug-non-oss | Debug Repository (Non-OSS) | No |
---- | ----
4 | repo-debug-update | Update Repository (Debug) | No |
---- | ----
5 | repo-debug-update-non-oss | Update Repository (Debug, Non-OSS) | No |
---- | ----
6 | repo-non-oss | Non-OSS Repository | Yes | (r) Yes | Yes
7 | repo-oss | Main Repository | Yes | (r) Yes | Yes
8 | repo-source | Source Repository | No |
---- | ----
zypper

>_
$ sudo zypper modifyrepo -d repo-non-oss
Repository 'repo-non-oss' has been successfully disabled.

$ sudo zypper modifyrepo -e repo-non-oss


Repository 'repo-non-oss' has been successfully enabled.

$ sudo zypper modifyrepo -f repo-non-oss


Autorefresh has been enabled for repository 'repo-non-oss'.

$ sudo zypper modifyrepo -F repo-non-oss


Autorefresh has been disabled for repository 'repo-non-oss'.
zypper

>_
$ sudo zypper addrepo http://packman.inode.at/suse/openSUSE-Leap_15.1/packman
Adding repository 'packman' ........................................[done]
Repository 'packman' successfully added
URI : http://packman.inode.at/suse/openSUSE_Leap_15.1/
Enabled : Yes
GPG Check : Yes
Autorefresh : No
Priority : 99 (default priority)
Repository priorities are without effect. All enabled repositories share the same
priority.

$ sudo zypper removerepo packman


Removing repository 'packman' ......................................[done]
Repository 'packman' has been removed.
Linux as a Virtualization Guest:
Tools and Images
Virtualization

Virtualization: Allows a hypervisor to run processes that contain a


fully emulated computer system

Hypervisor: Manages the physical hardware's resources used by


individual virtual machines
• Separates access to the host's hardware resources, allowing
multiple operating systems on a single host

Virtual Are known as guests of the hypervisor


machines:
• Have many aspects of a physical computer emulated in software

• Often use hard disk images stored as individual files


and access RAM and CPU through the hypervisor
Xen

Xen: open-source Type-1 hypervisor

• Bare-metal hypervisor

• Computer can boot directly into the Xen hypervisor


KVM

Kernel Virtual Linux kernel module for virtualization


Machine:
• Both Type-1 and Type-2 hypervisor

• Needs a generic Linux operating system to work

• Can integrate with a running Linux installation

• Virtual machines use the libvirt daemon


VirtualBox

VirtualBox: Popular desktop application to create and manage


virtual machines

• Cross-platform: works on Linux, macOS, and Microsoft Windows

• Type-2 hypervisor
Migrations

Some hypervisors allow dynamic relocation of virtual machines

Migration: moving a virtual machine from one hypervisor


installation to another
• Some migrations require the guest to be completely shut down

Live migration: can be performed while the guest is running


• Useful for maintenance on hypervisors and system resiliency
Types of Virtual Machines

Paravirtualized Fully Hybrid


Guest Virtualized Guest
Guest
Fully Virtualized Guests

All guest instructions must be able to run within a fully virtualized


operating system installation

No additional software drivers installed within the guest to translate


instructions

The guest is unaware that it is running as a virtual machine

Requires Intel VT-x or AMD-V CPU extensions on x86 platforms


Paravirtualized Guests

PVM: The guest operating system is aware that it is running


in a virtual machine instance

• Uses a modified kernel and special drivers to help the


guest utilize software and hardware resources

• Performance is often better than a fully virtualized guest


due to these drivers
Hybrid Guests

Combines paravirtualization and full virtualization

Unmoidified operating systems receive near-native I/O performance


using paravirtualized drivers

Paravirtualized drivers contain storage and networking device


drivers to enhance performance

KVM uses the Virtio project

VirtualBox uses Guest Extentions


Virtual Machines in the Cloud

IaaS providers run hypervisor systems to deploy virtual


(infrastructure guests
as a service):

• Provide tools to build, deploy, and configure custom virtual machines

• May provide systems for deployment and migration of virtual


machines from a customer's organization
Computing Instances

Many providers charge usage rates based on computing


instances

Computing how much CPU time your cloud-based infrastructure


Instances: will use

• Careful planning is required to keep cloud costs manageable

• Computing instances may refer to the number of virtual machines


provisioned in a cloud environment

• Higher usage means higher cost


Block Storage

Block Storage: May be meant for web-based traffic or external storage


used to host files

• Costs vary based on the amount of storage used and storage speed

• Faster storage access typically costs more

• Archival storage is often very inexpensive


Networking

Networking: Web-based utilities for designing and implementing


network routes, subnetting, and firewall control

• May provide DNS solutions for publicly accessible fully


qualified domain names

• Hybrid solutions can connect existing on-premise


network infrastructure to the cloud through VPN
Preconfiguring Cloud Systems

>_ cloud-config
$ vi cloud-config #cloud-config
timezone: Africa/Dar_es_Salaam
hostname: test-system
# Update the system when it first boots up
apt_update: true
apt_upgrade: true
# Install the Nginx web server
packages:
- nginx
Login Methods

Local text-mode console Remote text-mode login

Local graphical-mode console Remote graphical-mode login


Console Virtual Terminal Terminal Emulator
Consoles
Virtual Terminals

CTRL + ALT + F2
Terminal Emulators
Local GUI
Local text console
Remote GUI

VNC RDP
Remote text-mode login

SSH

Secure SHell

telnet
SSH login

>_
$ ip a Server
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group
default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 SSH daemon
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state
UP group default qlen 1000
link/ether 08:00:27:6b:d7:87 brd ff:ff:ff:ff:ff:ff
inet 192.168.0.17/24 brd 192.168.0.255 scope global dynamic
noprefixroute enp0s3
valid_lft 1966sec preferred_lft 1966sec
inet6 fe80::a00:27ff:fe6b:d787/64 scope link noprefixroute

SSH client

Computer
MacOS & Linux
Windows
SSH

>_

$ ssh [email protected]
[email protected]'s password:
Activate the web console with: systemctl enable --now cockpit.socket

Last login: Tue Oct 19 20:27:15 2021 from 192.168.0.3


[aaron@LFCS-CentOS ~]$
Use and Edit Bash
Command History
Bash History

>_
$ history
1 history

2 ls

3 ls -la

4 test

5 clear

6 cd

7 pwd

8 clear

9 sudo systemctl reboot

10 ls -la

11 clear
Bash History

>_
$ history | grep sudo
9 sudo systemctl reboot

12 sudo yum update

14 sudo -i

17 history | grep sudo


Bash History

>_
$ ls -la /home/aaron
drwx------. 14 aaron aaron 4096 Dec 5 13:52 .

drwxr-xr-x. 3 root root 19 Dec 5 13:43 ..

-rw-------. 1 aaron aaron 112 Dec 5 13:51 .bash_history

-rw-r--r--. 1 aaron aaron 18 Nov 24 08:20 .bash_logout

-rw-r--r--. 1 aaron aaron 141 Nov 24 08:20 .bash_profile

-rw-r--r--. 1 aaron aaron 492 Nov 24 08:20 .bashrc

drwx------. 7 aaron aaron 181 Dec 5 13:45 .cache

drwx------. 9 aaron aaron 4096 Dec 5 13:46 .config

drwxr-xr-x. 2 aaron aaron 6 Dec 5 13:45 Desktop

drwxr-xr-x. 2 aaron aaron 6 Dec 5 13:45 Documents

drwxr-xr-x. 2 aaron aaron 6 Dec 5 13:45 Downloads


Bash History

>_
$ cat .bash_history
history

ls

ls -la

test

clear

cd

pwd

clear

sudo systemctl reboot

ls -la

clear

UP DOWN ENTER
Working With Files
and Directories
Listing Files and Directories

>_
$ ls
Pictures Desktop
ls list
Documents Videos
Downloads Music

$ ls -a -a all
.
..
.ssh
.bash_logout
.bash_profile
.bashrc
Pictures
Desktop Documents Videos
Downloads Music
Listing Files and Directories

>_
$ ls –l /var/log/
total 4064
drwxr-xr-x. 2 root root 4096 Oct 18 22:52 anaconda
drwx------. 2 root root 23 Oct 18 22:53 audit
-rw-------. 1 root root 19524 Nov 1 17:56 boot.log
-rw-rw----. 1 root utmp 0 Nov 1 14:08 btmp
-rw-rw----. 1 root utmp 0 Oct 18 22:38 btmp-20211101
drwxr-x---. 2 chrony chrony 6 Jun 24 09:21 chrony
-rw-------. 1 root root 9794 Nov 1 18:01 cron
-rw-------. 1 root root 10682 Oct 26 14:01 cron-20211026
drwxr-xr-x. 2 lp sys 135 Oct 26 14:13 cups
-rw-r--r--. 1 root root 35681 Nov 1 18:13 dnf.rpm.log
-rw-r-----. 1 root root 4650 Nov 1 17:56 firewalld
drwx--x--x. 2 root gdm 6 Oct 19 00:07 gdm
drwxr-xr-x. 2 root root 6 Aug 31 12:07 glusterfs
Listing Files and Directories

>_
$ ls –a -l $ ls –al
total 76
drwx------. 16 aaron aaron 4096 Nov 1 17:57 .
drwxr-xr-x. 7 root root 70 Oct 26 16:54 ..
-rw-------. 1 aaron aaron 5085 Nov 1 17:56 .bash_history
-rw-r--r--. 1 aaron aaron 18 Jul 27 09:21 .bash_logout
-rw-r--r--. 1 aaron aaron 141 Jul 27 09:21 .bash_profile
-rw-r--r--. 1 aaron aaron 376 Jul 27 09:21 .bashrc
drwxr-xr-x. 2 aaron aaron 6 Oct 19 00:11 Desktop
drwxr-xr-x. 3 aaron aaron 25 Oct 23 18:15 Documents
drwxr-xr-x. 2 aaron aaron 6 Oct 19 00:11 Downloads
drwxr-xr-x. 2 aaron aaron 6 Oct 19 00:11 Music
drwxr-xr-x. 2 aaron aaron 28 Oct 26 13:37 Pictures
-rw-rw-r--. 1 aaron aaron 36 Oct 28 20:06 testfile
Listing Files and Directories

>_
$ ls –alh -h human readable format
total 76K
drwx------. 16 aaron aaron 4.0K Nov 1 17:57 .
drwxr-xr-x. 7 root root 70 Oct 26 16:54 ..
-rw-------. 1 aaron aaron 5.0K Nov 1 17:56 .bash_history
-rw-r--r--. 1 aaron aaron 18 Jul 27 09:21 .bash_logout
-rw-r--r--. 1 aaron aaron 141 Jul 27 09:21 .bash_profile
-rw-r--r--. 1 aaron aaron 376 Jul 27 09:21 .bashrc
drwxr-xr-x. 2 aaron aaron 6 Oct 19 00:11 Desktop
drwxr-xr-x. 3 aaron aaron 25 Oct 23 18:15 Documents
drwxr-xr-x. 2 aaron aaron 6 Oct 19 00:11 Downloads
drwxr-xr-x. 2 aaron aaron 6 Oct 19 00:11 Music
drwxr-xr-x. 2 aaron aaron 28 Oct 26 13:37 Pictures
-rw-rw-r--. 1 aaron aaron 36 Oct 28 20:06 testfile
Filesystem Tree

home var

aaron jane log

Documents

Invoice.pdf
Filesystem Tree

home var

aaron jane log

directory path Documents

file path Invoice.pdf


Absolute Path

/ home/aaron/Documents/Invoice.pdf
/

home var

aaron jane log

Documents

Invoice.pdf
Current / Working Directory

>_
/
$ pwd print working directory
/root

home var root

aaron jane log

Documents

Invoice.pdf
Current / Working Directory

>_
$ cd /var/log change directory /

$ cd /home/aaron home var root

$ cd .. .. = parent directory

aaron jane log

Documents

Invoice.pdf
Relative Path

>_
Invoice.pdf /
$ Documents/Invoice.pdf

$ Invoice.pdf
Invoice.pdf home var

$ ../Invoice.pdf

$ ../../Invoice.pdf Invoice.pdf aaron log

Documents

Invoice.pdf
Current / Working Directory

>_
/
$ cd / # Go to root directory

$ cd - # Go to previous directory
home var

$ cd # Go to home directory

aaron log

Documents

Invoice.pdf
Creating Files

>_
$ touch Receipt.pdf /

$ touch /home/jane/Receipt.pdf

$ touch ../jane/Receipt.pdf home

aaron jane

Receipt.pdf Receipt.pdf
Creating Directories

>_
/
$ mkdir Receipts make directory

home

aaron jane

Receipts
Receipt.pdf Receipt.pdf
Copying Files

>_
# cp [source] [destination] /
copy

$ cp Receipt.pdf Receipts/

$ cp Receipt.pdf Receipts home

$ cp Receipt.pdf Receipts/ ReceiptCopy.pdf

aaron

Receipts
Receipt.pdf

Receipt.pdf ReceiptCopy.pdf
Copying Directories

>_
# cp -r [source] [dest] /
recursive

$ cp –r Receipts/ BackupOfReceipts/
home

aaron

Receipts BackupOfReceipts

D D D D D D

F F F F F F
Copying Directories

>_
# cp -r [source] [dest] /
recursive

$ cp –r Receipts/ BackupOfReceipts/ home

aaron

Receipts BackupOfReceipts

D D D

F F F Receipts

D D D
F F F
Moving Files

>_
/
$ cp Receipt.pdf Receipts/

home

aaron

2
Receipts
Receipt.pdf

Receipt.pdf 1
Moving Files

>_
/
# mv [source] [dest] move

$ mv Receipt.pdf Receipts/
home
$ mv Receipt.pdf OldReceipt.pdf

$ mv Receipts/ OldReceipts/
aaron

Receipts
OldReceipts
Receipt.pdf
1

OldReceipt.pdf
Deleting Files and Directories

>_
/
# rm remove

$ rm Invoice.pdf

$ rm -r Invoices/ home

aaron

Invoices

Invoice.pdf
Manage System-wide
Environment Profiles
Manage System-wide Environment Profiles

>_
$ printenv $ env
PATH=/home/aaron/.local/bin:/home/aaron/bin:/usr/local/bin:/usr/local/sbin
:/usr/bin:/usr/sbin
HISTSIZE=1000
GJS_DEBUG_TOPICS=JS ERROR;JS LOG
SESSION_MANAGER=local/unix:@/tmp/.ICE-unix/2260,unix/unix:/tmp/.ICE-
unix/2260

$ HISTSIZE=2000

$ history
1 sudo nano -w /etc/hosts
2 ssh [email protected]
3 ssh student@LFCS-CentOS2
4 ls
5 ls -laF
6 cd .ssh
7 ls
8 nano -w known_hosts
9 exit
10 rm .ssh/known_hosts
Manage System-wide Environment Profiles

>_
$ printenv
PWD=/home/aaron
SSH_ASKPASS=/usr/libexec/openssh/gnome-ssh-askpass
HOME=/home/aaron

$ echo $HOME
/home/aaron

$ touch $HOME/saved_file $ touch /home/aaron/saved_file


Manage System-wide Environment Profiles

>_ environment
$ cat .bashrc
# .bashrc KODEKLOUD=https://kodekloud.com
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi

# User specific environment


if ! [[ "$PATH" =~ "$HOME/.local/bin:$HOME/bin:" ]]
then
PATH="$HOME/.local/bin:$HOME/bin:$PATH"
fi
export PATH

$ sudo vim /etc/environment

$ logout

$ echo $KODEKLOUD
https://kodekloud.com
Manage System-wide Environment Profiles

>_ environment
$ sudo vim /etc/profile.d/lastlogin.sh echo "Your last login was at: " >
$HOME/lastlogin

date >> $HOME/lastlogin


$ logout

$ ls
lastlogin

$ cat lastlogin
Your last login was at: Thursday DEC 16 11:19:27 CDT 2021
Manage Template
User Environment
Manage Template User Environment

>_ README
$ sudo vim /etc/skel/README Please don't run CPU-intensive
processes between 8AM and 10PM.

$ sudo useradd trinity

$ sudo ls -a /home/trinity
. .. .bash_logout .bash_profile .bashrc README

$ cat README
Please don't run CPU-intensive processes between 8AM and 10PM.
Manage Template User
Environment

>_ .bashrc
$ sudo vim /home/trinity/.bashrc
PATH="$HOME/.local/bin:$HOME/bi
n:$PATH"

$ echo $PATH
/home/trinity/.local/bin:/home/trinity/bin:/usr/local/bin:/usr/bin:/usr PATH="$HOME/.local/bin:$HOME/bin
/local/sbin:/usr/sbin :/opt/bin:$PATH"

$ specialtool $ /opt/specialtool

$ sudo vim /etc/skel/.bashrc


Basic File Management: Wildcard
Specifications in Commands
Types of Wildcards

* (asterisk): Represents zero, one, or more occurrences of


any character

? (question mark): Represents a single occurrence of any character

[ ] (bracketed characters): Represents an occurrence of the character(s)


enclosed in the square brackets

[0-9] matches all digits


Asterisk

>_
$ find /home -name *.png
photo.png
cat.png
frank.png

$ ls lpic-*.txt
lpic-1.txt lpic-2.txt

$ cp -r animal/* forest

$ rm *ate*
Question Mark

>_
$ ls
last.txt lest.txt list.txt third.txt past.txt

$ ls l?st.txt
last.txt lest.txt list.txt

$ ls ??st.txt
last.txt lest.txt list.txt past.txt
Bracketed Characters

>_
$ ls l[aef]st.txt
last.txt lest.txt

$ ls l[a-z]st.txt
last.txt lest.txt list.txt

$ ls
student-1A.txt student-2A.txt student-3.txt

$ ls student-[0-9][A-Z].txt
student-1A.txt student-2A.txt
Combining Wildcards

>_
$ ls
last.txt lest.txt list.txt third.txt past.txt

$ ls [plf]?st*
last.txt lest.txt list.txt past.txt

$ ls
file1.txt file.txt file23.txt fom23.txt

$ ls f*[0-9].txt
file1.txt file23.txt fom23.txt
Analyze Text With
Regular Expressions .*
Regular Expressions

203.102.3.5
5.23
x is an integer
x is greater than 3 (x > 3)
x is less than 8 (x < 8)
x = 4, 5, or 6
Regex Operators

^
$
.
*
+
{}
?
|
[]
()
[^]
^ “The line begins with”

>_
$ less /etc/login.defs $ grep –v '^#' /etc/login.defs
# MAIL_DIR /var/spool/mail
# Please note that the parameters in this configuration file control the
# behavior of the tools from the shadow-utils component. None of these UMASK 022
# tools uses the PAM mechanism, and the utilities that use PAM (such as the
# passwd command) should therefore be configured elsewhere. Refer to HOME_MODE 0700
# /etc/pam.d/system-auth for more information.
# PASS_MAX_DAYS 99999
PASS_MIN_DAYS 0
# *REQUIRED* PASS_MIN_LEN 5
# Directory where mailboxes reside, _or_ name of file, relative to the PASS_WARN_AGE 7
# home directory. If you _do_ define both, MAIL_DIR takes precedence.
# QMAIL_DIR is for Qmail UID_MIN 1000
# UID_MAX 60000
#QMAIL_DIR Maildir SYS_UID_MIN 201
MAIL_DIR /var/spool/mail SYS_UID_MAX 999
#MAIL_FILE .mail
GID_MIN 1000
GID_MAX 60000
$ grep '^#' /etc/login.defs SYS_GID_MIN 201
SYS_GID_MAX 999

CREATE_HOME yes
^ “The line begins with”

>_

$ grep '^PASS' /etc/login.defs


PASS_MAX_DAYS 99999
PASS_MIN_DAYS 0
PASS_MIN_LEN 5
PASS_WARN_AGE 7
$ “The line ends with”

>_

$ grep '7' /etc/login.defs


# 022 is the default value, but 027, or even 077, could be considered
HOME_MODE 0700
PASS_WARN_AGE 7

$ grep '7$' /etc/login.defs


PASS_WARN_AGE 7

$ grep 'mail$' /etc/login.defs


MAIL_DIR /var/spool/mail
#MAIL_FILE .mail

^PASS
mail$
. “Match any ONE character”

>_

$ grep –r 'c.t' /etc/


/etc/man_db.conf:# manpath. If no catpath string is used, the catpath will default to the
/etc/man_db.conf:# the database cache for any manpaths not mentioned below unless explicitly
/etc/man_db.conf:# location of catpaths and the creation of database caches; it has no effect
/etc/man_db.conf:#DEFINE cat cat
/etc/man_db.conf:# directives may be given for clarity, and will be concatenated together in
/etc/man_db.conf:# is that you only need to explicitly list extensions if you want to force a
/etc/man_db.conf:# Range of terminal widths permitted when displaying cat pages. If the
/etc/man_db.conf:# terminal falls outside this range, cat pages will not be created (if
/etc/man_db.conf:# If CATWIDTH is set to a non-zero number, cat pages will always be
/etc/man_db.conf:# NOCACHE keeps man from creating cat pages.
/etc/nanorc:## Use cut-from-cursor-to-end-of-line by default.
/etc/nanorc:# set cutfromcursor
/etc/nanorc:## (The old form, 'cut', is deprecated.)
/etc/nanorc:## double click), and execute shortcuts. The mouse will work in the X

$ grep –wr ‘c.t’ /etc/


. “Match any ONE character”

>_
$ grep –wr 'c.t' /etc/
/etc/brltty/Input/mn/all.txt:Left: append to existing cut buffer from selected character
/etc/brltty/Input/mn/all.txt:Up: start new cut buffer at selected character
/etc/brltty/Input/mn/all.txt:Down: rectangular cut to selected character
/etc/brltty/Input/mn/all.txt:Right: linear cut to selected character
grep: /etc/libvirt: Permission denied
grep: /etc/wpa_supplicant/wpa_supplicant.conf: Permission denied
/etc/mime.types:application/vnd.commonspace csp cst
/etc/mime.types:# wav: audio/x-wav, cpt: application/mac-compactpro
/etc/mime.types:application/mac-compactpro cpt
grep: /etc/sudo-ldap.conf: Permission denied
grep: /etc/sudo.conf: Permission denied
grep: /etc/sudoers: Permission denied
grep: /etc/sudoers.d: Permission denied
grep: /etc/iscsi/iscsid.conf: Permission denied
grep: /etc/firewalld: Permission denied
/etc/mcelog/triggers/cache-error-trigger: if [ "$(cat $F)" != "0" ] ; then
/etc/smartmontools/smartd_warning.sh: cat <<EOF
Special Characters

>_
$ grep '.' /etc/login.defs
SYS_UID_MIN 201
SYS_UID_MAX 999
#
# Min/max values for automatic gid selection in groupadd
#
GID_MIN 1000
GID_MAX 60000
# System accounts
SYS_GID_MIN 201
SYS_GID_MAX 999
#
# If defined, this command is run when removing a user.
# It should remove any at/cron/print jobs etc. owned by
# the user to be removed (passed as the first argument).
#
#USERDEL_CMD /usr/sbin/userdel_local
#
# If useradd should create home directories for users by default
# On RH systems, we do. This option is overridden with the -m flag on
# useradd command line.
#
CREATE_HOME yes
# This enables userdel to remove user groups if no members exist.
\: Escaping For Special Characters

>_
$ grep '\.' /etc/login.defs
# behavior of the tools from the shadow-utils component. None of these
# passwd command) should therefore be configured elsewhere. Refer to
# /etc/pam.d/system-auth for more information.
# home directory. If you _do_ define both, MAIL_DIR takes precedence.
#MAIL_FILE .mail
# Default initial "umask" value used by login(1) on non-PAM enabled
systems.
# Default "umask" value for pam_umask(8) on PAM enabled systems.
# home directories if HOME_MODE is not set.
# for increased privacy. There is no One True Answer here: each sysadmin
# must make up their mind.
# home directories.
# If HOME_MODE is not set, the value of UMASK is used to create the mode.
# PASS_MAX_DAYS Maximum number of days a password may be
used.
# PASS_MIN_DAYS Minimum number of days allowed between
password changes.
# PASS_MIN_LEN Minimum acceptable password length.
# PASS_WARN_AGE Number of days warning given before a
password expires.
*: Match The Previous Element 0 Or More Times

>_

let* lettt
lett
let
$ grep -r 'let*' /etc/
/etc/pnm2ppa.conf:# configuration file (/etc/pnm2ppa.conf), and not from
configuration files
/etc/pnm2ppa.conf:#silent 1
/etc/pnm2ppa.conf:# (Older versions of pnm2ppa required larger left and
right margins to avoid
/etc/pnm2ppa.conf:# printer failure with "flashing lights", but this
problem is believed to
/etc/pnm2ppa.conf:#leftmargin 10
/etc/pnm2ppa.conf:# and color ink print cartridges. This changes a
little whenever you
/etc/pnm2ppa.conf:# if there is a horizontal offset between right-to-left
and left-to-right
/etc/pnm2ppa.conf:# density of black ink used: 1 (least ink), 2 (default),
4 (most).
/etc/pnm2ppa.conf:# a calibration file /etc/pnm2ppa.gamma, in which case
these
/etc/pnm2ppa.conf:# gEnh(i) = (int) ( pow ( (double) i / 256, Gamma ) *
256 )
/etc/pnm2ppa.conf:# Valid choices are: a4, letter, legal:
/etc/pnm2ppa.conf:#papersize letter # this is the default
/etc/pnm2ppa.conf:#papersize legal
*: Match The Previous Element 0 Or More Times

>_

$ grep -r '/.*/' /etc/ Begins with /; has 0 or more characters between; ends with a /
/etc/man_db.conf:# before /usr/man.
/etc/man_db.conf:MANDB_MAP /usr/man
/var/cache/man/fsstnd
/etc/man_db.conf:MANDB_MAP /usr/share/man
/var/cache/man
/etc/man_db.conf:MANDB_MAP /usr/local/man
/var/cache/man/oldlocal
/etc/man_db.conf:MANDB_MAP /usr/local/share/man
/var/cache/man/local
/etc/man_db.conf:MANDB_MAP /usr/X11R6/man
/var/cache/man/X11R6
/etc/man_db.conf:MANDB_MAP /opt/man /var/cache/man/opt
/etc/nanorc:# set quotestr "^([ ]*([#:>|}]|//))+"
/etc/nanorc:## include "/path/to/syntax_file.nanorc"
/etc/nanorc:include "/usr/share/nano/*.nanorc"
/etc/pbm2ppa.conf:# Sample configuration file for the HP720/HP820/HP1000
PPA Printers
/etc/pbm2ppa.conf:# /etc/pbm2ppa.conf
/etc/pnm2ppa.conf:# /etc/pnm2ppa.conf
/etc/pnm2ppa.conf:# configuration file (/etc/pnm2ppa.conf), and not from
configuration files
/etc/pnm2ppa.conf:# a calibration file /etc/pnm2ppa.gamma, in which case
these
/etc/mailcap:audio/*; /usr/bin/xdg-open %s
+: Match The Previous Element 1 Or More Times

>_

$ grep -r '0*' /etc/


/etc/pnm2ppa.conf:
/etc/pnm2ppa.conf:#black_ink 1
/etc/pnm2ppa.conf:#color_ink 1
/etc/pnm2ppa.conf:#cyan_ink 1
/etc/pnm2ppa.conf:#magenta_ink 1
/etc/pnm2ppa.conf:#yellow_ink 1
/etc/mailcap:###
/etc/mailcap:### Begin Red Hat Mailcap
/etc/mailcap:###
/etc/mailcap:
/etc/mailcap:audio/*; /usr/bin/xdg-open %s
/etc/mailcap:
/etc/mailcap:image/*; /usr/bin/xdg-open %s
/etc/mailcap:
/etc/mailcap:application/msword; /usr/bin/xdg-open %s
/etc/mailcap:application/pdf; /usr/bin/xdg-open %s
/etc/mailcap:application/postscript ; /usr/bin/xdg-open %s
/etc/mailcap:
/etc/mailcap:text/html; /usr/bin/xdg-open %s ; copiousoutput
/etc/subuid-:aaron:100000:65536
/etc/subuid-:bob:165536:65536
/etc/subuid-:charles:231072:65536
/etc/subuid-:david:296608:65536
+: Match The Previous Element 1 Or More Times

>_

$ grep -r '0*' /etc/ 0+


/etc/pnm2ppa.conf:
/etc/pnm2ppa.conf:#black_ink 1
/etc/pnm2ppa.conf:#color_ink 1
/etc/pnm2ppa.conf:#cyan_ink 1
/etc/pnm2ppa.conf:#magenta_ink 1
/etc/pnm2ppa.conf:#yellow_ink 1
/etc/mailcap:###
/etc/mailcap:### Begin Red Hat Mailcap
/etc/mailcap:###
/etc/mailcap:
/etc/mailcap:audio/*; /usr/bin/xdg-open %s
/etc/mailcap:
/etc/mailcap:image/*; /usr/bin/xdg-open %s
/etc/mailcap:
/etc/mailcap:application/msword; /usr/bin/xdg-open %s
/etc/mailcap:application/pdf; /usr/bin/xdg-open %s
/etc/mailcap:application/postscript ; /usr/bin/xdg-open %s
/etc/mailcap:
/etc/mailcap:text/html; /usr/bin/xdg-open %s ; copiousoutput
/etc/subuid-:aaron:100000:65536
/etc/subuid-:bob:165536:65536
/etc/subuid-:charles:231072:65536
+: Match The Previous Element 1 Or More Times

>_
0+ 000
00
$ grep -r '0+' /etc/ $ man grep
/etc/brltty/Keyboard/keypad.ktb:bind KP0+!KP2 MENU_NEXT_ITEM In basic regular expressions the meta-characters
/etc/brltty/Keyboard/keypad.ktb:bind KP0+!KP7 MENU_FIRST_ITEM ?, +, {, |, (, and ) lose their special meaning;
/etc/brltty/Keyboard/keypad.ktb:bind KP0+!KP1 MENU_LAST_ITEM instead use the backslashed versions \?, \+, \{,
/etc/brltty/Keyboard/keypad.ktb:bind KP0+!KP9 MENU_PREV_SETTING \|, \(, and \).
/etc/brltty/Keyboard/keypad.ktb:bind KP0+!KP3 MENU_NEXT_SETTING
/etc/brltty/Keyboard/keypad.ktb:bind KP0+!KP5 MENU_PREV_LEVEL
/etc/brltty/Keyboard/keypad.ktb:bind KP0+!KPEnter PREFMENU
/etc/brltty/Keyboard/keypad.ktb:bind KP0+!KPPlus PREFSAVE
/etc/brltty/Keyboard/keypad.ktb:bind KP0+!KPMinus PREFLOAD
grep: /etc/libvirt: Permission denied
grep: /etc/wpa_supplicant/wpa_supplicant.conf: Permission denied
/etc/mime.types:application/vnd.d2l.coursepackage1p0+zip
grep: /etc/sudo-ldap.conf: Permission denied
grep: /etc/sudo.conf: Permission denied
grep: /etc/sudoers: Permission denied
grep: /etc/sudoers.d: Permission denied
grep: /etc/iscsi/iscsid.conf: Permission denied
/etc/sane.d/mustek_pp.conf:# - cis1200+ (for Mustek 1200CP+
& OEM versions),
/etc/sane.d/mustek_pp.conf:# scanner Mustek-1200CP+ 0x378 cis1200+
/etc/sane.d/mustek_pp.conf:# scanner mustek-cis1200+ * cis1200+
/etc/sane.d/teco1.conf:scsi "RELISYS" "VM3530+" Scanner * * * 0
+: Match The Previous Element 1 Or More Times

>_

$ grep -r '0\+' /etc/


/etc/pnm2ppa.conf:# The setting is correct when alignments "0" are
correct.
/etc/pnm2ppa.conf:#colorshear 0
/etc/pnm2ppa.conf:#blackshear 0
/etc/pnm2ppa.conf:# 0 = no black ink. This affects black ink bordered by
whitespace
/etc/pnm2ppa.conf:# (i.e., 256 times ( i*(1.0/256)) to the power Gamma ),
/etc/pnm2ppa.conf:# where (int) i is the ppm color intensity, in the range
0 - 255.
/etc/pnm2ppa.conf:# the corresponding color. Gamma = 1.0 corresponds to
no
/etc/pnm2ppa.conf:#GammaR 1.0 # red enhancement
/etc/pnm2ppa.conf:#GammaG 1.0 # green enhancement
/etc/pnm2ppa.conf:#GammaB 1.0 # blue enhancement
/etc/pnm2ppa.conf:# which gives Gamma = 1.0 - 0.033 * GammaIdx :
/etc/pnm2ppa.conf:#RedGammaIdx 0
/etc/pnm2ppa.conf:#GreenGammaIdx 0
/etc/pnm2ppa.conf:#BlueGammaIdx 0
/etc/pnm2ppa.conf:# by default the printing sweeps are now bidirectional
(unimode 0);
/etc/pnm2ppa.conf:# set their values to 0 to switch off the corresponding
ink type:
/etc/subuid-:aaron:100000:65536
/etc/subuid-:charles:231072:65536
Extended Regular Expressions

>_

$ grep -Er '0+' /etc/ $ egrep r '0+' /etc/


/etc/pnm2ppa.conf:# The setting is correct when alignments "0" are
correct.
/etc/pnm2ppa.conf:#colorshear 0
/etc/pnm2ppa.conf:#blackshear 0
/etc/pnm2ppa.conf:# 0 = no black ink. This affects black ink bordered by
whitespace
/etc/pnm2ppa.conf:# (i.e., 256 times ( i*(1.0/256)) to the power Gamma ),
/etc/pnm2ppa.conf:# where (int) i is the ppm color intensity, in the range
0 - 255.
/etc/pnm2ppa.conf:# the corresponding color. Gamma = 1.0 corresponds to
no
/etc/pnm2ppa.conf:#GammaR 1.0 # red enhancement
/etc/pnm2ppa.conf:#GammaG 1.0 # green enhancement
/etc/pnm2ppa.conf:#GammaB 1.0 # blue enhancement
/etc/pnm2ppa.conf:# which gives Gamma = 1.0 - 0.033 * GammaIdx :
/etc/pnm2ppa.conf:#RedGammaIdx 0
/etc/pnm2ppa.conf:#GreenGammaIdx 0
/etc/pnm2ppa.conf:#BlueGammaIdx 0
/etc/pnm2ppa.conf:# by default the printing sweeps are now bidirectional
(unimode 0);
/etc/pnm2ppa.conf:# set their values to 0 to switch off the corresponding
ink type:
/etc/subuid-:aaron:100000:65536
/etc/subuid-:charles:231072:65536
{}: Previous Element Can Exist “this many” Times

>_

$ egrep -r '0{3,}' /etc/


000/09/xmldsig#
/etc/vmware-tools/vgauth/schemas/xmldsig-core-schema.xsd: [2]
http://www.w3.org/Consortium/Legal/IPR-FAQ-20000620.html#DTD
/etc/vmware-tools/vgauth/schemas/xmldsig-core-schema.xsd:<schema
xmlns="http://www.w3.org/2001/XMLSchema"
xmlns:ds="http://www.w3.org/2000/09/xmldsig#"
targetNamespace="http://www.w3.org/2000/09/xmldsig#" version="0.1"
elementFormDefault="qualified">
grep: /etc/firewalld: Permission denied
/etc/smartmontools/smartd.conf:# Monitor 4 ATA disks connected to a 3ware
6/7/8000 controller which uses
/etc/smartmontools/smartd.conf:# Monitor 2 ATA disks connected to a 3ware
9000 controller which
/etc/smartmontools/smartd.conf:# Monitor 2 SATA (not SAS) disks connected
to a 3ware 9000 controller which
/etc/nanorc:## of tabs and spaces. 187 in ISO 8859-1 (0000BB in Unicode)
and 183 in
/etc/nanorc:## ISO-8859-1 (0000B7 in Unicode) seem to be good values for
these.
/etc/pbm2ppa.conf:# Sample configuration file for the HP720/HP820/HP1000
PPA Printers
/etc/pbm2ppa.conf:# 1000: HP DeskJet 1000Cse,
1000Cxi
{}: Previous Element Can Exist “this many” Times

>_
$ egrep -r '10{,3}' /etc/
/etc/pnm2ppa.conf:#xoffset 160
/etc/pnm2ppa.conf:# sweeps of the print head, adjust these in units of
1"/600 (1 dot).
/etc/pnm2ppa.conf:# valid blackness choices are 1 2 3 4; controls the
/etc/pnm2ppa.conf:# density of black ink used: 1 (least ink), 2 (default),
4 (most).
/etc/pnm2ppa.conf:# (i.e., 256 times ( i*(1.0/256)) to the power Gamma ),
/etc/pnm2ppa.conf:# the corresponding color. Gamma = 1.0 corresponds to
no
/etc/pnm2ppa.conf:#GammaR 1.0 # red enhancement
/etc/pnm2ppa.conf:#GammaG 1.0 # green enhancement
/etc/pnm2ppa.conf:#GammaB 1.0 # blue enhancement
/etc/pnm2ppa.conf:# which gives Gamma = 1.0 - 0.033 * GammaIdx :
/etc/pnm2ppa.conf:# (unimode 1) uncomment the next line . (The command
line options --uni
/etc/pnm2ppa.conf:#unimode 1
/etc/pnm2ppa.conf:#black_ink 1
/etc/pnm2ppa.conf:#color_ink 1
/etc/pnm2ppa.conf:#cyan_ink 1
/etc/pnm2ppa.conf:#magenta_ink 1
/etc/pnm2ppa.conf:#yellow_ink 1
/etc/subuid-:aaron:100000:65536
/etc/subuid-:bob:165536:65536
/etc/subuid-:charles:231072:65536
{}: Previous Element Can Exist “this many” Times

>_
$ egrep -r '0{3}' /etc/
/etc/vmware-tools/vgauth/schemas/xmldsig-core-schema.xsd: [2]
http://www.w3.org/Consortium/Legal/IPR-FAQ-20000620.html#DTD
/etc/vmware-tools/vgauth/schemas/xmldsig-core-schema.xsd:<schema
xmlns="http://www.w3.org/2001/XMLSchema"
xmlns:ds="http://www.w3.org/2000/09/xmldsig#"
targetNamespace="http://www.w3.org/2000/09/xmldsig#" version="0.1"
elementFormDefault="qualified">
grep: /etc/firewalld: Permission denied
/etc/smartmontools/smartd.conf:# Monitor 4 ATA disks connected to a 3ware
6/7/8000 controller which uses
/etc/smartmontools/smartd.conf:# Monitor 2 ATA disks connected to a 3ware
9000 controller which
/etc/smartmontools/smartd.conf:# Monitor 2 SATA (not SAS) disks connected
to a 3ware 9000 controller which
/etc/nanorc:## of tabs and spaces. 187 in ISO 8859-1 (0000BB in Unicode)
and 183 in
/etc/nanorc:## ISO-8859-1 (0000B7 in Unicode) seem to be good values for
these.
/etc/pbm2ppa.conf:# Sample configuration file for the HP720/HP820/HP1000
PPA Printers
/etc/pbm2ppa.conf:# 1000: HP DeskJet 1000Cse,
1000Cxi
/etc/pbm2ppa.conf:#version 1000
/etc/pnm2ppa.conf:#version 1000
/etc/subuid-:aaron:100000:65536
?: Make The Previous Element Optional

>_
$ egrep -r 'disabled?' /etc/
t to 0 to disable polling.
/etc/vmware-tools/tools.conf.example:# Set to true to disable the
deviceHelper plugin.
/etc/vmware-tools/tools.conf.example:#disabled=false
/etc/containers/storage.conf:# Value 0% disables
/etc/dleyna-server-service.conf:# 0 = disabled
/etc/dleyna-server-service.conf:# You can't enable levels disabled at
compile time
/etc/dleyna-server-service.conf:# If netf is enabled but the list is
empty, it behaves as disabled.
/etc/tuned/tuned-main.conf:# Dynamicaly tune devices, if disabled only
static tuning will be used.
/etc/tuned/tuned-main.conf:# Recommend functionality, if disabled
"recommend" command will be not
/etc/enscript.cfg:# Enable / disable page prefeed.
grep: /etc/firewalld: Permission denied
/etc/mcelog/mcelog.conf:# An upstream bug prevents this from being
disabled
/etc/smartmontools/smartd.conf:# -o VAL Enable/disable automatic
offline tests (on/off)
/etc/smartmontools/smartd.conf:# -S VAL Enable/disable attribute
autosave (on/off)
/etc/smartmontools/smartd_warning.sh:# Plugin directory (disabled if
empty)
{}: Previous Element Can Exist “this many” Times

>_
$ egrep -r '0{3,5}' /etc/ 0{min,max}
000/09/xmldsig#
/etc/vmware-tools/vgauth/schemas/xmldsig-core-schema.xsd: [2]
http://www.w3.org/Consortium/Legal/IPR-FAQ-20000620.html#DTD
/etc/vmware-tools/vgauth/schemas/xmldsig-core-schema.xsd:<schema
xmlns="http://www.w3.org/2001/XMLSchema"
xmlns:ds="http://www.w3.org/2000/09/xmldsig#"
targetNamespace="http://www.w3.org/2000/09/xmldsig#" version="0.1"
elementFormDefault="qualified">
grep: /etc/firewalld: Permission denied
/etc/smartmontools/smartd.conf:# Monitor 4 ATA disks connected to a 3ware
6/7/8000 controller which uses
/etc/smartmontools/smartd.conf:# Monitor 2 ATA disks connected to a 3ware
9000 controller which
/etc/smartmontools/smartd.conf:# Monitor 2 SATA (not SAS) disks connected
to a 3ware 9000 controller which
/etc/nanorc:## of tabs and spaces. 187 in ISO 8859-1 (0000BB in Unicode)
and 183 in
/etc/nanorc:## ISO-8859-1 (0000B7 in Unicode) seem to be good values for
these.
/etc/pbm2ppa.conf:# Sample configuration file for the HP720/HP820/HP1000
PPA Printers
/etc/pbm2ppa.conf:# 1000: HP DeskJet 1000Cse,
1000Cxi
|: Match One Thing Or The Other

>_
$ egrep -r 'enabled|disabled' /etc/
/etc/vmware-tools/tools.conf.example:# disabled.
/etc/vmware-tools/tools.conf.example:#disabled=false
/etc/dleyna-server-service.conf:# 0 = disabled
/etc/dleyna-server-service.conf:# You can't enable levels disabled at
compile time
/etc/dleyna-server-service.conf:netf-enabled=false
/etc/dleyna-server-service.conf:# If netf is enabled but the list is
empty, it behaves as disabled.
/etc/tuned/tuned-main.conf:# Dynamicaly tune devices, if disabled only
static tuning will be used.
/etc/tuned/tuned-main.conf:# Recommend functionality, if disabled
"recommend" command will be not
/etc/tuned/tuned-main.conf:# /etc/sysctl.conf. If enabled, these sysctls
will be re-appliead
grep: /etc/firewalld: Permission denied
/etc/mcelog/mcelog.conf:# An upstream bug prevents this from being
disabled
/etc/mcelog/mcelog.conf:dimm-tracking-enabled = yes
/etc/mcelog/mcelog.conf:socket-tracing-enabled = yes
/etc/smartmontools/smartd_warning.sh:# Plugin directory (disabled if
empty)
/etc/nanorc:## To make sure an option is disabled, use "unset <option>".
|: Match One Thing Or The Other

>_
$ egrep -ir 'enabled?|disabled?' /etc/
grep: /etc/firewalld: Permission denied
/etc/mcelog/mcelog.conf:# An upstream bug prevents this from being
disabled
/etc/mcelog/mcelog.conf:# Enable DIMM-tracking
/etc/mcelog/mcelog.conf:dimm-tracking-enabled = yes
/etc/mcelog/mcelog.conf:# Disable DIMM DMI pre-population unless supported
on your system
/etc/mcelog/mcelog.conf:socket-tracing-enabled = yes
/etc/smartmontools/smartd.conf:# First ATA/SATA or SCSI/SAS disk. Monitor
all attributes, enable
/etc/smartmontools/smartd.conf:# -o VAL Enable/disable automatic
offline tests (on/off)
/etc/smartmontools/smartd.conf:# -S VAL Enable/disable attribute
autosave (on/off)
/etc/smartmontools/smartd_warning.sh:# Plugin directory (disabled if
empty)
/etc/nanorc:## Please note that you must have configured nano with --
enable-nanorc
/etc/nanorc:## To make sure an option is disabled, use "unset <option>".
/etc/nanorc:## When soft line wrapping is enabled, make it wrap lines at
blanks
/etc/nanorc:## Enable vim-style lock-files. This is just to let a vim
user know you
[]: Ranges Or Sets

>_
$ egrep -r 'c[au]t' /etc/ [a-z] [0-9] [abz954]
/etc/man_db.conf:# Range of terminal widths permitted when displaying cat
pages. If the
/etc/man_db.conf:# terminal falls outside this range, cat pages will not
be created (if
/etc/man_db.conf:# If CATWIDTH is set to a non-zero number, cat pages will
always be
/etc/man_db.conf:# NOCACHE keeps man from creating cat pages.
/etc/nanorc:## Use cut-from-cursor-to-end-of-line by default.
/etc/nanorc:# set cutfromcursor
/etc/nanorc:## (The old form, 'cut', is deprecated.)
/etc/nanorc:## double click), and execute shortcuts. The mouse will work
in the X
/etc/nanorc:## Don't display the helpful shortcut lists at the bottom of
the screen.
/etc/nanorc:## (The old form, 'justifytrim', is deprecated.)
/etc/nanorc:## Disallow file modification. Why would you want this in an
rcfile? ;)
/etc/nanorc:# bind M-B cutwordleft main
/etc/nanorc:# bind M-N cutwordright main
/etc/mailcap:application/msword; /usr/bin/xdg-open %s
/etc/mailcap:application/pdf; /usr/bin/xdg-open %s
/etc/mailcap:application/postscript ; /usr/bin/xdg-open %s
[]: Ranges Or Sets

>_
$ egrep -r '/dev/.*' /etc/
/etc/smartmontools/smartd.conf:#/dev/twa0 -d 3ware,1 -a -s L/../../2/03
/etc/smartmontools/smartd.conf:# On FreeBSD /dev/tws0 should be used
instead
/etc/smartmontools/smartd.conf:#/dev/twl0 -d 3ware,0 -a -s L/../../2/01
/etc/smartmontools/smartd.conf:#/dev/twl0 -d 3ware,1 -a -s L/../../2/03
/etc/smartmontools/smartd.conf:#/dev/hdc,0 -a -s L/../../2/01
/etc/smartmontools/smartd.conf:#/dev/hdc,1 -a -s L/../../2/03
/etc/smartmontools/smartd.conf:#/dev/sdd -d hpt,1/1 -a -s L/../../7/01
/etc/smartmontools/smartd.conf:#/dev/sdd -d hpt,1/2 -a -s L/../../7/02
/etc/smartmontools/smartd.conf:#/dev/sdd -d hpt,1/3 -a -s L/../../7/03
/etc/smartmontools/smartd.conf:#/dev/sdd -d hpt,1/4/1 -a -s L/../../2/01
/etc/smartmontools/smartd.conf:#/dev/sdd -d hpt,1/4/2 -a -s L/../../2/03
/etc/smartmontools/smartd_warning.sh: hostname=`eval $cmd 2>/dev/null` ||
continue
/etc/smartmontools/smartd_warning.sh: dnsdomain=`eval $cmd 2>/dev/null`
|| continue
/etc/smartmontools/smartd_warning.sh: nisdomain=`eval $cmd 2>/dev/null`
|| continue
/etc/smartmontools/smartd_warning.sh: echo "$cmd </dev/null"
/etc/smartmontools/smartd_warning.sh: "$cmd" </dev/null
/etc/smartmontools/smartd_warning.sh: echo "$cmd </dev/null"
/etc/smartmontools/smartd_warning.sh: "$cmd" </dev/null
/etc/smartmontools/smartd_warning.sh: echo "exec '$SMARTD_MAILER'
</dev/null"
[]: Ranges Or Sets

>_
$ egrep -r '/dev/[a-z]*' /etc/
/etc/smartmontools/smartd.conf:#/dev/twa0 -d 3ware,1 -a -s L/../../2/03
/etc/smartmontools/smartd.conf:# On FreeBSD /dev/tws0 should be used instead
/etc/smartmontools/smartd.conf:#/dev/twl0 -d 3ware,0 -a -s L/../../2/01
/etc/smartmontools/smartd.conf:#/dev/twl0 -d 3ware,1 -a -s L/../../2/03
/etc/smartmontools/smartd.conf:#/dev/hdc,0 -a -s L/../../2/01
/etc/smartmontools/smartd.conf:#/dev/hdc,1 -a -s L/../../2/03
/etc/smartmontools/smartd.conf:#/dev/sdd -d hpt,1/1 -a -s L/../../7/01
/etc/smartmontools/smartd.conf:#/dev/sdd -d hpt,1/2 -a -s L/../../7/02
/etc/smartmontools/smartd.conf:#/dev/sdd -d hpt,1/3 -a -s L/../../7/03
/etc/smartmontools/smartd.conf:#/dev/sdd -d hpt,1/4/1 -a -s L/../../2/01
/etc/smartmontools/smartd.conf:#/dev/sdd -d hpt,1/4/2 -a -s L/../../2/03
/etc/smartmontools/smartd_warning.sh: hostname=`eval $cmd 2>/dev/null` || continue
/etc/smartmontools/smartd_warning.sh: dnsdomain=`eval $cmd 2>/dev/null` || continue
/etc/smartmontools/smartd_warning.sh: nisdomain=`eval $cmd 2>/dev/null` || continue
/etc/smartmontools/smartd_warning.sh: echo "$cmd </dev/null"
/etc/smartmontools/smartd_warning.sh: "$cmd" </dev/null
/etc/smartmontools/smartd_warning.sh: echo "$cmd </dev/null"
/etc/smartmontools/smartd_warning.sh: "$cmd" </dev/null
/etc/smartmontools/smartd_warning.sh: echo "exec '$SMARTD_MAILER' </dev/null"
[]: Ranges Or Sets

>_
$ egrep -r '/dev/[a-z]*[0-9]' /etc/
/etc/sane.d/umax_pp.conf:# /dev/ppi1, ...
/etc/sane.d/fujitsu.conf:#scsi /dev/sg1
/etc/sane.d/v4l.conf:/dev/bttv0
/etc/sane.d/v4l.conf:/dev/video0
/etc/sane.d/v4l.conf:/dev/video1
/etc/sane.d/v4l.conf:/dev/video2
/etc/sane.d/v4l.conf:/dev/video3
/etc/sane.d/gphoto2.conf:port=serial:/dev/ttyd1
/etc/sane.d/kodak.conf:#scsi /dev/sg1
/etc/sane.d/ma1509.conf:#/dev/uscanner0
/etc/sane.d/mustek_usb.conf:#/dev/usbscanner0
/etc/sane.d/snapscan.conf:# For SCSI scanners specify the generic device, e.g. /dev/sg0 on Linux.
/etc/sane.d/snapscan.conf:# /dev/sg0
grep: /etc/firewalld: Permission denied
/etc/smartmontools/smartd.conf:# For example /dev/twe0, /dev/twe1, and so on.
/etc/smartmontools/smartd.conf:#/dev/twa0 -d 3ware,0 -a -s L/../../2/01
/etc/smartmontools/smartd.conf:#/dev/twa0 -d 3ware,1 -a -s L/../../2/03
/etc/smartmontools/smartd.conf:# On FreeBSD /dev/tws0 should be used instead
/etc/smartmontools/smartd.conf:#/dev/twl0 -d 3ware,0 -a -s L/../../2/01
/etc/smartmontools/smartd.conf:#/dev/twl0 -d 3ware,1 -a -s L/../../2/03
[]: Ranges Or Sets

>_
$ egrep -r '/dev/[a-z]*[0-9]?' /etc/
/etc/smartmontools/smartd.conf:#/dev/twa0 -d 3ware,1 -a -s L/../../2/03
/etc/smartmontools/smartd.conf:# On FreeBSD /dev/tws0 should be used instead
/etc/smartmontools/smartd.conf:#/dev/twl0 -d 3ware,0 -a -s L/../../2/01
/etc/smartmontools/smartd.conf:#/dev/twl0 -d 3ware,1 -a -s L/../../2/03
/etc/smartmontools/smartd.conf:#/dev/hdc,0 -a -s L/../../2/01
/etc/smartmontools/smartd.conf:#/dev/hdc,1 -a -s L/../../2/03
/etc/smartmontools/smartd.conf:#/dev/sdd -d hpt,1/1 -a -s L/../../7/01
/etc/smartmontools/smartd.conf:#/dev/sdd -d hpt,1/2 -a -s L/../../7/02
/etc/smartmontools/smartd.conf:#/dev/sdd -d hpt,1/3 -a -s L/../../7/03
/etc/smartmontools/smartd.conf:#/dev/sdd -d hpt,1/4/1 -a -s L/../../2/01
/etc/smartmontools/smartd.conf:#/dev/sdd -d hpt,1/4/2 -a -s L/../../2/03
/etc/smartmontools/smartd_warning.sh: hostname=`eval $cmd 2>/dev/null` || continue
/etc/smartmontools/smartd_warning.sh: dnsdomain=`eval $cmd 2>/dev/null` || continue
/etc/smartmontools/smartd_warning.sh: nisdomain=`eval $cmd 2>/dev/null` || continue
/etc/smartmontools/smartd_warning.sh: echo "$cmd </dev/null"
/etc/smartmontools/smartd_warning.sh: "$cmd" </dev/null
/etc/smartmontools/smartd_warning.sh: echo "$cmd </dev/null"
/etc/smartmontools/smartd_warning.sh: "$cmd" </dev/null
/etc/smartmontools/smartd_warning.sh: echo "exec '$SMARTD_MAILER' </dev/null"
(): Subexpressions

>_
$ egrep -r '/dev/[a-z]*[0-9]?' /etc/
/etc/sane.d/dc25.conf:#port=/dev/tty0p0
/etc/sane.d/dc25.conf:#port=/dev/tty01
/etc/sane.d/u12.conf:# device /dev/usbscanner
/etc/sane.d/u12.conf:# device /dev/usbscanner
1+2*3
/etc/sane.d/dmc.conf:/dev/camera
/etc/sane.d/umax.conf:/dev/scanner
/etc/sane.d/umax.conf:/dev/usbscanner
1+6 = 7
/etc/sane.d/epjitsu.conf:#usb /dev/usb/scanner0
/etc/sane.d/epjitsu.conf:#
'\.nal$' - 2>/dev/null; then
if echo "$nal" | grep -q
(1+2)*3
/etc/sane.d/epson.conf:#usb /dev/usbscanner0
/etc/sane.d/epson.conf:#usb /dev/usb/scanner0
/etc/sane.d/umax1220u.conf:#/dev/scanner
3*3 = 9
/etc/sane.d/umax1220u.conf:#/dev/usb/scanner0
/etc/sane.d/umax_pp.conf:# device : /dev/parport0, /dev/parport1, ......
/etc/sane.d/umax_pp.conf:# on *BSD, you may provide the device name of the
ppi device: /dev/ppi0,
/etc/sane.d/umax_pp.conf:# /dev/ppi1, ...
/etc/sane.d/fujitsu.conf:#scsi /dev/sg1
/etc/sane.d/fujitsu.conf:#usb /dev/usb/scanner0
/etc/sane.d/v4l.conf:/dev/bttv0
/etc/sane.d/v4l.conf:/dev/video0
/etc/sane.d/v4l.conf:/dev/video1
/etc/sane.d/v4l.conf:/dev/video2
(): Subexpressions

>_
$ egrep -r '/dev/([a-z]*[0-9]?)*' /etc/
/etc/sane.d/coolscan3.conf:#scsi:/dev/scanner
/etc/sane.d/coolscan3.conf:#usb:/dev/usbscanner
/etc/sane.d/dc210.conf:port=/dev/ttyS0
/etc/sane.d/dc210.conf:#port=/dev/ttyd1
/etc/sane.d/dc210.conf:#port=/dev/term/a [a-z]*[0-9]?
/etc/sane.d/dc210.conf:#port=/dev/tty0p0
/etc/sane.d/dc210.conf:#port=/dev/tty01 tty0p0
/etc/sane.d/dc240.conf:port=/dev/ttyS0
/etc/sane.d/dc240.conf:#port=/dev/ttyd1
/etc/sane.d/dc240.conf:#port=/dev/term/a
/etc/sane.d/dc240.conf:#port=/dev/tty0p0
/etc/sane.d/dc240.conf:#port=/dev/tty01
/etc/sane.d/dc25.conf:port=/dev/ttyS0
/etc/sane.d/dc25.conf:#port=/dev/ttyd1
/etc/sane.d/dc25.conf:#port=/dev/term/a
/etc/sane.d/dc25.conf:#port=/dev/tty0p0
/etc/sane.d/dc25.conf:#port=/dev/tty01
/etc/sane.d/u12.conf:# device /dev/usbscanner
/etc/sane.d/u12.conf:# device /dev/usbscanner
/etc/sane.d/dmc.conf:/dev/camera
/etc/sane.d/umax.conf:/dev/scanner
/etc/sane.d/umax.conf:/dev/usbscanner
(): Subexpressions

>_
$ egrep -r egrep -r '/dev/(([a-z]|[A-Z])*[0-9]?)*' /etc/
/etc/sane.d/coolscan3.conf:#scsi:/dev/scanner
/etc/sane.d/coolscan3.conf:#usb:/dev/usbscanner
/etc/sane.d/dc210.conf:port=/dev/ttyS0
/etc/sane.d/dc210.conf:#port=/dev/ttyd1
/etc/sane.d/dc210.conf:#port=/dev/term/a
/etc/sane.d/dc210.conf:#port=/dev/tty0p0
/etc/sane.d/dc210.conf:#port=/dev/tty01
/etc/sane.d/dc240.conf:port=/dev/ttyS0
([a-z]|[A-Z]*[0-9]?)*
/etc/sane.d/dc240.conf:#port=/dev/ttyd1
/etc/sane.d/dc240.conf:#port=/dev/term/a
/etc/sane.d/dc240.conf:#port=/dev/tty0p0
/etc/sane.d/dc240.conf:#port=/dev/tty01
/etc/sane.d/dc25.conf:port=/dev/ttyS0
/etc/sane.d/dc25.conf:#port=/dev/ttyd1
/etc/sane.d/dc25.conf:#port=/dev/term/a
/etc/sane.d/dc25.conf:#port=/dev/tty0p0
/etc/sane.d/dc25.conf:#port=/dev/tty01
/etc/sane.d/u12.conf:# device /dev/usbscanner
/etc/sane.d/u12.conf:# device /dev/usbscanner
/etc/sane.d/dmc.conf:/dev/camera
/etc/sane.d/umax.conf:/dev/scanner
/etc/sane.d/umax.conf:/dev/usbscanner
[^]: Negated Ranges Or Sets

>_
$ egrep –r 'http[^s]' /etc/
/etc/containers/registries.conf.d/001-rhel-
shortnames.conf:"openshift4/ose-egress-http-proxy" =
"registry.redhat.io/openshift4/ose-egress-http-proxy"
/etc/containers/registries.conf.d/001-rhel-shortnames.conf:"rhel8/httpd-
24" = "registry.redhat.io/rhel8/httpd-24"
/etc/containers/registries.conf.d/001-rhel-shortnames.conf:"rhscl/httpd-
24-rhel7" = "registry.access.redhat.com/rhscl/httpd-24-rhel7" [abc123]
/etc/containers/registries.conf.d/001-rhel-shortnames.conf:"ubi8/httpd-24"
= "registry.redhat.io/ubi8/httpd-24" [a-z]
/etc/containers/registries.d/default.yaml:# For reading signatures, schema
may be http, https, or file.
/etc/containers/registries.d/default.yaml:#
http://privateregistry.com/sigstore/
sigstore: http[^s] http https
/etc/wgetrc:# You can set the default proxies for Wget to use for http,
https, and ftp.
/etc/wgetrc:#https_proxy = http://proxy.yoyodyne.com:18023/
/etc/wgetrc:#http_proxy = http://proxy.yoyodyne.com:18023/
/etc/wgetrc:#ftp_proxy = http://proxy.yoyodyne.com:18023/
/etc/enscript.cfg:# along with Enscript. If not, see
<http://www.gnu.org/licenses/>.
grep: /etc/firewalld: Permission denied
/etc/smartmontools/smartd.conf:# Home page is:
http://www.smartmontools.org
[^]: Negated Ranges Or Sets

>_
$ egrep –r '/[^a-z]' /etc/ https://regexr.com
/etc/smartmontools/smartd_warning.sh: cmd="$plugindir/${ad#@}"
/etc/qemu-ga/fsfreeze-hook:for file in "$FSFREEZE_D"/* ; do
/etc/man_db.conf:MANPATH_MAP /usr/X11R6/bin /usr/X11R6/man
/etc/man_db.conf:MANPATH_MAP /usr/bin/X11 /usr/X11R6/man
/etc/man_db.conf:MANDB_MAP /usr/X11R6/man /var/cache/man/X11R6
/etc/nanorc:## Each user can save his own configuration to ~/.nanorc
/etc/nanorc:## Don't convert files from DOS/Mac format.
/etc/nanorc:# set quotestr "^([ ]*([#:>|}]|//))+"
/etc/nanorc:## Fix Backspace/Delete confusion problem.
/etc/nanorc:include "/usr/share/nano/*.nanorc"
/etc/pbm2ppa.conf:# Sample configuration file for the HP720/HP820/HP1000 PPA Printers
/etc/pbm2ppa.conf:# 1/4 inch margins all around (at 600 DPI)
/etc/pbm2ppa.conf:# 1/4 inch margins all around (at 600 DPI)
/etc/pbm2ppa.conf:# 1/4 inch margins all around (at 600 DPI)
/etc/pnm2ppa.conf:# paper. Units are dots (1/600 inch). Add a positive number of dots to
/etc/pnm2ppa.conf:# sweeps of the print head, adjust these in units of 1"/600 (1 dot).
/etc/pnm2ppa.conf:# gEnh(i) = (int) ( pow ( (double) i / 256, Gamma ) * 256 )
Compress and Decompress Files
Compression And Decompression Utilities

>_
$ gzip file1 $ gunzip file1.gz gzip --decompress file1.gz
file1.gz file1

$ bzip2 file2 $ bunzip file2.bz2 bzip2 --decompress file2.bz2


file2.bz2 file2

$ xz file3 $ unxz file3.xz xz --decompress file3.xz


file3.bz2 file3

5 MB
50 MB file1
file1.gz

5 MB
50 MB file1
file1.gz
Compression And Decompression Utilities

>_
$ gzip --help $ gzip --keep file1
Usage: gzip [OPTION]... [FILE]...
file1 file1.gz
Compress or uncompress FILEs (by default, compress FILES in-place).

Mandatory arguments to long options are mandatory for short options too.
$ bzip2 --keep file2
-c, --stdout write on standard output, keep original files unchanged file2 file2.bz2
-d, --decompress decompress
-f, --force force overwrite of output file and compress links
-h, --help give this help
-k, --keep keep (don't delete) input files $ xz --keep file3
-l, --list list compressed file contents
-L, --license display software license file3 file3.xz
-n, --no-name do not save or restore the original name and timestamp
-N, --name save or restore the original name and timestamp
-q, --quiet suppress all warnings
-r, --recursive operate recursively on directories $ gzip --list file1
--rsyncable make rsync-friendly archive compressed uncompressed ratio name
-S, --suffix=SUF use suffix SUF on compressed files 71 78 39.7% file1
--synchronous synchronous output
-t, --test test compressed file integrity
-v, --verbose verbose mode
-V, --version display version number
Compression And Decompression Utilities

>_

$ zip archive file1 $ zip archive.zip file1


adding: file1 (deflated 40%)

$ zip –r archive.zip Pictures/ -r = recursively


adding: Pictures/ (stored 0%)
adding: Pictures/family_dog.jpg (stored 0%)

$ unzip archive.zip
Archive: archive.zip
replace file1? [y]es, [n]o, [A]ll, [N]one, [r]ename: N
Compression And Decompression With tar

>_
$ tar --create --file archive.tar file1

$ gzip archive.tar
archive.tar.gz

$ gzip --keep archive.tar


archive.tar archive.tar.gz

$ tar --create –-gzip --file archive.tar.gz file1 $ tar czf archive.tar.gz file1
$ tar --create –-bzip2 --file archive.tar.bz2 file1 $ tar cjf archive.tar.bz2 file1

$ tar --create –-xz --file archive.tar.xz file1 $ tar cJf archive.tar.xz file1
$ tar --create –-autocompress --file archive.tar.gz file1
$ tar caf archive.xz file1
$ tar --extract --file archive.tar.gz
$ tar xf archive.tar.gz file1
Backup to a Remote System
Syncing Two Directories

>_
rsync = remote synchronization
$ rsync –a Pictures/ [email protected]:/home/aaron/Pictures/
Remote Server
/home/aaron/Pictures

$ rsync –a [email protected]:/home/aaron/Pictures/ Pictures/

SSH daemon

$ rsync –a Pictures/ /Backups/Pictures/

Local Server
Pictures/
Disk Imaging

>_

$ sudo dd if=/dev/vda of=diskimage.raw bs=1M status=progress

1340080128 bytes (1.3GB, 1.2GB) copied, 3s, 432 MB/s

$ sudo dd if=diskimage.raw of=/dev/vda bs=1M status=progress

1340080128 bytes (1.3GB, 1.2GB) copied, 3s, 432 MB/s


Redirecting Input and Output
Redirecting Output

>_
$ cat file.txt
6
5
1
3
4
2

$ sort file.txt
1
2
3
4
5
6

$ sort file.txt > sortedfile.txt > file_name #Redirect Output


$ cat sortedfile.txt
1
2
3
4
5
6
Redirecting Output

>_

$ date
Mon Nov 8 18:50:25 CST 2021

$ date > file.txt

$ date > file.txt

$ date > file.txt

$ date > file.txt

$ date > file.txt > file_name #Redirect & Overwrite

$ cat file.txt
Mon Nov 8 18:50:30 CST 2021
Redirecting Output

>_

$ date >> file.txt

$ date >> file.txt

$ date >> file.txt


$ date >> file.txt

$ date >> file.txt >> file_name #Redirect & Append

$ cat file.txt
Mon Nov 8 18:50:30 CST 2021
Mon Nov 8 18:50:31 CST 2021
Mon Nov 8 18:50:32 CST 2021
Mon Nov 8 18:50:33 CST 2021
Mon Nov 8 18:50:34 CST 2021
Mon Nov 8 18:50:35 CST 2021
Redirecting Output

>_

date > file.txt

date 1> file.txt


stdin, stdout, and stderr

stdin
< terminal
standard input
file.txt sort

errors.txt

<file.txt 2>errors.txt >file.txt or 1>file.txt


Redirecting Errors

>_
$ grep –r '^The' /etc/ $ grep –r '^The' /etc/ 2>/dev/null
grep: /etc/cups/ssl: Permission denied /etc/brltty/Input/tn/all.txt:The two keys at the left
grep: /etc/cups/subscriptions.conf.O: Permission denied rear (2 columns, 1 row):
grep: /etc/cups/subscriptions.conf: Permission denied /etc/brltty/Input/tn/all.txt:The four keys at the left
grep: /etc/ssh/sshd_config: Permission denied middle (cross):
grep: /etc/chrony.keys: Permission denied /etc/brltty/Input/tn/all.txt:The six keys at the left
grep: /etc/brlapi.key: Permission denied front (2 columns, 3 row):
/etc/brltty/Input/tn/all.txt:The two keys at the left /etc/brltty/Input/tn/all.txt:The one key at the right
rear (2 columns, 1 row): rear (1 column, 1 row):
/etc/brltty/Input/tn/all.txt:The four keys at the left /etc/brltty/Input/tn/all.txt:The two keys at the right
middle (cross): rear (1 column, 2 rows):
/etc/brltty/Input/tn/all.txt:The six keys at the left /etc/brltty/Input/tn/all.txt:The four keys at the right
front (2 columns, 3 row): rear (1 column, 4 rows):
/etc/brltty/Input/tn/all.txt:The one key at the right /etc/brltty/Input/tn/all.txt:The twelve keys of the
rear (1 column, 1 row): numeric pad (3 columns, 4 rows):
/etc/brltty/Input/tn/all.txt:The two keys at the right
rear (1 column, 2 rows):
/etc/brltty/Input/tn/all.txt:The four keys at the right
rear (1 column, 4 rows):
/etc/brltty/Input/tn/all.txt:The twelve keys of the
numeric pad (3 columns, 4 rows):
grep: /etc/libvirt: Permission denied
grep: /etc/wpa_supplicant/wpa_supplicant.conf:
Permission denied
grep: /etc/sudo-ldap.conf: Permission denied
Redirecting Output

>_
$ grep –r '^The' /etc/ 1>output.txt 2>errors.txt overwrite

$ grep –r '^The' /etc/ 1>>output.txt 2>>errors.txt append


Redirecting Output

>_
$ grep –r '^The' /etc/ $ grep –r '^The' /etc/ > all_output.txt 2>&1
grep: /etc/cups/ssl: Permission denied
grep: /etc/cups/subscriptions.conf.O: Permission denied
grep: /etc/cups/subscriptions.conf: Permission denied
$ grep –r '^The' /etc/ 1>all_output.txt 2>&1
grep: /etc/ssh/sshd_config: Permission denied
grep: /etc/chrony.keys: Permission denied $ grep –r '^The' /etc/ 2>&1 1>all_output.txt
grep: /etc/brlapi.key: Permission denied
/etc/brltty/Input/tn/all.txt:The two keys at the left grep: /etc/cups/classes.conf: Permission denied
rear (2 columns, 1 row): grep: /etc/cups/cups-files.conf: Permission denied
/etc/brltty/Input/tn/all.txt:The four keys at the left grep: /etc/cups/cups-files.conf.default: Permission denied
middle (cross): grep: /etc/cups/cupsd.conf: Permission denied
/etc/brltty/Input/tn/all.txt:The six keys at the left grep: /etc/cups/cupsd.conf.default: Permission denied
front (2 columns, 3 row): grep: /etc/cups/printers.conf: Permission denied
/etc/brltty/Input/tn/all.txt:The one key at the right grep: /etc/cups/snmp.conf.default: Permission denied
rear (1 column, 1 row): grep: /etc/cups/ssl: Permission denied
/etc/brltty/Input/tn/all.txt:The two keys at the right grep: /etc/cups/subscriptions.conf.O: Permission denied
rear (1 column, 2 rows): grep: /etc/cups/subscriptions.conf: Permission denied
/etc/brltty/Input/tn/all.txt:The four keys at the right grep: /etc/ssh/sshd_config: Permission denied
rear (1 column, 4 rows): grep: /etc/ssh/ssh_host_ecdsa_key: Permission denied
/etc/brltty/Input/tn/all.txt:The twelve keys of the grep: /etc/ssh/ssh_host_ed25519_key: Permission denied
numeric pad (3 columns, 4 rows): grep: /etc/ssh/ssh_host_rsa_key: Permission denied
grep: /etc/libvirt: Permission denied grep: /etc/nftables: Permission denied
grep: /etc/wpa_supplicant/wpa_supplicant.conf: grep: /etc/audit: Permission denied
Permission denied grep: /etc/gssproxy/99-nfs-client.conf: Permission denied
grep: /etc/sudo-ldap.conf: Permission denied
Redirecting Input

>_
$ sort file.txt from file

$ sendemail [email protected] from keyboard


Hi Someone,

How are you today?


...
Talk to you soon

Bye

$ sendemail [email protected] < emailcontent.txt from file


Heredoc and Here String

>_

$ sort <<EOF Here document or heredoc


> 6
> 3
> 2
> 5
> 1
> 4
> EOF
1
2
3
4
5
6

$ bc <<<1+2+3+4 Here string


10
Piping

>_

$ grep –v '^#' /etc/login.defs $ grep –v '^#' /etc/login.defs | sort


PASS_MAX_DAYS 99999 CREATE_HOME yes
PASS_MIN_DAYS 0 ENCRYPT_METHOD SHA512
PASS_MIN_LEN 5 GID_MAX 60000
PASS_WARN_AGE 7 GID_MIN 1000
HOME_MODE 0700
UID_MIN 1000 MAIL_DIR /var/spool/mail
UID_MAX 60000 PASS_MAX_DAYS 99999
SYS_UID_MIN 201 PASS_MIN_DAYS 0
SYS_UID_MAX 999 PASS_MIN_LEN 5
PASS_WARN_AGE 7
GID_MIN 1000 SYS_GID_MAX 999
GID_MAX 60000 SYS_GID_MIN 201
SYS_GID_MIN 201 SYS_UID_MAX 999
SYS_GID_MAX 999 SYS_UID_MIN 201
UID_MAX 60000
UID_MIN 1000
CREATE_HOME yes UMASK 022
USERGROUPS_ENAB yes
USERGROUPS_ENAB yes

ENCRYPT_METHOD SHA512
Piping

>_

$ grep –v '^#' /etc/login.defs | sort $ grep –v '^#' /etc/login.defs | sort | column -t


CREATE_HOME yes CREATE_HOME yes
ENCRYPT_METHOD SHA512 ENCRYPT_METHOD SHA512
GID_MAX 60000 GID_MAX 60000
GID_MIN 1000 GID_MIN 1000
HOME_MODE 0700 HOME_MODE 0700
MAIL_DIR /var/spool/mail MAIL_DIR /var/spool/mail
PASS_MAX_DAYS 99999 PASS_MAX_DAYS 99999
PASS_MIN_DAYS 0 PASS_MIN_DAYS 0
PASS_MIN_LEN 5 PASS_MIN_LEN 5
PASS_WARN_AGE 7 PASS_WARN_AGE 7
SYS_GID_MAX 999 SYS_GID_MAX 999
SYS_GID_MIN 201 SYS_GID_MIN 201
SYS_UID_MAX 999 SYS_UID_MAX 999
SYS_UID_MIN 201 SYS_UID_MIN 201
UID_MAX 60000 UID_MAX 60000
UID_MIN 1000 UID_MIN 1000
UMASK 022 UMASK 022
USERGROUPS_ENAB yes USERGROUPS_ENAB yes
Basic File Management: cpio
cpio

>_
cpio Copy In, Copy Out
$ ls | cpio -o > archive.cpio
.cpio or .tar files
$ cpio -id < archive.cpio Copying files to
archives
Extracting files from
archives
Command Substitution
Command Substitution

>_
Command Substitution
$ mkdir `date +%Y+%m+%d` Using the output of one command
as an argument to another
$ ls command.
2022-12-13
Backquotes: `` Normally located
on the same key as ~ on English
$ rmdir 2022-12-13 keyboards

$ mkdir $(date +%Y+%m+%d)


$()

$ ls
2022-12-13

$ OS=`uname -o`

$ echo $OS
GNU/Linux
Command Substitution

>_
$ find /usr/share/icons -name 'debian*' | xargs identify -format "%f: %wx%h\n"
debian-swirl.svg: 48x48
debian-swirl.png: 22x22
debian-swirl.png: 32x32
debian-swirl.png: 256x256
debian-swirl.png: 48x48
debian-swirl.png: 16x16
debian-swirl.png: 24x24
debian-swirl.svg: 48x48

$ find /usr/share/icons -name 'debian*' | xargs -n 1 identify -format "%f: %wx%h\n"

$ find /usr/share/icons -name 'debian*' | xargs -L 3 identify -format "%f: %wx%h\n"


Command Substitution

>_
$ find . -name '*avi' -print0 -name '*mp4' -print0 -name '*mkv' -print0 | xargs -0 du | sort -n

$ find . -mindepth 2 -name '*avi' -print0 -o -name '*mp4' -print0 -o -name '*mkv' -print0 | xargs -0 -I PATH mv PATH ./
Using GNU Screen
Terminal Multiplexers

Multiplexers allow multiple inputs connected to a single output.

Any successful invocation results in at least a session and includes at least


a window. Windows contain programs.

Windows can be split into regions or panes. Increases productivity when using
programs simultaneously.

Ease of control: most commands use a key combination. Consists of a command


prefix and letter.

Sessions can detach from their current terminal.

Provide features like socket connections and copy mode.

Highly customizable.
GNU Screen: Windows

>_ SPACE OR ENTER


$ screen
GNU Screen version 4.05.00 (GNU) 10-Dec-16
Copyright (c) 2010 Juergen Weigert, Sadrul
Habib Chowdhury
Copyright (c) 2008, 2009 Juergen Weigert,
Michael Schroeder, Micah Cowan, Sadrul
Habib Chowdhury
Copyright (c) 1993-2002, 2003, 2005, 2006, 2007
Juergen Weigert, Michael Schroeder
Copyright (c) 1987 Oliver Laumann
(...)

CTRL + a - w
0*$ bash
GNU Screen: Windows

>_ CTRL + a - c
$ ps
PID TTY TIME CMD
974 pts/2 00:00:00 bash
981 pts/2 00:00:00 ps

CTRL + a - w

0-$ bash 1*$ bash

CTRL + a - A
Set window's title to: ps
GNU Screen: Windows

>_ CTRL + a - n
$ screen -t yetanotherwindow

CTRL + a - p

CTRL + a - Number

Num Name Flags


0 bash $ CTRL + a - "
1 ps $
2 yetanotherwindow

UP DOWN ENTER
GNU Screen: Windows

>_ CTRL + a - k
Really kill this window [y/n]
Window 0 (bash) killed.
GNU Screen: Regions

>_ CTRL + a - S
1 ps --

CTRL + a - |

CTRL + a - TAB

$ ps $
PID TTY TIME CMD CTRL + a - 2
1020 pts/2 00:00:00 bash
1033 pts/2 00:00:00 ps
$ screen -t yetanotherwindow
1 ps 2
yetanotherwindow
GNU Screen: Regions

Move between regions: CTRL + a - TAB

Terminate all regions except CTRL + a - Q


current:

Terminate current region: CTRL + a - X

Terminating a region does not terminate its window.


GNU Screen: Sessions

>_
$ screen -ls
There is a screen on:
1037.pts-0.debian (08/24/19 13:53:35)
(Attached)
1 Socket in /run/screen/S-carol.

$ screen -S "second session"

$ screen -ls
There are screens on:
1090.second session (08/24/19 14:38:35)
(Attached)
1037.pts-0.debian (08/24/19 13:53:36)
(Attached)
2 Sockets in /run/screen/S-carol.
GNU Screen: Sessions

>_
$ screen -S 1037 -X quit

$ screen -ls
There is a screen on:
1090.second session (08/24/19 14:38:35)
(Detached)
1 Socket in /run/screen/S-carol.
GNU Screen: Session Detachment

>_ CTRL + a - d
[detached from 1090.second session]

$ screen -r

$ screen -ls
There is a screen on:
1090.second session (08/24/19 14:38:35)
(Attached)
1 Socket in /run/screen/S-carol.
GNU Screen: Reattaching

>_
$ screen -d -r Reattach. Detach first, if necessary

$ screen -d -R Same as -d -r. Create session if necessary.

$ screen -d -RR Same as -d -r. Use the first session.

$ screen -D -r Reattach. Detach first and logout remotely.

$ screen -D -R Reattach if running. Create and notify.

$ screen -D -RR Same as -D -R. Stronger.

$ screen -d -m Start in detached mode.

$ screen -D -m Same as -d -m. Does not fork to new


process.
GNU Screen: Scrollback Mode

Enter scrollback mode: CTRL + a - [

Move to the text you want to copy: UP DOWN

Mark the beginning: SPACE

Move to the end: UP DOWN

Mark the end: SPACE

Paste: CTRL + a - ]
GNU Screen: Customization

>_ /etc/screenrc
$ sudo vi /etc/screnrc SCREEN SETTINGS

$ vi ~/.screenrc SCREEN KEYBINDINGS

TERMINAL SETTINGS

STARTUP SCREENS
Using tmux
tmux

Released in 2007.

Client-server model. Server supplies sessions and sessions


supply windows. Multiple clients can share windows.

Interactive selection of sessions, windows, and clients


via menus.

The same window can be linked to multiple sessions.

Both vim and Emacs key layouts.

UTF-8 and 256-color terminal support.


tmux: Windows

>_
$ tmux
[0] 0:bash* "debian" 18:53
27-Aug-19

$ tmux new -s "LPI" -n "Window zero"


[LPI] 0:Window zero* "debian" 19:01
27-Aug-19
tmux: Windows

>_
CTRL + b - c
[LPI] 0:Window zero- 1:bash* "debian" 19:02
27-Aug-19

(rename-window) Window one


CTRL + b - , ENTER

(0) 0: Window zero- "debian" CTRL + b - w UP/DOWN


(1) 1: Window one* "debian"

CTRL + b - n

CTRL + b - p
tmux: Windows

>_
CTRL + b - NUMBER

kill-window Window one? (y/n)


CTRL + b - &

CTRL + b - f

CTRL + b - .

$ man tmux
tmux: Panes

>_
CTRL + b - "
Tasks: 93 total, 1 running, 92 sleeping, 0 stopped, 0 zombie
%Cpu(s): 0.0 us, 0.0 sy, 0.0 ni,100.0 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
KiB Mem : 4050960 total, 3730920 free, 114880 used, 205160 buff/cache
KiB Swap: 4192252 total, 4192252 free, 0 used. 3716004 avail Mem
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
1340 carol 20 0 44876 3400 2800 R 0.3 0.1 0:00.24 top
1 root 20 0 139088 6988 5264 S 0.0 0.2 0:00.50 systemd
2 root 20 0 0 0 0 S 0.0 0.0 0:00.00 kthreadd
3 root 20 0 0 0 0 S 0.0 0.0 0:00.04 ksoftirqd/0
4 root 20 0 0 0 0 S 0.0 0.0 0:01.62 kworker/0:0
5 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 kworker/0:0H
7 root 20 0 0 0 0 S 0.0 0.0 0:00.06 rcu_sched
8 root 20 0 0 0 0 S 0.0 0.0 0:00.00 rcu_bh
9 root rt 0 0 0 0 S 0.0 0.0 0:00.00 migration/0
10 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 lru-add-drain
11 root rt 0 0 0 0 S 0.0 0.0 0:00.01 watchdog/0
12 root 20 0 0 0 0 S 0.0 0.0 0:00.00 cpuhp/0
$
────────────────────────────────────────────────────────────────────────────
───────
────────────
$
[LPI] 0:Window zero- 1:Window one* "debian"
19:05 27-Aug-19
tmux: panes

>_
CTRL + b - %
│$
1 root 20 0 139088 6988 5264 S 0.0 0.2 0:00.50 systemd │

2 root 20 0 0 0 0 S 0.0 0.0 0:00.00 kthreadd │

3 root 20 0 0 0 0 S 0.0 0.0 0:00.04 ksoftirqd/0 │
4 root 20 0 0 0 0 S 0.0 0.0 0:01.62 kworker/0:0 │
5 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 kworker/0:0H │
7 root 20 0 0 0 0 S 0.0 0.0 0:00.06 rcu_sched │
8 root 20 0 0 0 0 S 0.0 0.0 0:00.00 rcu_bh │
9 root rt 0 0 0 0 S 0.0 0.0 0:00.00 migration/0 │

10 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 lru-add-drai │
n │
11 root rt 0 0 0 0 S 0.0 0.0 0:00.01 watchdog/0 │

12 root 20 0 0 0 0 S 0.0 0.0 0:00.00 cpuhp/0 │

$ │
────────────────────────────────────────────────────────────────────────────
───┴───
────────────
$
[LPI] 0:Window zero- 1:Window one* "debian"
19:05 27-Aug-19
tmux: Panes

>_
CTRL + b - x
kill-pane 1? (y/n)
tmux: Panes

Move between panes: CTRL + b - ARROW

Move to last active pane: CTRL + b - ;

Resize pane by one line: CTRL + b - CTRL + ARROW

Resize pane b five lines: CTRL + b - ALT + ARROW


tmux: Panes

Swap to previous pane: CTRL + b - {

Swap to next pane: CTRL + b - }

Zoom in/out panel: CTRL + b - z

Fancy clock: CTRL + b - t

Turn pane into window: CTRL + b - !


tmux: Sessions

>_
CTRL + b - s
(0) + LPI: 2 windows (attached)

$ tmux ls
LPI: 2 windows (created Tue Aug 27 19:01:49 2019) [158x39] (attached)

:new CTRL + b ENTER

[2] 0:bash* "debian" 19:15


27-Aug-19
tmux: Sessions

>_
CTRL + b - $ ENTER
(rename-session) Second Session

0) + LPI: 2 windows CTRL + b - s


(1) + Second Session: 1 windows (attached)

UP/DOWN ENTER

$ tmux kill-session -t "Second Session"


[exited]

$
tmux: Detachment

>_
$ tmux ls
LPI: 2 windows (created Tue Aug 27 19:01:49 2019) [158x39]

$ tmux a

CTRL + b - d
[exited]

CTRL + b - D

CTRL + b - r
tmux: Scrollback Mode

Enter scrollback mode: CTRL + b - [

Move to the text you want to copy: UP DOWN

Mark the beginning: CTRL + b - SPACE

Move to the end: UP DOWN

Mark the end: SPACE

Paste: ALT + W
tmux: Customization

>_ /etc/tmux.conf
$ sudo vi /etc/tmux.conf # Change the prefix key to C-a
set -g prefix C-a
unbind C-b
$ vi ~/.tmux.conf bind C-a send-prefix

# Some extra key bindings to select higher


numbered windows
bind F1 selectw -t:10
bind F2 selectw -t:11
bind F3 selectw -t:12
Nano and Emacs
Nano

undo/redo / syntax coloring

/ interactive search-and-replace

GNU / auto-indentation / line numbers


NANO
/ word completion / file locking

/ backup files / internationalization support


Nano

CTRL
GNU
NANO
META
/ VI
Nano

Start a new session: CTRL + 6

Copy selection: META + 6

Cut selection: CTRL + K

Paste: CTRL + U
Nano

Undo: META + U

Redo: META + E

Replace text: CTRL + \

Spell-check: CTRL + T
Emacs

Text is inserted by typing, as in nano. Navigation is via


commands, as in vi.

Also an IDE, capable of compiling, running, and testing programs.

Can be configured as an email, news, or RSS client.


Configure the Standard Editor
SysVinit

>_ ~/.bash_profile
$ export EDITOR=nano EDITOR=nano

$ vi ~/.bash_profile
Demo
List, Create, Delete,
and Modify Physical Storage Partitions
Physical Storage Partitions

>_
block devices
$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT vda
vda 8:0 0 20G 0 disk vda1
├─vda1 8:1 0 1G 0 part /boot
└─vda2 8:2 0 19G 0 part
vda2
├─cs-root 253:0 0 17G 0 lvm / vdb
└─cs-swap 253:1 0 2G 0 lvm [SWAP] vdb1
vdb2
vdb3
vdc
vdc1
Physical Storage Partitions

>_
/dev/
$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT /dev/vda1
vda 8:0 0 20G 0 disk
├─vda1 8:1 0 1G 0 part /boot
└─vda2 8:2 0 19G 0 part
├─cs-root 253:0 0 17G 0 lvm /
└─cs-swap 253:1 0 2G 0 lvm [SWAP]

$ fdisk

$ cfdisk
Demo
Create and Configure
File Systems
Create and Configure File Systems

>_
$ sudo mkfs.xfs /dev/vdb1 make filesystem

$ sudo mkfs.ext4 /dev/vdb1


Configure Systems to
Mount Filesystems At or During Boot
Mount Filesystems At or During Boot

>_
$ ls /mnt/

$ sudo mount /dev/vdb1 /mnt/

$ sudo touch /mnt/testfile

$ ls -l /mnt/
-rw-rw-r--. 1 aaron aaron 30 Jan 31 14:30 testfile

$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
vda 8:0 0 20G 0 disk
├─vda1 8:1 0 1G 0 part /boot
└─vda2 8:2 0 19G 0 part
├─cs-root 253:0 0 17G 0 lvm /
└─cs-swap 253:1 0 2G 0 lvm [SWAP]
vdb 8:16 0 10G 0 disk
├─vdb1 8:17 0 4G 0 part
├─vdb2 8:18 0 4G 0 part
└─vdb3 8:19 0 2G 0 part /mnt
Mount Filesystems At or During Boot

>_
$ sudo umount /mnt/

$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
vda 8:0 0 20G 0 disk
├─vda1 8:1 0 1G 0 part /boot
└─vda2 8:2 0 19G 0 part
├─cs-root 253:0 0 17G 0 lvm /
└─cs-swap 253:1 0 2G 0 lvm [SWAP]
vdb 8:16 0 10G 0 disk
├─vdb1 8:17 0 4G 0 part
├─vdb2 8:18 0 4G 0 part
└─vdb3 8:19 0 2G 0 part

$ ls /mnt/
Mount Filesystems At or During Boot

>_
$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
vda 8:0 0 20G 0 disk
├─vda1 8:1 0 1G 0 part /boot
└─vda2 8:2 0 19G 0 part
├─cs-root 253:0 0 17G 0 lvm /
└─cs-swap 253:1 0 2G 0 lvm [SWAP]
vdb 8:16 0 10G 0 disk
├─vdb1 8:17 0 4G 0 part
├─vdb2 8:18 0 4G 0 part
└─vdb3 8:19 0 2G 0 part

$ sudo mkdir /mybackups/


Mount Filesystems At or During Boot

>_ /etc/fstab
$ sudo vim /etc/fstab /dev/mapper/cs-root / xfs defaults 00

/dev/vdb1 /mybackups xfs defaults 02


$ sudo systemctl daemon-reload
/dev/vdb2 /mybackups etx4 defaults 02

# After editing this file, run 'systemctl daemon-reload' to update


systemd
# units generated from this file.
Mount Filesystems At or During Boot

>_
$ ls /mybackups/

$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
vda 8:0 0 20G 0 disk
├─vda1 8:1 0 1G 0 part /boot
└─vda2 8:2 0 19G 0 part
├─cs-root 253:0 0 17G 0 lvm /
└─cs-swap 253:1 0 2G 0 lvm [SWAP]
vdb 8:16 0 10G 0 disk
├─vdb1 8:17 0 4G 0 part
├─vdb2 8:18 0 4G 0 part
└─vdb3 8:19 0 2G 0 part
Mount Filesystems At or During Boot

>_
$ sudo systemctl reboot

$ ls -l /mybackups/
-rw-rw-r--. 1 aaron aaron 30 Jan 31 14:30 testfile

$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
vda 8:0 0 20G 0 disk
├─vda1 8:1 0 1G 0 part /boot
└─vda2 8:2 0 19G 0 part
├─cs-root 253:0 0 17G 0 lvm /
└─cs-swap 253:1 0 2G 0 lvm [SWAP]
vdb 8:16 0 10G 0 disk
├─vdb1 8:17 0 4G 0 part
├─vdb2 8:18 0 4G 0 part /mybackups
└─vdb3 8:19 0 2G 0 part
Mount Filesystems At or During Boot

>_
$ man fstab
FSTAB(5) File Formats FSTAB(5)

NAME
fstab - static information about the filesystems

SYNOPSIS
/etc/fstab

DESCRIPTION
The file fstab contains descriptive information about the filesystems the system can mount. fstab
is only read by programs, and not written; it is the duty of the system administrator to properly
create and maintain this file. The order of records in fstab is important because fsck(8),
mount(8), and umount(8) sequentially iterate through fstab doing their thing.

Each filesystem is described on a separate line. Fields on each line are separated by tabs or
spaces. Lines starting with '#' are comments. Blank lines are ignored.

The following is a typical example of an fstab entry:

LABEL=t-home2 /home ext4 defaults,auto_da_alloc 0 2


Mount Filesystems At or During Boot

>_ /etc/fstab
/dev/mapper/cs-swap none swap defaults 00
$ sudo vim /etc/fstab
/dev/vdb3 none swap defaults 00

$ swapon --show
NAME TYPE SIZE USED PRIO
/dev/vdb3 partition 2G 0B -2
/dev/dm-1 partition 2G 0B -3
Mount Filesystems At or During Boot

>_ /etc/fstab
UUID=3b93b1ba-e44a-4f75-aa38-c93ed32e34e2 /boot xfs defaults 00
$ sudo vim /etc/fstab
/dev/vda1 /boot xfs defaults 00

$ sudo blkid /dev/vdb1


/dev/vdb1: LABEL="FirstFS" UUID="9ab8cfa5-2813-4b70-ada0-7abd0ad9d289" UUID=9ab8cfa5-2813-4b70-ada0-7abd0ad9d289 /mybackups xfs defaults 0 0
BLOCK_SIZE="512" TYPE="xfs" PARTUUID="569a3fcc-f9eb-9147-888d-
9e3ffe9ccdb0"
Configure Systems to
Mount Filesystems On Demand
On Demand Mounting

/backups/
On Demand Mounting

/backups/ /backups/ /backups/ /backups/ /backups/

Fileserver
Mount Filesystems on Demand

>_
$ sudo dnf install autofs

$ sudo systemctl start autofs.service

$ sudo systemctl enable autofs.service


Mount Filesystems on Demand

>_
$ sudo dnf install nfs-utils

$ sudo systemctl start nfs-server.service

$ sudo systemctl enable nfs-server.service


Mount Filesystems on Demand

>_ /etc/exports
/etc 127.0.0.1(ro)
$ sudo vim /etc/exports

$ sudo systemctl reload nfs-server.service


Mount Filesystems on Demand

>_ /etc/auto.master
/shares/ /etc/auto.shares --timeout=400
$ sudo vim /etc/auto.master
Mount Filesystems on Demand

>_ /etc/auto.shares
mynetworkshare -fstype=auto 127.0.0.1:/etc
$ sudo vim /etc/auto.shares

/etc/auto.master /shares /etc/auto.shares mynetworkshare -fstype=nfs4 127.0.0.1:/etc

mynetworkshare -fstype=auto,ro 127.0.0.1:/etc

mynetworkshare -fstype=auto,ro nfs1.example.com:/etc

myext4files -fstype=auto :/dev/vdb2


Mount Filesystems on Demand

>_
$ sudo systemctl reload autofs

$ ls /shares/

$ ls /shares/mynetworkshare/
mysharedfile1 mysharedfile2
Mount Filesystems on Demand

>_ /etc/auto.master
/shares/ /etc/auto.shares --timeout=400
$ sudo vim /etc/auto.master
/- /etc/auto.shares --timeout=400
Mount Filesystems on Demand

>_ /etc/auto.shares
mynetworkshare -fstype=auto 127.0.0.1:/etc
$ sudo vim /etc/auto.shares
myext4files -fstype=auto :/dev/vdb2

$ sudo systemctl reload autofs


/mynetworkshare -fstype=auto 127.0.0.1:/etc

/localfiles/myext4files -fstype=auto :/dev/vdb2

$ ls /mynetworkshare/
mysharedfile1 mysharedfile2

$ ls /localfiles/myext4files/
mysharedfile3 mysharedfile4
Create and Manage Hard Links
Inodes

>_

$ echo “Picture of Milo the dog” > Pictures/family_dog.jpg

family_dog.jpg
$ stat Pictures/family_dog.jpg
File: Pictures/family_dog.jpg
Size: 49 Blocks: 8 IO Block: 4096 regular file
Device: fd00h/64768d Inode: 52946177 Links: 1
Access: (0640/-rw-r-----) Uid: ( 1000/ aaron) Gid: ( 1005/ family)
Context: unconfined_u:object_r:user_home_t:s0 52946177
Inode
Access: 2021-10-27 16:33:18.949749912 -0500
Modify: 2021-10-27 14:41:19.207278881 -0500 Permissions Access Time
Change: 2021-10-27 16:33:18.851749919 -0500
Birth: 2021-10-26 13:37:17.980969655 -0500
Hard Links

>_

$ echo “Picture of Milo the dog” > Pictures/family_dog.jpg

family_dog.jpg
$ stat Pictures/family_dog.jpg
File: Pictures/family_dog.jpg
Size: 49 Blocks: 8 IO Block: 4096 regular file Hard Link
Device: fd00h/64768d Inode: 52946177 Links: 1
Access: (0640/-rw-r-----) Uid: ( 1000/ aaron) Gid: ( 1005/ family)
Context: unconfined_u:object_r:user_home_t:s0 52946177
Inode 1
Access: 2021-10-27 16:33:18.949749912 -0500
Modify: 2021-10-27 14:41:19.207278881 -0500 Permissions Access Time
Change: 2021-10-27 16:33:18.851749919 -0500
Birth: 2021-10-26 13:37:17.980969655 -0500
Hard Links

>_ home

$ cp –r /home/aaron/Pictures/ /home/jane/Pictures/

# ln path_to_target_file path_to_link_file aaron/Pictures jane/Pictures

$ ln /home/aaron/Pictures/family_dog.jpg /home/jane/Pictures/family_dog.jpg
copy
$ stat Pictures/family_dog.jpg
family_dog.jpg family_dog.jpg
File: Pictures/family_dog.jpg
Size: 49 Blocks: 8 IO Block: 4096 regular file
Device: fd00h/64768d Inode: 52946177 Links: 2
Access: (0640/-rw-r-----) Uid: ( 1000/ aaron) Gid: ( 1005/ family)
Context: unconfined_u:object_r:user_home_t:s0 52946177
Inode 2
1
Access: 2021-10-27 16:33:18.949749912 -0500
Permissions Access Time
Modify: 2021-10-27 14:41:19.207278881 -0500
Change: 2021-10-27 16:33:18.851749919 -0500
Birth: 2021-10-26 13:37:17.980969655 -0500

$ rm /home/aaron/Pictures/family_dog.jpg

$ rm /home/jane/Pictures/family_dog.jpg
Limitations and Considerations

>_
Only hardlink to files, not folders
$ useradd –a –G family aaron

$ useradd –a –G family jane

$ chmod 660 /home/aaron/Pictures/family_dog.jpg

Only hardlink to files on the same filesystem

/home/aaron/file /mnt/Backups/file
Create and Manage Soft Links
Soft Links

C:\Program Files\MyCoolApp\application.exe
Soft Links

>_
# ln -s path_to_target_file path_to_link_file
family_dog_shortcut.jpg
$ ln –s /home/aaron/Pictures/family_dog.jpg family_dog_shortcut.jpg
Soft Link
$ ls -l
lrwxrwxrwx. 1 aaron aaron family_dog_shortcut.jpg -> /home/aaron/Pictures..

$ readlink family_dog_shortcut.jpg
family_dog.jpg
/home/aaron/Pictures/family_dog.jpg
Hard Link
$ echo “Test” >> fstab_shortcut

bash: fstab_shortcut: Permission denied 52946177 Inode

$ ls -l
lrwxrwxrwx. 1 aaron aaron family_dog_shortcut.jpg -> /home/aaron/Pictures..

[/home/aaron]$ ln –s Pictures/family_dog.jpg relative_picture_shortcut


Soft Links

>_
Softlink to files and folders

Softlink to files on different filesystem as well

/home/aaron/file /mnt/Backups/file
List, Set, and
Change File Permissions
Owners and Groups

>_
$ ls -l
-rw-r-----. 1 aaron family 49 Oct 27 14:41 family_dog.jpg

# chgrp group_name file/directory change group


$ chgrp wheel family_dog.jpg

$ ls -l
-rw-r-----. 1 aaron wheel 49 Oct 27 14:41 family_dog.jpg

$ groups aaron
jane family
wheel
aaron wheel family

$ sudo chown jane family_dog.jpg change owner


$ ls -l
-rw-r-----. 1 jane family 49 Oct 27 14:41 family_dog.jpg

$ sudo chown aaron:family family_dog.jpg


$ ls -l
-rw-r-----. 1 aaron family 49 Oct 27 14:41 family_dog.jpg
File and Directory Permissions

$ ls -l
- r w x r w x r w x . 1 aaron family 49 Oct 27 14:41 family_dog.jpg

File Type Identifier


DIRECTORY d

REGULAR FILE -

CHARACTER DEVICE c

LINK l

SOCKET FILE s

PIPE p

BLOCK DEVICE b
File and Directory Permissions

rwxrwxrwx
owner Group Others
u g o

Bit Purpose
r Read File

w Write to File

x Execute (run)

- No permission
Directory Permissions

>_

$ ls Pictures/

$ mkdir Pictures/Family

$ cd Pictures/

Bit Purpose
r Read Directory

w Write to Directory

x Execute into

- No permission
Evaluating Permissions

>_
(aaron)$ ls -l
-r--rw----. 1 aaron family 49 family_dog.jpg

(aaron)$ echo “Add this content to file” >> family_dog.jpg


bash: family_dog.jpg: Permission denied

(aaron)$ su jane
-r--rw----
(jane)$ echo “Add this content to file” >> family_dog.jpg owner Group Others
u g o
(jane)$ cat family_dog.jpg
Picture of Milo the dog
Adding Permissions

>_

# chmod permissions file/directory change mode


u+[list of permissions]
$ ls -l
-r--rw----. 1 aaron family 49 Oct 27 14:41 family_dog.jpg

$ chmod u+w family_dog.jpg


$ ls -l Option Examples
-rw-rw----. 1 aaron family 49 Oct 27 14:41 family_dog.jpg
user u+ u+w / u+rw / u+rwx

group g+ g+w / g+rw / g+rwx

others o+ o+w / o+rw / o+rwx


Removing Permissions

>_
$ ls -l
-r--rw-r--. 1 aaron family 49 Oct 27 14:41 family_dog.jpg
u-[list of permissions]

$ chmod o-r family_dog.jpg


$ ls -l Option Examples
-r--rw----. 1 aaron family 49 Oct 27 14:41 family_dog.jpg user u- u-w / u-rw / u-rwx

group g- g-w / g-rw / g-rwx

others o- o-w / o-rw / o-rwx


Setting Exact Permissions

>_
$ ls -l
-r--rw----. 1 aaron family 49 Oct 27 14:41 family_dog.jpg
u=[list of permissions]
$ chmod g=r family_dog.jpg

$ ls -l
-r--r-----. 1 aaron family 49 Oct 27 14:41 family_dog.jpg
Option Examples
$ chmod g=rw family_dog.jpg user u= u=w / u=rw / u=rwx

group g= g=w / g=rw / g=rwx


$ ls -l
-r--rw----. 1 aaron family 49 Oct 27 14:41 family_dog.jpg
others o= o=w / o=rw / o=rwx

$ chmod g= family_dog.jpg

$ ls -l
-r--------. 1 aaron family 49 Oct 27 14:41 family_dog.jpg

$ chmod g-rwx family_dog.jpg


Chaining Permissions

>_

$ ls -l
-r--------. 1 aaron family 49 Oct 27 14:41 family_dog.jpg

$ chmod u+rw,g=r,o= family_dog.jpg


user: at least read and write
group: only read
$ ls -l
-rw-r-----. 1 aaron family 49 Oct 27 14:41 family_dog.jpg
others: no permissions

$ chmod u=rw,g-w family_dog.jpg


user: only read and write
group: remove write
$ ls -l
-rw-r-----. 1 aaron family 49 Oct 27 14:41 family_dog.jpg
Octal Permissions

>_

$ stat family_dog.jpg
File: family_dog.jpg
Size: 49 Blocks: 8 IO Block: 4096 regular file
Device: fd00h/64768d Inode: 52946177 Links: 1
Access: (0640/-rw-r-----) Uid: ( 1000/ aaron) Gid: ( 10/ wheel)
Octal Permissions

r1 w1 -01 r1 -01 -01 -01 -01 -01


6 4 0 Binary Decimal
000 0

001 1

r1 w1 x1 r1 -01 x1 r1 -01 x1 010

011
2

100 4
7 5 5
101 5

110 6

r1 w1 x1 r1 w1 x1 r1 w1 x1 111 7

7 7 7
Octal Permissions

r4 w2 -01 r4 -02 -01 -04 -02 -01


+ + + + + +
= = =
6 4 0

r4 w2 x1 r4 -02 x1 r4 -02 x1 Permission


r
Value
4

w 2
7 5 5 x 1

r4 w2 x1 r4 w2 x1 r4 w2 x1
7 7 7
Octal Permissions

>_

$ stat family_dog.jpg
File: family_dog.jpg
Size: 49 Blocks: 8 IO Block: 4096 regular file
Device: fd00h/64768d Inode: 52946177 Links: 1
Access: (0640/-rw-r-----) Uid: ( 1000/ aaron) Gid: ( 10/ wheel)

$ chmod 640 family_dog.jpg


Create Partitions and Filesystems: btrfs
btrfs

B-Tree Filesystem, also known as Butter FS or Better FS

Large amounts of storage and multi-device support

RAID-like features: striping, mirroring, striping+mirroring

Transparent compression

SSD optimizations

Incremental backups and snapshots

Online defragmentation

Offline checks

Supports sub-volumes with quotas

Deduplication
btrfs

Copy-on-write filesystem

Traditional filesystems New data is written directly over old data

New data is written to free space and the original


Copy-on-write filesystems file's metadata is updated to refer to the new file
before removing the old data.
Creating a btrfs Filesystem

>_ raid0
$ sudo mkfs.btrfs /dev/sdb1 raid1
raid5
raid6
$ sudo mkfs.btrfs /dev/sdb1 -L "New Disk" raid10
single
$ sudo mkfs.btrfs -d single -m single /dev/sdb /dev/sdc dup
Sub-volumes

>_
$ sudo btrfs subvolume create /mnt/disk/BKP

$ ls -lh /mnt/disk/
total 0
drwxr-xr-x 1 root root 0 jul 13 17:35 BKP
drwxrwxr-x 1 carol carol 988 jul 13 17:30 Images

$ sudo btrfs subvolume show /mnt/disk/BKP/


Name: BKP
UUID: e90a1afe-69fa-da4f-9764-3384f66fa32e
Parent UUID: -
Received UUID: -
Creation time: 2019-07-13 17:35:40 -0300
Subvolume ID: 260
Generation: 23
Gen at creation: 22
Parent ID: 5
Top level ID: 5
Flags: -
Snapshot(s):

$ sudo mount -t btrfs -o subvol=BKP /dev/sdb1 /mnt/BKP


Snapshots

>_
$ sudo btrfs subvolume snapshot /mnt/disk /mnt/disk/snap

$ ls -lh /mnt/disk/
total 2,8M
-rw-rw-r-- 1 carol carol 109K jul 10 16:22 Galaxy_Note_10.png
-rw-rw-r-- 1 carol carol 484K jul 5 15:01 geminoid2.jpg
-rw-rw-r-- 1 carol carol 429K jul 5 14:52 geminoid.jpg
-rw-rw-r-- 1 carol carol 467K jul 2 11:48 LG-G8S-ThinQ-Mirror-White.jpg
-rw-rw-r-- 1 carol carol 654K jul 2 11:39 LG-G8S-ThinQ-Range.jpg
-rw-rw-r-- 1 carol carol 94K jul 2 15:43 Mimoji_Comparativo.jpg
-rw-rw-r-- 1 carol carol 112K jul 10 16:20 Note10Plus.jpg
drwx------ 1 carol carol 366 jul 13 17:56 snap
-rw-rw-r-- 1 carol carol 118K jul 11 16:36 Twitter_Down_20190711.jpg
-rw-rw-r-- 1 carol carol 324K jul 2 15:22 Xiaomi_Mimoji.png
Snapshots

>_
$ rm LG-G8S-ThinQ-*

$ ls -lh /mnt/disk/
total 1,7M
-rw-rw-r-- 1 carol carol 109K jul 10 16:22 Galaxy_Note_10.png
-rw-rw-r-- 1 carol carol 484K jul 5 15:01 geminoid2.jpg
-rw-rw-r-- 1 carol carol 429K jul 5 14:52 geminoid.jpg
-rw-rw-r-- 1 carol carol 94K jul 2 15:43 Mimoji_Comparativo.jpg
-rw-rw-r-- 1 carol carol 112K jul 10 16:20 Note10Plus.jpg
drwx------ 1 carol carol 366 jul 13 17:56 snap
-rw-rw-r-- 1 carol carol 118K jul 11 16:36 Twitter_Down_20190711.jpg
-rw-rw-r-- 1 carol carol 324K jul 2 15:22 Xiaomi_Mimoji.png

$ ls -lh /mnt/disk/snap
total 2,8M
-rw-rw-r-- 1 carol carol 109K jul 10 16:22 Galaxy_Note_10.png
-rw-rw-r-- 1 carol carol 484K jul 5 15:01 geminoid2.jpg
-rw-rw-r-- 1 carol carol 429K jul 5 14:52 geminoid.jpg
-rw-rw-r-- 1 carol carol 467K jul 2 11:48 LG-G8S-ThinQ-Mirror-White.jpg
-rw-rw-r-- 1 carol carol 654K jul 2 11:39 LG-G8S-ThinQ-Range.jpg
-rw-rw-r-- 1 carol carol 94K jul 2 15:43 Mimoji_Comparativo.jpg
-rw-rw-r-- 1 carol carol 112K jul 10 16:20 Note10Plus.jpg
-rw-rw-r-- 1 carol carol 118K jul 11 16:36 Twitter_Down_20190711.jpg
-rw-rw-r-- 1 carol carol 324K jul 2 15:22 Xiaomi_Mimoji.png
Snapshots

>_
$ sudo btrfs subvolume snapshot -r /mnt/disk /mnt/disk/snap
Compression

Compression is transparent

• Enabled with the -o mount option

• Compression is on a per-file basis


Compression

ZLIB: Default compression algorithm

LZO: Faster than ZLIB, but lower compression ratio

ZSTD: Faster than ZLIB, with a similar compression


ratio to ZLIB
Control Mounting and Unmounting
Filesystems
User Mountable Filesystems

/media/USER/LABEL

/media/john/FlashDrive

user

nouser

group

owner

/dev/sdb1 /mnt/userdrive ext4 defaults,user 0 0


Mounting with Systemd

/etc/systemd/system/mnt-external.mount
>_
$ sudo vi /etc/systemd/system/mnt-external.mount [Unit]
Description=External data disk
[Mount]
What=/dev/disk/by-uuid/56C11DCC5D2E1334
$ sudo systemctl daemon-reaload Where=/mnt/external
Type=ntfs
Options=defaults
$ sudo systemctl start mnt-external.mount [Install]
WantedBy=multi-user.target
Mounting with Systemd

>_
$ sudo systemctl status mnt-external.mount
mnt-external.mount - External data disk
Loaded: loaded (/etc/systemd/system/mnt-external.mount; disabled; vendor
pres
Active: active (mounted) since Mon 2019-08-19 22:27:02 -03; 14s ago
Where: /mnt/external
What: /dev/sdb1
Tasks: 0 (limit: 4915)
Memory: 128.0K
CGroup: /system.slice/mnt-external.mount
ago 19 22:27:02 pop-os systemd[1]: Mounting External data disk...
ago 19 22:27:02 pop-os systemd[1]: Mounted External data disk.

$ sudo systemctl enable mnt-external.mount


Mounting with Systemd

/etc/systemd/system/mnt-external.automount
>_
$ sudo vi /etc/systemd/system/mnt-external.automount [Unit]
Description=Automount for the external data disk
[Automount]
Where=/mnt/external
$ sudo systemctl daemon-reaload [Install]
WantedBy=multi-user.target

$ sudo systemctl start mnt-external.automount

$ sudo systemctl enable mnt-external.automount


Filesystem Hierarchy Standard
Filesystem Hierarchy Standard

/ /root
/bin /run
/boot /sbin
/dev /srv
/etc /tmp
/home /usr
/lib /proc
/media /var
/mnt /var/tmp
/opt
Conclusion
Conclusion
Conclusion

You might also like