DEV Community

Lennard John
Lennard John

Posted on

LPIC-1 Lesson 101.1 cheat sheet

I know this might be easy for most, but as i've learnt something new while reviewing this, i am sure someone else will.

Lesson 101.1 summarized

  • Bios vs UEFI

    • Bios (Basic Input Output system)
    • UEFI (Unified extensible firmware interface)
    • Bios is older, UEFI is newer and improved
  • Kernel module, similar to drivers on windows

-


 shows all devices currently connected to the PCI (Peripheral Component Interconnect) bus.
    common commands


```bash
lspci # list all available pci device 

lspci -s \[hex_address\] -v # show(verbose) more detail about a specific device based on Hex address given

lspci -s \[hex_address\] -k # verify which kernel module is in use based on Hex address given
Enter fullscreen mode Exit fullscreen mode

-


 Lists USB (Universal Serial Bus) devices currently connected to the machine
    common command


```bash
lsusb # list usb devices 

lsusb -v -d \[ID\] # detailed output of a specific device based on ID

lsusb -t # show curent usb device mapping as a tree

lsusb -s bus:dev # verify which device is using that module e.g lsusb -s 01:02
Enter fullscreen mode Exit fullscreen mode

-


 extracts detail information about hardware

-

 ```lsblk```

 list block device

-

 ```kmod```

 preferable way to interact with kernel module is also be call using these:

    -

 ```modprobe```

 used to add and remove module from the linux kernel 
    -

 ```lsmod```

 shows the status of module in the linux kernel 
    -

 ```rmmod```

 simple program to remove a module from linus kernel
    -

 ```insmod```

 simple program to insert a module to the linux kernel
    -

 ```modinfo```

 shows info about a kernel module
    -

 ```depmod```

 generate modules.deb and map files

- Example


```bash
sudo modprobe module_name # load a module
sudo modprobe -r module_name # remove a module
sudo rmmod module_name # remove a module
sudo rmmod -f module_name # force remove a module
sudo insmod /path/to.module.ko # load a module into kernel but doesn't handle dependencies 
modinfo module_name # display detail information about a kernel module
modinfo -p module_name # list specific module parameter
depmod -a kernel_version # generate for a specific module version
Enter fullscreen mode Exit fullscreen mode
  • kernel module important files - /etc/modules add module here to load at boot (depreciated), can also - /etc/modprobe.d/ use instead of /etc/module, add module config file here to load at boot - Kernel module parameter: can be change while kernel is at boot - /etc/modprobe.conf used to customized module parameter to make them persistent - /etc/modprobe.d/ add individual files with the extension .conf to customize module parameters - /etc/modprobe.d/blacklist.conf add module name here to block the loading of the module - /etc/modprobe.d/<module_name>.conf preferred method for blocking a module that will contain settings specific only to the given kernel module.
  • pseudo-filesystems: only exist while the system is running, not intended for conventional file storage.

    • /proc contains files with information regarding running processes and hardware resources. Common /proc files
      • /proc/cpuinfo: Lists detailed information about the CPU(s) found by the operating system.
      • /proc/interrupts: A list of numbers of the interrupts per IO device for each CPU.
      • /proc/ioports: Lists currently registered Input/Output port regions in use.
      • /proc/dma:Lists the registered DMA (direct memory access) channels in use.
    • sysfs pseudo-filesystem which provides an interface to kernel data structures, he files under sysfs provide information about devices, kernel modules, filesystems, and other kernel components, which are all mounted in /sys
      • /sys have similar roles to those in /proc. However, the /sys directory has the specific purpose of storing device information and kernel data related to hardware
    • u*dev subsystem*: Removable devices are handled by the udev subsystem, which creates the corresponding devices in /dev
      • /dev/ every file inside /dev is associated with a system device, particularly storage devices
      • /etc/udev/rules.d/ as new devices are detected, udev searches here for a matching rule about what to do
        • /dev/hdc cd/dvd are represented by these
        • /dev/fd0 represent floppy disk
        • /dev/sda represents IDE, SSD, and USB
        • /dev/mmcblk0p1 represents SD cards
        • /dev/nvme0n1p1 represents nvme
        • Linux kernel version 2.4, most storage devices are identified as if they were SCSI devices, regardless of their hardware type.
  • Linux Distro

    • debian-based uses dpkg and use apt (Advanced Packaging Tool) as package manager - RPM-based uses rpm and use yum (Yellowdog Updater Modified) or DNF as package manager - debian-based common commands
sudo dpkg -i \[package.deb\] # install

sudo dpkg -r \[package\] # Remove

sudo dpkg -P \[package\] # purge: remove config file

sudo dpkg -c \[package.deb\] # list content

dpkg -s \[package\] # check status

sudo dpkg -R -i \[directory\] # install from directory

dpkg -I \[package.deb\] # show package info

sudo dpkg --unpack \[package.deb\] # unpack contents

 dpkg -l # list installed package
Enter fullscreen mode Exit fullscreen mode
  • RPM-based common commands
sudo rpm -ivh \[package.rpm\] # insall 

sudo rpm -e \[package\] # remove

sudo rpm -Uvh \[package.rpm\] # upgrade

rpm -Vp \[package.rpm\] (specific) or rpm -Va (all) # verify

# query

rpm -qdf \[package\] # Documentation 

rpm -qi \[package\] # installed info

rpm -qip \[package.rpm\] # package info from online

Enter fullscreen mode Exit fullscreen mode

Top comments (0)