101 Exam Flashcards
Regular File System
Method of laying out files and folders on a physical hard disk
Two primary psuedo file system locations
/proc
/sys
Linux Kernel
- Core framework of the OS
- Handles memory management and hardware device interactions
- Many third-party kernel modules are device drivers
uname
displays information about current running kernel
uname -m
prints machine hardware name
uname -rm
brings up kernel release version with hardware name
uname -a
brings up OS, host name of the server, kernel release version, build time of the kernel, machine architecture, cpu type, and the OS label
modprobe
used to dynamically load and unload kernel modules at runtime
modprobe -r
used to remove a kernel module
modprobe (name)
used to add a kernel module
xfs module
used by kernel to know how to work with the PC’s file system
/udev
device manager for the Linux kernel, links information on system.
lspci
- displays information on PCI devices attached
- should the kernel not recognize a device, it will show up here and contain information that can be used to find drivers/modules
lsusb
displays information on USB devices attached
lsblk
lists hard disk and partition
procfs
Information about system hardware and the state of the system is contained in this
‘pseudofilesystem’
/proc
- Usually where the procfs filesystem is mounted.
-Within this directory, you will find directories that correspond in label (number) to the
associated PID (Process ID) of running processes
/proc/mounts
file (or link to another file) that contains information on all the
filesystems that are mounted locally
/proc/interrupts
shows information about the interrupts in use in the system
and what they are associated with (the hardware that is using them)
/proc/ioports
one or more addresses that identify a device, and the kernel module associated with them
/proc/dma
(Direct Memory Access), values used by hardware to access system memory directly (i.e. without involving the CPU)
/proc/usb
USB device IDs and kernel modules associated with them
/proc/pci
PCI device IDs and kernel modules associated with them
sysfs
- ‘pseudofilesystem’ that can contain information about system hardware (like procfs)
-designed to address some of the problems with the procfs method (unstructured data and
the fact that both hardware and process information was consolidated in the structure)
/sys
- Where the ‘sysfs’ filesystem is mounted
-Within this directory, you will directories that correspond to system hardware and kernel
modules associated with the system (physical or virtual)
-process data (PID) does NOT exist in this method
/dev
-contains device data (using the information from /sys or sysfs)
- Devices added or removed on a live system will engage the udev system which will detect
and configure it and then make it available for use (often called ‘hotplug’ or ‘hotswap’)
D-Bus
-send data messages between applications
udev utilizes dbus to notify user and the system when new hardware is attached
-Allows desktop applications to send messages to other applications and/or receive
messages from the Linux kernel
lsmod
- displays a listing of all currently loaded kernel modules
- Will not load a driver if missing
lscpu
displays information on processors on a system
lscpu -a (–all)
will display offline and online CPUs
lscpu -b (–online)
only online CPU information
lscpu -c (–offline)
only offline CPU information
lscpu -e (–extended)
display information in a more readable format
lscpu -p (–parse)
provides the information displayed in a comma delimited form (that can be
logged and used by other applications for reporting)
lsscsi
- displays information on any SCSI devices detected
- some distros will display SATA devices connected
lsscsi -c (–classic)
output is the same as running cat /proc/scsi/scsi
lsscsi -d (–device)
provides additional ‘major/minor’ device numbers behind each detected device
lsscsi -g (–generic)
generic SCSI device file name (sg)
lsscsi -l (–long)
additional information for each device
lsscsi -s (–size)
print the disk size in a more readable format
lsscsi -v (-vv or -vvv)
controls the level of detail (verbosity)
lsdev
Shows all the devices that are recognized by the running system kernel
lsraid
• Displays any RAID (Redundant Array of Inexpensive Disks) on your system
• not installed on most systems, unavailable outside of some RAID drivers/configuration
software
lsusb -t
- tells you which device is attached to which controller
- displayed in a tree view
lsusb -s
shows the specified bus and device number information
lsusb -d [vendor]
show only devices with the indicated vendor and product ID
lsusb -v
verbose device output
lsblk -a (–all)
list empty devices as well (off by default)
lsblk -d (–nodeps)
print only top level device information
lsblk -e (–exclude)
exclude the indicated devices (one or more, comma separated)
lsblk -f (–fs)
include information on filesystems
lsblk -i (–ascii)
use ASCH characters for tree view
lsblk -l (–list)
output list format
Pseudo File System
- Does not exit on a physical hard disk
- pseudo - “fake” or “not real”
- only exists in RAM while system is running
- cleared upon a reboot
dri
- Direct Rendering Interface
- pertains to the video cards attached to the system
lspci -k
lists out which components of the hardware are being used with which particular kernel modules
lspci -v (or -vv or -vvv)
be verbose and list more detailed information about all devices
General boot order 1
Power on
General boot order 2
BIOS loads ( modern systems includes EFI)
General boot order 3
BIOS find and hands off to the primary (or chosen) disks ‘boot sector’
General boot order 4
Boot sector provides the MBR (Master Boot Record), within the first 512 bytes of the active (or
first, depending on installation) drive (can be any type of hard drive)
General boot order 5
Boot loader is executed
General boot order 13
Modules indicated within the init scripts are loaded
General boot order 14
root filesystem is checked
General boot order 15
remaining filesystems are mounted
General boot order 16
network devices are started
General boot order 17
remote filesystems are mounted (if configured)
General boot order 18
init process re-reads /etc/inittab and changes to the default runlevel indicated and
executes the appropriate scripts
General boot order 19
runlevel scripts executed in numeric order (#service for the runlevel indicated in /etc/
inittab)
General boot order 20
tty sessions are loaded as listed in /etc/inittab
General boot order 21
Login prompt is displayed, system is ready for login
General boot order 12
/etc/inittab is read and the appropriate runlevel script(s) are run
General boot order 11
The init program is loaded (and becomes the first PID - /sbin/init)
General boot order 10
root filesystem is mounted
General boot order 9
Device initialization, module loading, and the initial RAM disk (initrd) is loaded
General boot order 8
linux kernel is read and executed
General boot order 7
USER INPUT STEP
depending on boot loader configuration, the user may be able to choose
from a menu of potential boot types/kernel versions or allow the default to proceed
General boot order 6
LILO/GRUB/GRUB2 boot loader begins
sysvinit
- older system and service management
- init script driven
- written by Miquelvan Smoorenburg
init (initialization)
- based off of the system V init used in UNIX systems
- services start one after the other
- static. does not natively respond to changes on a system
inittab: wait
process specified will be started once when the runlevel is entered, and init will wait for its termination.
Red Hat init script
/etc/rc.d/
Debian init script
/etc/init.d
/etc/init.d/rc
script that orchestrates how the runlevel scripts run and what occurs when a runlevel changes
upstart (background)
- first developed for Ubuntu in 2006 by Scott Remnant
- started in Ubuntu 6.10
- Eventually used in Red Hat 6, Debian, and Fedora 9
upstart
- offers asynchronous starting of services - decreasing boot up times
- works off real-time events
- stops and starts services, and monitors their availability
- considered easily extensible
- not used by most distros
- dynamic. can respond to changes on the system
- supports all sysvinit methods but not systemd methods
init Runlevel 3
- Multi-user mode but with networking.
- most linux servers are set up to run at this level by default.
init Runlevel 2
- Multi-user with no networking
- No remote file systems mounted
init Runlevel 6
- Reboot
- where init stops services and restarts the system.
init Runlevel 5
Multi-user but with networking and GUI.
Older Linux webstations set to run on this by default.
init Runlevel 4
typically not used but available should a system administrator want to set up a custom run level environment.
init Runlevel 1
- single user mode
- only root user allowed to log in.
- primarily used for maintenance tasks and repair functionality
init Runlevel 0
- halt or shutdown level
- where init runs scripts that stop services and powers off the system.
systemd
- removed the need for shell scripts
- replaces the functionality of scripts with compiled C code
- still compatible with older System V scripts
- default on most modern distros
- designed to replace sysvinit method
- fewer dependencies
- service prioritization and precedence
- reduces start up time
Unit File Locations:
/usr/lib/systemd/system
- the ‘units’ installed
- provided by package installations (do not edit these unit files)
Unit File Locations:
/etc/systemd/system
units that have priority over other units and are controlled by
sysadmin
Unit File Locations:
/run/systemd/system
units created at runtime and may have priority over non-runtime (or installed) units
systemctl
primary command for controlling service start/stop/restart/status
system-analyze
display performance information on system bootup, allows for
trace/debugging information
logind
replaces consolekit, supports X Windows managers
consoled
console daemon, replaces virtual terminals
journald
logging system, uses binary logs (although it can be replaced by other logging
daemons)
networkd
network support daemon
.service
system service
.swap
swap device or file
.socket
IPC socket
.target
unit (one or a group of)
.snapshot
saved state instance of the systemd manager
.slice
units grouped together in a hierarchy used to manage processes
.timer
timer
.mount
mount point on the file system (local or remote)
.automount
automount point on the filesystem
.scope
externally created process
.path
file or directory on file system
.device
device in use by the system kernel
systemd runlevel 0
- poweroff.target
- shutdown the system
systemd runlevel 1
- rescue.target
- single user/rescue shell
systemd runlevel 2,3 and 4
- multi-user.target
- non-graphical, but full network, multi-user
systemd runlevel 5
- graphical.target
- full graphical desktop, multi-user
systemd runlevel 6
- reboot.target
- reboot
Service target dependencies
• Method of indicating dependencies between units or groups of units on the system
Service target dependencies - requires
• Only after the requirement is met, will any other ‘wanted’ units be started
Service target dependencies - wants
Only executed upon completion of ‘requires’ units
systemd boot process changes
- /etc/inittab is not read (and is no longer in use)
- ‘default.target’ is started (which is linked to the current ‘default’ target - multiuser, graphical, etc)
- A tree of ‘requires’ and ‘wants’ is then followed throughout the process
runlevel (command)
displays the current runlevel (and the previous, if available)
systemctl get-default
displays the current default runlevel target
systemctl set-default [new.target]
- Will set the default runlevel target to the indicated value
- Creates a link from ‘default.target’ to the indicated target
systemctl list-units –type=target
list all the active system targets
systemctl isolate [runlevel.target]
Allows you to set the runlevel of the system without changing the default
Components of the Unit File
-unit files follow the INI style format first seen in MS-DOS
lspci -m (-mm)
displays the PCI device information in a more “easily parseable” format
lspci -vm
nicely formatted listing of all PCI hardware on the system
lspci -t
displays a tree view of the PCI devices on the system
lspci -tvm
associate the device names with the IDs in a tree view
PCI
- Peripheral Component Interconnect
- PCI device is any piece of computer hardware that plugs directly into a PCI slot on a computer
Commands to view output from kernel ring buffer
- dmesg - legacy command
- journalctl -k viewed within the systemd journal
/sbin/init
binary used to bring up the rest of the system and start services
Boot order overview
- BIOS
- Boot sector (w/ Boot loader)
- Kernel
- Initial RAM disk
- Device initialization
upstart: Task
will do what is requested and will return to a waiting state once finished
upstart: Service
Will not stop by itself
upstart: Job state
condition at one point in time
upstart: Waiting
initial state of a job
upstart: Starting
job itself is about to start
upstart: Stopping
interim state where job has processed a section of it’s configuration known as prestop
upstart: Killed
where job is actually stopped
upstart: Post-stop
where job has completely stopped and goes in waiting state
upstart: Respawning
- occurs when something goes wrong when job is running and quits unexpectedly
- upstart will attempt to respawn a job up to 10 times at 5 second intervals
sysvinit: change runlevel
- telinit or init (followed by runlevel)
- must be root user
- telinit is legacy command
sysvinit: pull default runlevel
cat/etc/inittab
sysvinit: change runlevel during restart
- press any key during boot process
- press “a” in GRUB menu
- type run level number to use
reboot (command)
reboot system
shutdown -h
halt the system (shut it down)
shutdown -r [specifictime]
reboot system at the time given
shutdown -P
power off (if ACPI is available)
shutdown -C
cancel shutdown
shutdown -k [message]
broadcasts a ‘wall’ message to logged in users
halt -f (–force)
does not shutdown, only halts
halt -p (–poweroff)
power off after shutdown (if ACPI is available)
halt -w (–wtmp-only)
only LOGS the shutdown but does not perform the shutdown
or reboot
halt –verbose
displays more information for troubleshooting
systemd Target
- target is a unit that syncs up other units when the computer boots or changes states
- other units associate themselves with a target for an operating environment
multi-user.target
- multi-user system
- similar to runlevel 3
- provides a command line shell with networking and the ability to host multiple user log ins
graphical.target
- multi-user system with a desktop environment. similar to runlevel 5
- “picture text”
rescue.target
- pulls in basic system and file system mounts and provides a rescue shell
- there to provide an isolated environment for the root user to perform repairs on the system.
- similar to runlevel 1
basic.target
basic system. used during the boot process before another
sysinit.target
system initialization
systemctl list-unit-files -t target
show all unit files for available targets
systemctl list-units -t target
show all loaded and active unit files
systemctl get-default
list out the default target
systemctl set-default [new.target]
change the default target to a different target
systemctl isolate [runlevel.target]
will change the running state of the system from the current target to a different target
systemctl rescue
- almost identical to the System V init single-user mode
- allows the root user to repair the system
systemctl reboot
- will run the reboot target
- same thing as just typing reboot at the prompt
systemctl poweroff
- isolates the system to poweroff.target
- same as typing poweroff at the prompt
systemctl halt
halt. do not power off
systemctl poweroff
halt and power off (if ACPI is available)
wall
- allows you to broadcast a message to all logged in users.
- limited to 20 lines of text
- will appear on every terminal overwriting or interrupting terminal text
- terminate with CTRL+D
reboot commands
- reboot
- telinit 6
- shutdown -r now
- systemctl isolate reboot.target
Shutdown commands
- poweroff
- telinit 0
- shutdown -h+1
- systemctl isolate poweroff.target
ACPI
-Advanced Configuration and Power Interface
-registers system events
(pressing power button or closing laptop lid)
mount (command)
list out every partition and every mount point currently in use on the system
block device
hard disk or anything that takes a large amount of data and writes it and blocks sizes to a location
single disk installation
linux installed on a single physical disk, consisting of one or more partitions
multi-disk installation
linux installed on multiple physical disks, each consisting of on or more partitions
dev/sda
first physical SATA disk on a system
dev/sda2
first physical disk, second partition
dev/hdc2
third IDE drive, second partition
dev/scd0
- first CDROM drive
- CDROM doesn’t have partitions
Linux filesystem layout
- everything is a file
- any folder (few exceptions) can be mounted on any drive/partition
- shared development system with constrained disk space
/
- ‘root’ filesystem is mounted on a device/partition and contains all other folders
- bottom of the directory tree
/var
- log files, shared files/directories, runtime information, binary data files
- generally set up on a separate partition
/home
user’s home directory, where personal files are stored
/boot
-boot loader configuration and kernel files are contained here
/opt
- generally third party applications are installed here
- enterprise environments make use of this location
swap
- temporary storage that acts like RAM
- when a percentage of RAM is full, kernel will move less used data to swap
- much slower than using a dedicated partition
Swap size
older ‘rules’ ranged from 1.5x to 2x of avail RAM
-today should use no less than 50% of avail
LVM (Logical Volume Manager)
- Allows the creation of ‘groups of disks’ or partitions that can be assembled into a filesystem.
- can be used for nearly any mount point except /boot
- flexibility - allows for resizing of volumes
- snapshots- allows for ‘point in time’ copies of your logical volume
VG (Volume Group)
- combination of one or more PV to create a pool of avail storage
- Contains all of your physical volumes
LV (Logical Volumes)
- Volume group is carved into individual components that can be used for specific functions
- like a partition
pvs (command)
lists out the physical volumes in an LVM group
vgs (command)
lists out the volume groups within an LVM group
lvs (command)
lists out the logical volumes within an LVM group
PV (Physical Volume)
- basic starting point of storage
- corresponds to a disk or partition
Swap - Partition
dedicated partition formatted specifically as swap space
Swap - files
created file that is used on a filesystem as swap space for the system
grub-install [device]
- command used to install GRUB to the specified device
- typically done from a live CD/USB where GRUB is installed on a new disk
- can be identified by drive path /dev/hda or /dev/hd0
grub (command)
-invokes GRUB shell environment and prompt
help (command)
print the help listing for GRUB, or get more info on a command
GRUB: find (command)
search for a file in all partitions and list the devices the file is on
GRUB: quit (command)
exit grub shell
MBR (Master Boot Record)
- traditionally supported only 26 total partitions
- partition size limited to 2TB
GPT (GUID Partition Table)
- supports 128 partitions
- partition size up to ZB range
- Needs UEFI to boot and asks as BIOS
UEFI (United Extensible Firmware Interface)
- replacement for traditional BIOS, can act in legacy BIOS mode
- requires 64bit OS
- prevents unauthorized
grub2-editenv list
view the default boot entry for the grub configuration file
grub2-mkconfig
- creates or updates a /boot/grub2/grub.cfg file based on entries from the /etc/default/grub file
- used to generate the GRUB configuration file menu
update-grub
- can be used to update a GRUB2 configuration after changes to /etc/default/grub have been made
- same results as running grub-mkconfig -o /boot/grub/grub.cfg
GRUB Legacy: [A] key
append options to the kernel boot line
GRUB Legacy: [C] key
open up the GRUB command lilne
GRUB Legacy: [ESC] key
escapes out of any GRUB menu
GRUB Legacy: Arrow Keys
used to highlight an option in the GRUB menu
RHGB
Red Hat Graphical Boot
Setup (command)(hd0)
used to reinstall GRUB
GRUB2: [E] key
used to edit GRUB menu item
GRUB2: [Esc] key
go to previous menu item
GRUB2: Ctrl+x or F10
boots a selection or modified line
GRUB (legacy) /boot
- ‘boot volume’ for GRUB
- kernel and related files are stored here
- kernel config file
- kernel initrd (ramdisk) file
- default boot message
- system map file
/boot/grub
-Legacy GRUB configuration directory
menu.lst/grub.conf
GRUB options and builds the menu of choices displayed on boot
GRUB Legacy menu list:
deftault=[#]
determines the menu option that will be started if nothing else is chosen
GRUB Legacy menu list:
timeout=[#]
the amount of time, in seconds, you have to choose another option
GRUB Legacy menu list:
title [description]
text based description of the menu entry
GRUB Legacy menu list:
root [(hd#,#)]
hard drive device number and partition of the root drive (where the kernel is)
GRUB Legacy menu list:
initrd [/boot/initrd#.img]
path to the initial RAM disk image for the chosen menu entry
GRUB2: /boot
- ‘boot’ volume for GRUB2
- kernel config file
- kernel initrd (ramdisk) file
- default boot message
- system map file
GRUB2: /boot/grub
- compatibility with GRUB directory
- sometimes will contain splash image for the boot menu
/boot/grub2/grub.cfg
-combination of a number of files when the grub2-mkconfig utility is used
/boot/grub2/fonts
default and custom font for the GRUB2 menu
/boot/grub2/themes
themes for the GRUB2 graphical menu
/etc/grub.d
-numbered files that, when the grub2-mkconfig utility is run, all are concatenated to make the /boot/grub2/grub.cfg (menu) file
/etc/deftault/grub
file containing the GRUB2 specific configurations
grub2-install
installs GRUB2 to the indicated location
APT - Advanced Package Tool
-installs applications and their dependencies
-remove applications
-updates and upgrades packages
-reads /etc/apt/sources.list
directs installation and uninstallation of packages to dpkg
/etc/apt/sources.list
configuration file that lists out repository locations for packages
apt-get update (command)
updates the local apt cache with a listing of packages that can be updated/upgraded and installed
apt-get upgrade (command)
upgrades the packages that have updates available
apt-get install (package name)
installs a package from the repositories in the sources.list file
apt-get remove (package name)
removes package from the system but any config files that came with the package will be left behind
apt-get purge (package name)
0r dpkg –purge
removes the package from the system and any associated configuration files
apt-get dist-upgrade
upgrades all packages on the system up to the next release of the distro
apt-get download (-d) (package name)
- downloads the package and places in /var/cache/apt/archives
- does not install it
Shared Library
- files containing functionality that other applications can use
- files can end in a ‘.so’ extension - for ‘shared object’
Shared Libraries are found here
-/lib
-/usr/lib (32 bit)
-/usr/lib64 (64 bit)
/usr/local/lib
-/usr/share
Two types of library files
- dynamic - ends in.so
- statically linked - ends in .a
ldd
prints out shared object library dependencies
ldconfig
- configures dynamic linker run-time bindings
- creates a cache based on library directories and can show you what is cached
/etc/ld.so.conf
configuration file that points to directories and other configuration files that hold references to library directory locations
LD_LIBRARY_PATH
Legacy environment variable that points to a path where library files can be read from
Shared Libraries: Soft links
where specific library versions are linked to a more generic name
Static linking
- application contains a full copy of the library that is used
- application will have exact library version it expects with known interfaces
- size is a disadvantage
Dynamic linking
- application uses the library externally using ‘stubs’, the library is installed on the OS itself but not installed with the app
- size is an advantage
ld.so
any time an app needs to use a shared library, the ld.so is called
-known as ‘dynamic linker’
Repository
remote location that you can download and install packages from using any of the package management tools
/etc/apt/sources.list.d
- files that define one or more remote repository locations for package download and installation
- each may contain lines for both packages and another for package resources
apt-get
Package manager that can install, reinstall or remove packages and all their dependencies at the
same time
apt-cache
allows you to interact with the cache of available packages from all configured repositories
apt-cache search [value]
search for packages matching the indicated value
apt-cache show [packagename]
show available information about the indicated package
apt-cache showpkg [packagename]
additional technical information about the package
aptitude and synaptic
- similar to apt and uses it in the background
- has a graphical front end
dpkg package
- application or utility
- default configuration files
- how and where to install files
- listing of dependencies the package requires
- apt handles the dependencies
dpkg –info [packagename] or
dpkg -I (capital i)
displays package contents
dpkg –status [packagename]
abbreviated display of the –info option
dpkg -l [packagename or partial name]
lists out package(s) that match the string provided
dpkg -i (–install) [packagename]
- will install the indicated package name
- fail if there are missing dependencies
dpkg -L (–listfile) [packagename]
list all files that were installed with the indicated package
dpkg -r (–remove) [packagename]
removes the package’s files but any configuration files and directories will be left alone
dpkg -P (–purge) [packagename]
removes the package’s files AND and configuration files and directories associated with it
dpkg -S (–search) [filename]
search for the indicated installed file within the package database for all mentions of the file or string
dpkg-reconfigure [packagename]
allows for modification of a package by re-running the application’s configuration tool
dpkg –force-reinstreq [packagename]
allows you to force the removal of a package marked as requiring install
dpkg –force-depends [packagename]
used with -i to force the install of a package with missing dependencies
dpkg –force-conflicts [packagename]
- used with -i to force install a package with conflicting dependencies
- forcing installations may leave system unusable
yum (Yellowdog Updater, Modified)
- originally used for Yellowdog Linux distro
- handles RPM package dependencies
- installs, upgrades, removes packages
- RHEL, CentOS, Scientific LINUX
yum setup
- global yum config options are set in /etc/yum.conf
- reads repository information from /etc/yum.repos.d/
zypper
-RPM package manager for SUSE Linux
zypper repos (command)
will list out the individual repositories that zypper uses for install and upgrade of packages
zypper install vim (command)
will install the vim package
DNF - Dandified yum
- used in Fedora
- future replacement for yum in Red Hat
- uses same command syntax as yum
yum update/upgrade
will read the configured repositories and local cache, and upgrade all installed system apps
yum search
searches the yum repositories for specified package
yum info
lists information about a specified package
yum clean all
cleans up all of yum’s cache information and it’s local database file
basurl line within the repo file
web address that indicates where packages are downloaded from
yum install [packagename]
- installs a specified package and all of its dependencies
- -downloadonly will just download the indicated package
yum remove
uninstalls a package and leaves dependencies behind
yum autoremove
-uninstalls a package and its dependencies
yum whatprovides
find out what package provides a specified file name
yum reinstall
reinstalls a specified package
/etc/yum.conf
default yum config file. may contain some repository definitions
/etc/yum.repos.d
individual ‘*.repo’ files containing the location and options for remote repositories
/var/log/yum.log
default yum transaction log file
yum –enablerepo [reponame]
enable a disabled repo for the current transaction only
/var/cache/yum/[architecture]/[version]/base/packages
directory the package will be downloaded to
-y on a yum command
will skip affirmation step
yumdownloader
allows you to download a package only, but provides additional functionality
yumdownloader –source
download only source RPM
yumdownloader –urls
display the URL of the files without downloading
yumdownloader –destdir
allows you to indicate the directory to store the package download
yumdownloader –resolve
includes any dependencies
.rpm package
- application or utility
- default config files
- how and where to install the files that come with the package
- listing of dependencies the package requires
rpm -qpi
- displays information on a package
- same as yuminfo
rpm -qpl
list files in a package
rpm -qa or yum list installed
lists out all installed packages
rpm -i
installs a specified package
rpm -U
upgrades an installed package
rpm -e
uninstalls a package
rpm -Va
verify all installed package
rpm2cpio
converts a .rpm file into a cpio archive file
/var/lib/rpm
RPM database directory
rpm –rebuilddb
- rebuilds the local RPM database in the /var/lib/rpm directory
- only performed by root
rpm -q [packagename]
shows all packages meeting the indicated values that are installed
rpm -qi [packagename]
-detailed information about an installed package
rpm -ql [packagename]
listing of all files in the package
rpm -qip [package.rpm]
- show the appropriate details about a file NOT installed as named
- will show information on a package before install
rpm –changelog [packagename]
display the changelog for the indicated package
rpm -qc [packagename]
display all configuration files for the indicated package
rpm -qRp [package.rpm]
show the requirements of the indicated rpm file
rpm -qf
will show the package that the indicated file dependency belongs to
rpm -K
validate for the indicated package
rpm –import
import the indicated keyfile from the package maintainer
rpm -v
print verbose information
rpm -h (–hash)
during activity, print a ‘status’ bar using hash ‘#’ character
rpm –force
option added during install or removal to force install/removal
rpm –replacefiles
option added during install, that replaces duplicate files
rpm -V
verify the integrity of a package
rpm -Va
verify ALL installed packages
rpm -Vac
verify ALL installed package config files on the system
rpm -F (–freshen)
will ONLY upgrade the indicated package if it’s already installed
rpm -e (–erase)
erases the indicated package name
Virtual Machine
- emulation of a specific OS
- share same physical hardware
- isolated from hardware and communicates through Hypervisor
VM/Hypervisor Examples
- KVM
- QEMU
- VMWare
- Xen
- VirtualBox
Full virtualization
guest system is not aware that it is a virtual machine
paravirtualization
- guest system is aware that it is a virtual machine, uses guest drivers
- VMs perform better with guest drivers
dbus-uuidgen or dbus-uuidgen –get
ensures that each running kernel interacts with a system that has a unique ID
cloud-init (command)
- used to ensure user data is completely new
- creates new SSH keys
- sets system’s default locale
- sets system’s host name
- sets up mount points
Cloud Virtual Machines
- AWS
- Azure
- Rackspace
Container
- isolated set of packages, libraries and/or applications that are independent from their surroundings
- use shared OS
- more resource efficient
Machine container
shares a kernel and file system with the host computer
Application container
- shares everything but the application files and library files the application needs
- useful on a web server
Container example
- Docker
- nspawn (systemd)
- LXD
- OpenShift
Linux Shell
- bash is default
- csh - C programming style syntax
- ksh - KornShell includes elements of Bash and C
- zsh - Z Shell includes elements of Bash and Korn
Environment Variable
settings that dictate common functionality and locations
env
command that displays environment variables except shell settings
echo
versatile command that can be used to print the value of a variable
set
displays shell settings or shell variables for the session
unset
removes a variable or custom bash function
shopt
displays shell options and their current settings
set -x
turns on debugging with the bash shell
set +x
turns off debugging
shopt -s (option)
to set or enable option
export (command)
used to export a variable to the current shell and any new shells started from the current shell
which (command)
-shows the full path of (shell) commands
type (command)
determines if something is a function, file, alias, built-in or keyword
“weak” quotes
double quotes will expand variables, but characters used for path substitutions or pattern matching will not be expanded
‘strong quotes’
inside strong or single quotes. nothing is interpreted
history (command)
shows most recently used commands
.bash_history
file located in user’s home directory that contains the previously run commands
HISTFILESIZE
- environment variable that determines how many lines the bash_history file will contain
- default is 500
Man page - Section 1
executable programs or shell commands
Man page - Section 2
System calls - functions provided by the kernel
Man page - Section 3
Library calls - functions within program libraries
Man page - Section 4
special files - typically found in /dev
Man page - Section 5
file formats and conventions
Man page - Section 6
games
Man page - Section 7
miscellaneous terms and conventions
Man page - Section 8
system admin commands
Man page - Section 9
kernel routines
man -k or
apropos
used to search man pages for a key word
man [section number]
pulls up a specific section of a man page
less
read-only text view
head
bring up first 10 lines of a file
tail
last 10 lines of a file
zcat
view gzip compressed text file
bzcat
view bunzip2 compressed text file
xzcat
view XZ compressed text file
nl (file)
prints the number of lines in a file
od
- octal dump command
- print out file in octal or other formats
md5sum
calculates and checks a file’s hash based on MD5