Back to exam

101-500 Cheatsheet

LPIC-1 Exam 101

Download free PDF

System architecture

Firmware, kernel and initial root

  • **BIOS** initializes hardware and starts boot code from the selected device. **UEFI** understands partition tables and supported filesystems, loading EFI executables from the FAT-formatted **EFI System Partition (ESP)**.
  • **Boot sequence:** firmware, bootloader, kernel and initramfs, real root filesystem, then the system init process. The kernel starts **PID 1**; on a System V system this is normally /sbin/init.
  • **/boot** holds kernel images, initial RAM filesystem images and bootloader files. An **initramfs** is an archive containing early userspace tools and drivers needed to locate and mount the real root; rebuild it when required drivers change.
  • **/proc/cmdline** exposes the running kernel command line. **dmesg** reads the current kernel ring buffer; reading normally leaves it intact. **dmesg --clear** clears it, and reboot starts a new buffer.

Hardware, modules and power events

  • **lspci** lists PCI devices; verbose output can include vendor IDs, IRQ information and link capabilities. **lsusb** lists USB devices. **/proc** and **/sys** expose live kernel and device information.
  • **lsmod** lists loaded modules; **modinfo module** shows module metadata. **modprobe module** loads a module and required dependencies; **modprobe -r module** attempts removal. **depmod** builds module dependency data.
  • A **blacklist module_name** line in /etc/modprobe.d/*.conf suppresses automatic alias-based loading. It does not unload an active module or prevent every explicit load; rebuild the initramfs if it contains the unwanted module.
  • **ACPI** reports power and hardware events. **acpid** handles configured ACPI events on systems using that daemon; systemd-logind also manages common power-button, lid and sleep actions.

Startup modes and boot diagnosis

  • **systemctl get-default** shows the default target; **systemctl set-default multi-user.target** changes future boots. **systemctl isolate multi-user.target** switches the current system to that target.
  • **multi-user.target** supplies a non-graphical multiuser environment; **graphical.target** adds graphical login. **rescue.target** and **emergency.target** provide progressively smaller recovery environments.
  • **System V init** commonly sets the default runlevel in /etc/inittab. In /etc/rcN.d, **S** links start services and **K** links stop them when entering runlevel N; numeric prefixes order execution. Runlevel meanings can vary by distribution.
  • From rescue media, mount the installed system and inspect its **/var/log** files or persistent journal. The rescue kernel has its own **dmesg** buffer; **chroot** changes the filesystem view, not the running kernel.

Linux installation and package management

Partitions, swap and logical volumes

  • **MBR** has four primary partition entries; an extended partition can contain logical partitions. With 512-byte sectors its addressing limit is about **2 TiB**. **GPT** supports larger disks and commonly provides 128 partition entries.
  • Traditional Linux MBR type codes include **0x82 swap**, **0x83 Linux filesystem** and **0x8e Linux LVM**. **mkswap** initializes swap; **swapon** activates it. GPT uses partition type GUIDs instead of these byte codes.
  • **LVM** layers physical volumes into a volume group, then allocates logical volumes. It supports creating, removing and resizing LVs and taking snapshots. Filesystem resizing is a separate step; encryption is normally supplied by **dm-crypt/LUKS**.

GRUB installation and configuration

  • **GRUB 2** configuration commonly resides at /boot/grub/grub.cfg; some distributions use /boot/grub2. Generate it from /etc/default/grub and /etc/grub.d scripts with the distribution-supported update command.
  • **menuentry** defines a boot menu entry; **insmod** loads a GRUB module. GRUB modules are distinct from Linux kernel modules and live in platform-specific directories such as /boot/grub/i386-pc.
  • For a legacy BIOS installation, **grub-install /dev/sdc** targets the whole third SCSI-style disk; **/dev/sdc1** names its first partition. UEFI installation uses the mounted **ESP** and an EFI target, rather than BIOS MBR boot code.

Debian packages and APT

  • **dpkg -i file.deb** installs a local package without fetching missing dependencies. **apt-get install -f** attempts to repair broken dependencies; **apt install ./file.deb** can resolve dependencies from configured repositories.
  • **dpkg -l** lists package states; **dpkg -L package** lists installed paths; **dpkg -S /path** finds the installed package owning a path. **apt-file search /path** searches repository file indexes when available.
  • **dpkg -r package** removes the package while retaining managed configuration files. **dpkg -P package** or **--purge** also removes those configuration files; user-created data can remain.
  • **apt-get update** refreshes indexes from /etc/apt/sources.list and sources.list.d. **upgrade** updates packages without removals; **dist-upgrade** can change dependencies and remove packages. **apt full-upgrade** provides the latter behavior.

RPM, yum and zypper

  • **rpm -qa** lists installed packages. **rpm -ql package** lists installed files; **rpm -qf /path** identifies a file owner. **rpm -qR package** lists requirements of an installed package.
  • **rpm -qpR file.rpm** queries requirements in a package file: **-q** query, **-p** package file, **-R** requires. **rpm -Uvh file.rpm** installs or upgrades; repository managers add dependency resolution.
  • **yum** reads /etc/yum.conf and repository definitions in **/etc/yum.repos.d/*.repo**. Repositories can use **$basearch** and **$releasever** variables; editing configuration does not require restarting a yum daemon.
  • **yum groupinstall admintools** installs a defined package group. **zypper install '*foo'** selects package names ending in foo; quoting keeps the shell from expanding the wildcard first.

Shared libraries and virtual systems

  • **ldd trusted_binary** reports shared-library dependencies; use it only on trusted executables. **ldconfig** updates the library cache and links. Library locations include /lib and /usr/lib, often /lib64 and /usr/lib64 on 64-bit systems.
  • **LD_LIBRARY_PATH** adds runtime library search locations; /etc/ld.so.conf and its included files configure locations cached by ldconfig. A missing dependency can prevent a dynamically linked program from starting.
  • **Virtual machines** run guest kernels on virtual hardware supplied by a hypervisor. **Linux containers** share the host kernel and use namespaces and resource controls for isolation.
  • When cloning a VM, provision a unique **machine ID** and **SSH host keys** for the new host. Review hostname and network identity as well; copying a disk duplicates identities along with files.

GNU and Unix commands

Shell state, quoting and command lookup

  • **pwd** and **echo "$PWD"** show the working directory. **set** changes shell options and positional parameters; **export** passes variables to child processes. Bash normally saves history in **~/.bash_history**.
  • **Single quotes** preserve literal text, including $USER. **Double quotes** allow variable and command substitution while preventing word splitting and pathname expansion. Backslash escapes the following character.
  • **Globs** match filenames: **asterisk (*)** matches any string, **?** one character and **[012]** one listed character. Quote a literal backslash, for example **rmdir "$HOME/\dir"** for an empty directory named \dir.
  • **type command** explains shell resolution, including aliases and builtins. **command -v command** reports the resolved command; **which command** searches executable paths but may not reflect every shell construct.
  • **source script** and **. script** execute commands in the current shell, so directory and variable changes persist. **bash script** or direct script execution normally uses a separate process.

Redirection, pipes and input blocks

  • **File descriptors:** 0 is standard input, 1 standard output, 2 standard error. **> file** creates or truncates output; **>> file** appends; **< file** supplies input. **2> file** redirects errors.
  • **1>&2** sends standard output to the current standard error destination. **2>&1** sends stderr to the current stdout destination. Redirections are evaluated **left to right**.
  • **cmd >file 2>&1** sends both streams to file; **cmd 2>&1 >file** leaves stderr on the original stdout. A **pipe (|)** connects one command's stdout to another command's stdin.
  • **tee file** copies input to stdout and a file; **tee -a file** appends. A **here-document** starts with **<<EOF** and ends at a line containing only EOF; quoting the delimiter suppresses expansion within its body.

Finding files and building arguments

  • **find /tmp -user root -print** searches by owner name; **-uid 0** searches by numeric UID. **-name** matches a filename pattern; quote it so find receives the pattern unchanged.
  • **find path -maxdepth N** limits descent, counting the starting path as depth 0. Combine tests such as **-type f**, **-name** and **-user** to narrow the selection.
  • **find path -print0 | xargs -0 command** uses NUL delimiters to preserve spaces and newlines in names. **xargs** reads input and builds command arguments; **find ... -exec command {} +** is another safe argument-building pattern.
  • **locate** searches a filename database refreshed by **updatedb**, so results can be stale. **file path** identifies content formats using magic definitions; filename extensions alone do not establish a file's format.

Text fields, filters and regular expressions

  • **grep pattern file** selects matching lines; **grep -v** selects nonmatching lines. **-i** ignores case, **-n** adds line numbers, **-E** enables extended regular expressions and **-F** matches fixed strings.
  • In regex, **^** anchors the start, **$** the end, **.** matches one character and **[A-Z]** describes a range. **[[:upper:]]** is a character class. A literal space in a pattern requires a space in the input.
  • **sed 's/\.txt$/.bak.txt/'** replaces a trailing .txt suffix; the escaped dot is literal. An **asterisk (*)** repeats the preceding regex item; extended regex **+** means one or more. Shell glob syntax and regex syntax differ.
  • **cut -d: -f1,4 /etc/passwd** extracts username and primary group ID; **-f1,7** extracts username and login shell. **tr -d '\r' <input.txt >output.txt** removes carriage returns from CRLF text; **split** divides input into chunks.

Archives and compression

  • **tar** combines files into an archive; compression is a separate layer. **-c** creates, **-t** lists, **-x** extracts and **-f** names the archive. **-v** adds verbose output.
  • **tar -tzf archive.tgz** lists a gzip-compressed archive without extraction; **tar -xzf archive.tgz** extracts it. **-z** selects gzip, **-j** bzip2 and **-J** xz.
  • **gunzip texts.tgz** normally replaces the compressed file with **texts.tar**. The members remain inside the tar archive until a tar extraction; decompression alone does not unpack them.

Processes, jobs, signals and priority

  • **ps** lists processes; **top** provides an updating view. **uptime** reports runtime and load averages; top also shows uptime. **watch command** reruns a command periodically and refreshes its output.
  • **pgrep -u root** selects effective user IDs; **pgrep -U 0** selects real user ID 0. **-f** matches the full command line and **-c** counts matches rather than printing their PIDs.
  • **cmd &** starts a shell background job; **jobs** lists this shell's jobs. **fg %1** foregrounds a job and **bg %1** resumes it in the background. **nohup cmd >log 2>&1 &** protects against hangup on logout.
  • **Ctrl+C** sends **SIGINT** to the foreground process group; **Ctrl+Z** sends **SIGTSTP**. **SIGCONT** resumes stopped processes; **SIGTERM** requests termination. **SIGKILL** and **SIGSTOP** cannot be caught or ignored.
  • **nice -n N command** adjusts niceness for a new command; bare nice applies **+10** relative to inherited niceness. **renice** changes an existing process. Values run from **-20 to 19**; larger values lower CPU scheduling priority. Unprivileged users normally can only increase niceness.

vi modes, counts and file commands

  • **Esc** returns to Normal mode; **i** enters Insert mode. A numeric prefix repeats an action: **2dd** deletes two lines and **2yy** yanks two lines. Deleted text is also available for pasting.
  • **p** pastes after the cursor, or below the current line for linewise text; **P** pastes before or above. **u** undoes the last change.
  • **/pattern** searches forward; **?pattern** searches backward. **n** repeats in the search direction and **N** reverses it.
  • **:w filename** writes to a named file. **:wq** writes and quits; uppercase **ZZ** writes if changed and exits. **:q!** quits while discarding unsaved changes. Colon commands finish with Enter.

Devices, Linux filesystems and file hierarchy

Creating and maintaining filesystems

  • **mkfs -t ext4 /dev/device** explicitly selects a filesystem; bare util-linux **mkfs** defaults to ext2. Formatting creates filesystem structures and overwrites existing data on the selected device.
  • **ext2/ext3/ext4** normally allocate a fixed inode supply at creation. **df -i** checks inode usage: many small files can exhaust inodes while free data blocks remain.
  • **tune2fs** manages ext filesystem parameters: **-i 200d** sets a time-based check interval, **-c 200** sets a mount-count interval and **-m N** sets the reserved-block percentage. mke2fs normally reserves **5%** by default unless configured otherwise.
  • **fsck** dispatches filesystem-specific checkers; use **e2fsck** for ext filesystems and **xfs_repair** for XFS repair. Perform repairs on unmounted filesystems; XFS normally replays its journal during mounting after a crash.

Mounts, fstab and space usage

  • **mount** without arguments and **/proc/self/mounts** report current mounts; **/proc/mounts** commonly points to the latter. **/proc/filesystems** instead lists filesystem types supported by the kernel.
  • **/etc/fstab** conventionally has six fields: source, mountpoint, type, options, dump flag and fsck pass. Sources may use **UUID=** or **LABEL=** for stable identification; **blkid** reports these identifiers.
  • **mount --bind source target** exposes a directory tree at another path. **umount target** detaches it. systemd tracks manually created mounts as mount units as well as mounts configured through fstab.
  • **df -h** reports capacity and usage for mounted filesystems; **du -sh path** summarizes space attributed to a directory tree. These measure different things, so totals can differ, for example when a deleted file remains open.

Inodes, hard links and symbolic links

  • **ls -i file** and **stat file** show an inode number. An inode stores file metadata and data references; a directory entry associates a filename with an inode.
  • **ln original alias** creates a hard link to the same inode and increments its link count. Both names share ownership, permissions and data. Hard links cannot cross filesystem boundaries and normally cannot target directories.
  • Hard-linked backup trees can reuse unchanged data without copying it. Modifying shared contents affects every link; reclaiming the data requires removing all hard links and closing any remaining open references.
  • **ln -s target link** creates a separate symbolic-link inode storing a pathname. It can cross filesystems and become dangling. A relative target is resolved from the link's directory; ordinary chmod through a symlink affects its target on Linux.

Ownership, mode bits and umask

  • **chown user:group file** changes owner and group; **chgrp group file** changes group. The owner or a privileged process can normally **chmod** a file. Hard links share one mode; they do not have independent permissions.
  • **r=4, w=2, x=1** combine for user, group and others. **chmod 640 file** gives rw-r-----. Directory **r** lists names, **x** permits traversal and **w**, together with x, permits creating or removing entries.
  • **umask** clears permission bits from requested modes: commonly **0666 & ~mask** for files and **0777 & ~mask** for directories. **0027** normally yields files 0640 and directories 0750; it does not add execute bits to ordinary new files.
  • **SetUID 4000** runs an eligible executable with its owner's effective UID; **chmod 4755 file** sets it. **SetGID 2000** on a directory makes newly created entries inherit its group: **chmod g+s directory** or **chmod 2775 directory**.
  • **Sticky 1000** on a shared directory restricts deletion and renaming to the entry owner, directory owner or a privileged process. SetGID group inheritance and umask access restrictions solve different parts of shared-directory design.

File hierarchy and manual pages

  • **/etc** stores host configuration; **/var** holds changing data such as logs; **/usr** contains installed userspace software and shared data. **/usr/share/man** holds manual pages.
  • **/usr/local/bin** is for locally installed general commands, including administrator-built programs intended for all users. **/usr/local/sbin** holds local system administration commands.
  • **man 1 command** explicitly selects manual section 1. Common sections include **1** user commands, **5** file formats and **8** administration commands; **apropos keyword** searches manual descriptions.