These are my notes as I prepare to take the CompTIA Linux+ LX-103 Exam.
[Source: http://linuxacademy.com]
System Architecture
SECTION 1
Determine and Configure Hardware Settings
modprobe
-- auto load/unload dependent kernel modules. preferred toinsmod
andrmmod
.lsusb
-- usb bus info; reads/dev/bus/usb
dir for config and contents./proc
-- virtual system info./proc/interrupts
-- show IRQ's in use./proc/dma
-- show DMA addresses in use.- DMA's -- alternative method to communicate with I/O ports.
lsmod
-- list modules loaded in the running kernel.insmod
-- old method to insert kernel modules.rmmod
-- old method to remove kernel modules.
SECTION 2
Boot the System
dmesg
-- extract info about boot process.- kernel -- main part of OS. runs threads, devices, filesystems, video, etc.
- BIOS -- basic input output system. prepare system for boot. find CPU, mem, disk.
- EFI/UEFI -- new systems use instead of BIOS. (? abbr.)
- boot process 1 -- CPU starts then runs BIOS.
- boot process 2 - BIOS checks for and configures hardware, looks for boot sector on disk.
- boot process 3 -- BIOS hands off to GRUB boot loader.
- boot process 4 -- GRUB finds kernel, loads into memory, executes it.
- boot process 5 -- GRUB hands off to kernel. kernel performs system tasks, loads
init
from/sbin/init
. - boot process 6 --
init
given PID of 1.
/var/log/messages
-- global system messages. contains post-boot messages. also: messages, errors, and info from apps that communicate with kernel, modules, drivers.dmesg
--/var/log/messages
generally./var/log/dmesg
on some distros (?). contains kernel ring buffer info. shows messages about devices that kernel detected during bootup.
SECTION 3
Change Runlevels and Shutdown or Reboot the System
etc/inittab
-- sysvinit systems file for setting default run level. systemd redirects this tolib/systemd/system/<target-name>.target
.shutdown -k
-- warn of impending shutdown but doesn't shutdown.shutdown -r
-- reboot after shutdown.shutdown -h
-- halt and power-off.- `shutdown -P -- (?) half-action to turn off power.
shutdown -f
-- skipfsck
on next boot.shutdown -F
-- forcefsck
on next boot.shutdown -c
-- cancel a pending shutdown.shutdown -t
-- tellinit
to wait X # of seconds before shutting down.init
-- change run level or shutdown. last process to run during boot.- run level 0 -- shut down.
- run level 1, s, S -- single-user mode for low-level system maintenence: e.g. resizing partitions.
- run level 2 -- debian multi-user mode with
X
running and graphical login. undefined on other distros. - run level 3 -- RHEL/fedora/mandriva/etc. multi-user mode with console non-graphical login.
- run level 4 -- undefined; customizable.
- run level 5 -- RHEL/fedora/mandriva multi-user mode with
X
and graphical login. - run level 6 -- reboot/transitional.
init 1
-- change to run level 1.id:2:initdefault
-- set to default run level 2 in/etc/inittab
.N 2
- previous:current run level (?).id:runlevels:action:process
-- (?).id
-- 1-4 character sequence that idenfifies a function (?).runlevels
-- query run levels for a given entry (?).action
(?)wait
(?) -- tellsinit
to start process when entering specified run level and wait for process to terminate.respawn
-- tellinit
to restart the process whenever it terminates.
Linux Installation and Package Management
SECTION 4
Design a Hard Disk Layout or Partitioning Scheme
/var
-- contains files that change frequently./home
-- user directories.- partitions --
/var
and/home
could be on separate partitions.
SECTION 5
Install a Boot Manager
- Type codes:
- 0x0c - FAT.
- 0x05 - deprecated extended partition type.
- 0x07 - NTFS.
- 0x0f - new extended partition type.
- 0x82 - Linux swap.
- 0x83 - Linux file system.
- GRUB1 config:
/boot/grub/menu.list
. - GRUB2 config:
/boot/grub/grub.cfg
.
SECTION 6
Manage Shared Libraries
ldd
-- print shared library dependencies for a given program/file.LD_LIBRARY_PATH
-- bash env variable for additional library locations to search when looking for shared libraries.ldconfig
-- clear library cache after adding library locations to/etc/ld.so.conf
.
SECTION 7
Use Debian Package Management
/etc/apt/sources.list
-- list of repositories to search for system-compatible software for install.apt-get
-- package handling and installation for debian-based distros. install by name; include dependent packages.dpkg
-- install.deb
package files in debian-based systems.-i
-- install and configure.-r
-- remove package.-configure
-- configure package.-c
-- list contents of package.-s
-- list status of packages (installed or not).
apt-cache
-- search packages named or installed.apt-cache [pkgnames]
-- show installed.apt-cache search [pkgnames]
-- search for named package (not-installed).dpkg-reconfigure
-- reconfigure already installed packagesaptitude
-- high-level package management interface for debian-based distros.
SECTION 8
Use RPM and YUM Package Management
prm
-- package installation utility for red hat distros.-nodeps
-- install regardless of installed dependencies.-i
-- install.-K
-- check package signature.-V
-- verify package.-a
-- all packages.-Va
-- verify all packages.
-U
-- upgrade or install new package-F
-- upgrade installed packaged (only if it exists)-q
-- query a package. determine if installed or not.-e
-- erase/uninstall.-f
-- query package owning file (?).-p
-- package (named).-l
-- list files in package.-rebuild
-- rebuild source package.-rebuilddb
-- rebuild rpm database.-qa
-- print all installed packages.ql
-- list files in an installed package.qf
-- determine which installed package a file belongs to.-qpl
-- list all files in an RPM package.-checksig
-- same as-K
; check package signature.
/etc/yum.repos.d
-- directory containingyum
repository files.cpio
-- create CPIO archive (?).-d
-- create leading directories where needed.-i
-- extract.-u
-- replace all files without asking.-m
-- retain previous modification times when creating files.
rpm2cpio
-- convert RPM packages to CPIO compressed files. extract files from RPM package without installing it.rpm2cpio file.rpm | cpio -dium
GNU and Unix Commands
SECTION 9
Working on the Command Line
make
-- compile source code, install binaries.env
-- show current session environment variables.bash
-- bourne again shell. command language shell interpreter. executes commands from standard input or from files.uname
-- prints system information.-n
-- node name-s
-- kernel name-v
-- kernel version-r
-- kernel release-m
-- machine/cpu info-p
-- processor info-i
-- hardware info-o
-- operating system name-a
-- print all info
export
-- set an environment variable.export HOME=/home/user
-- set$HOME
to specified directory in env.
unset $HOME
-- unset/remove the$HOME
variable from env.man
-- manual pages:- 1 -- executable programs and shell commands
- 2 -- system calls (kernel functions)
- 3 -- library calls (library program functions)
- 4 -- special files (usually found in
/dev
) - 5 -- file formats and conventions, e.g.
/etc/passwd
- 6 -- games
- 7 -- miscellaneous, including macro packages and conventions
- 8 -- system administration commands (root)
- 9 -- kernel routines [non-standard]
SECTION 10
Process Text Streams Using Filters
cat
-- concatentate/combine files, display a single file.fmt
-- reformat streams or files for display, e.g. width of columns.join
-- join file lines based on delimiters:-t
-- delimiter as specified-1 [field]
-- join on given field of file #1-2 [field]
-- join on given field of file #2
pr
-- convert file for printing. adds header, footer, and page breaks.split
-- split a file into pieces:split -l 2 file.txt newname
-- split every two lines and namenewnamea
,newnameb
, etc.- (?) -- default
-b
split 512 bytes (?).
unexpand
-- convert spaces to tabs.expand
-- convert tabs to spaces.cut
-- remove sections from file lines using delimiters and fields.head
-- display only the first part of a file.-c [X]
-- display only the first [X] bytes.-n [X]
-- display only the first [X] lines.
nl
-- add line numbers to file for display or redirect purposes.sed
-- stream editor for filtering and formatting text.sed 's/ugly/beautiful/g' myfile.txt
-- replace all instances of 'ugly' with 'beautiful' in myfile.txt.
regex
-- regular expressions.- GNU tool under POSIX standard
- includes
sed
,awk
,grep
,egrep
,ed
, etc. [ \t]
-- match 'white space tab`[ \t\r\n]
-- match 'line break'([A-Z])
-- match alpha character range in caps
tail
-- display only the last part of a file.-c [X]
-- display only the last [X] bytes.-n [X]
-- display only the last [X] lines.
uniq
-- report or omit repeated lines.-d
-- only print duplicate lines-u
-- only print unique lines-r
-- recursive (?)
od
-- dump files inoctal
format (?).paste
-- merge lines of given files.sort
-- sort file contents forward or reverse by alphanumeric characters.tr
-- translate/squeeze/delete characters from standard input writing to output (?).tr test [texttotrim] < test
-- send contents of test file to standard input and trim out 'texttotrim'.
wc
-- perform a word or character count on given file.
SECTION 11
Perform Basic File Management
cp
-- copy files and directories.-a
-- archive-backup
-- back up each destination file-d
-- preserve links (?)
mv
-- move files and directories-f
-- do not prompt for overwrite-i
-- prompt for overwrite; interactive mode-n
-- no clobber; prevent overwrite of existing files
touch
-- change file date/time attributes-a
-- update access time only-c
-- do not create if file doesn't exist-d
-- parse string and use string instead of current time (?)-m
-- update modification time only-r
-- use given file's times instead of current time (?)-t
-- use specified timestamp
dd
-- copy file, converting and formatting according to operands.gzip
/gunzip
-- compression utility. used withtar
(for archiving).-d
-- decompress-f
-- force-h
-- help-l
-- list contents-q
-- quiet mode-t
-- test but don't perform operation-v
-- verbose mode
mkdir
-- make directory-p
-- create all directories in the given parent chain, e.g./dir/subdir/subsubdir
tar
-- tape archive utility for backups-d
-- show differences between archive and source file system--delete
-- delete specified contents/files from archive-c
-- create new archive-A
-- append tar files to existing archive-r
-- append files to existing archive-u
-- append only newer versions of files to existing archive-t
-- list archive contents-x
-- extract files from archive-z
-- filter archive throughgzip
-j
-- filter archive throughbzip2
-J
-- filter archive throughxz
compression tool
file
-- determine file typebzip2
-- compression utility. used withtar
(for archiving).
SECTION 12
Use Streams, Pipes, and Redirects
&&
-- run [command1] and then [command2]. e.g.cd .. && ls
moves up one level then lists directory contents.tee
-- save standard input to file and also send to standard output.xargs
-- build and execute command with multiple arguments-a
-- reads items from file instead of standard input-0
-- input items are terminated bynull
character instead of by white spaces (?)-d
-- input items are terminated by specified character
SECTION 13
Create, Monitor, and Kill Processes
jobs
-- display basic info about running processes associated with the current sessionps
-- display processes run (by default) from owner's terminal.-Ae
-- display all users' processes-u
-- display processes of specified user- (?)
H -F
-- group processes together and show hierarchy of relationships ps -w > ps.txt
-- does not truncate results; sends output to given file
uptime
-- find uptime and display load averagebg
-- restores a job to the running status, in the background.fg
-- useCtrl+Z
to pause a program;fg
to send to foregroundkill
-- stop running processes based on process ID (PID).nohup
-- run a command immune to hangups, with output to console or non-TTY.killall
-- kill all processes sharing a given namefree
-- show free memory and swap space- common kill signals:
SIGHUP 1 HANGUP
-- (?)SIGINT 2 INTERRUPT FROM KEYBOARD
-- (?)SIGKILL 9 KILL SIGNAL
-- abrubtly terminate the programSIGTERM 15 TERMINATION SIGNAL
-- asks program to finish and then exist. preferred method oversigkill
SIGSTOP 17,19,23 STOP THE PROCESS
-- when child process exits from parent process is sends aSIGHUP 1
man -k signal
-- signal's man page
SECTION 14
Modify Process Execution Priorities
nice
-- run a program with a modified scheduling priority.renice
-- alter the priority of a running process; -20 highest, 19 lowest.top
-- display running processes dynamically.k
-- kill processq
-- quittop
r
--renice
a processs [X]
/d [X]
-- change update delay to every [X] secondsP
-- sort by CPU usageM
-- sort by memory usage-p [PID],[PID],[PID]
-- display up to 20 specific processes (command line only)-n [X]
-- update [X] times and then quit-b
-- run in batch mode. for output to other files. non-interactive. command line only.
SECTION 15
Search Text Files Using Regular Expressions
grep
-- search using regular expressions-v
-- find lines NOT matching given string/parameters-i
-- ignore case[^abc]
-- match any character not contained in brackets^example
-- match lines starting with 'example'example$
-- match lines ending with 'example'*
-- match the preceding element 0 or more times. e.g.ab*c
matchesac
,abc
, andabbbbc
.+
-- match the preceding element 0 or more times
egrep
-- extended regular expressions. same asgrep -e
.fgrep
-- search using fixed strings (more literal). find any number of lines given as search strings/parameters. same asgrep -f
.
SECTION 16
Perform Basic File Editing Operations Using vi
vi
/vim
-- command line text editori
-- insert mode. insert text left of the cursor.I
-- insert text at beginning of linea
-- append text to the right of the cursoro
-- insert text on new line below last line of fileO
-- insert text on new line above first line of file/word
-- find next occurrence of 'word'n
-- repeat last search; find next occurrence?word
-- find previous occurrence of 'word'c
-- change text under cursor to new word typed (?)d
-- delete text that {motion} move over[X]dd
-- delete [X] number of linesy
-- yank (copy) text that {motion} passes over (to be pasted elsewhere later)[X]yy
-- yank [X] number of linesp
-- put/paste text copied previously (after the cursor)P
-- put/paste text copied previously (before the cursor)h
-- move LEFTj
-- move DOWNk
-- move UPl
-- move RIGHT2h
-- move LEFT 2 spacesZZ
-- save and quitwq!
-- save and force quitq!
-- quit without savinge!
-- discard changes and edit original again
Devices, Linux Filesystems, and the Filesystem Hierarchy Standard
SECTION 17
Create Partitions and Filesystems
fdisk
-- partition a disk-n
-- interactive mode
mkfs
-- build a filesystem-t [type]
-- specify filesystem type: ext2/3/4, FAT, btrfs, etc.-c
-- check device for bad blocks before building
mkswap
-- create swap partition on existing filesystem.swapon
/swapoff
-- turn swap on or off
SECTION 18
Maintain the Integrity of Filesystems
du
-- estimate file space usage on a disk-c
-- show grand total-h
-- human-readable format--max-depth [X]
-- print the total for given directory only down to [X] number of levels-b
-- display size in bytes
dumpe2fs
-- obtain filesystem informationxfs_info
-- obtain filesystem information for xfs filesystemsdf
-- display filesystem usage, across filesystems.df .
-- show mount location of current working directory- shows only total usage of each filesystem
mke2fs
-- create an ext2/3/4 filesystem.tune2fs
-- change filesystem parameters, fs cannot be mounted.- maximum mount count
- time between checks
- add a journal
- set reserved blocks
- obtain filesystem level (?)
fsck
-- check and repair a filesystem-A
-- try to check all filesystems listed in/etc/fstab
-a
-- attempt to automatically repair all errors (?)-C
-- display completion/progress-N
-- don't execute; simulate what would be done instead
debugfs
-- modify filesystem interactively- undelete a file from an unmounted file system with
inode
number
- undelete a file from an unmounted file system with
SECTION 19
Control Mounting and Unmounting of Filesystems
mount
-- attempt to mount filesystems to specified directories-a
-- mount all filesystems listed inetc/fstab
as indicated-o
-- override mount options listed inetc/fstab
during manual mount
unmount
-- unmount given filesystem(s)-f
-- force unmount even if busy
etc/fstab
-- persistent filesystem mounting configuration file (for mounting on boot).
SECTION 20
Manage Disk Quotas
quotaon
-- turn quotas onedquota
-- edit a given quota-p
-- duplicate/copy the quotas of an existing user quota to new users
repquota
-- summarize quotas for a given filesystem-a
-- print quotas of all filesystems configured with a quota mount-g
-- print only group quotas-v
-- print a header line before printing each filesystem quota (?)
SECTION 21
Manage File Permissions and Ownership
setuid
/setgid
-- set user and group ID. allow to run executables as if they were the owners of those files/programs.chmod 2711
-- sets group idchmod 4711
-- sets user idchmod 6711
-- sets group and user idu+s
-- set user ID, octal bit '4'g+s
-- set group ID, octal bit '2'+t
-- set sticky bit, octal bit '1'
chmod
-- change file/directory access attributes- 1 -- execute
- 2 -- write
- 4 -- read
chgrp
-- change group ownership of files/directoriesumask
- change default user level permissions for files/directories when createdchown
-- change ownership of files and directories-R
-- recursion switch forchown
,chgrp
,chmod
, etc.
SECTION 22
Create and Change Hard and Symbolic (Soft) Links
ln
-- create link between files and directories. hard link by default.-s
-- soft link- if you remove the source file on a hard link the link file will still exist
SECTION 23
Find System Files and Place Files in the Correct Location
find
-- find files on local or any mounted filesystemwhich
-- display the path of the indicated command. must be in $PATH variable.whereis
-- locate sources, binaries, and manual-sections for specific files./etc/updatedb.conf
-- location database configuration filelocate
-- find files by name. uses location database/etc/updatedb.conf
.- FHS -- filesystem hierarchy standard.
- unified directory trees -- all files, devices, and disks accessible from single directory tree
- system files include: startup scripts, daemons, program files, binaries, support files, config files, databases, log files,
/etc/shadow
for encrypted passwords - system files and programs use system accounts for access
/home/user
-- default user file storage location- shareable files -- shared between computers, includes data and binaries, may be placed on Network File System (NFS)
- unshareable files -- contain system-specific info and configurations
- static files -- only change through sysadmin edits typically, e.g. program executables
- variable files -- modified by users, scripts, servers, etc.
- FHS common linux directories:
/
-- root/etc
-- system config files/etc/fstab
-- define partition mount parameters/etc/passwd
-- primary account definition file/etc/X11
-- 'X' windows system/etc/samba
-- samba file server configuration directory
/boot
-- boot files, linux kernel, initramfs/initial RAM disk/bin
-- program files that users may run/sbin
-- program files seldom run by users/lib
-- libraries (code used by other programs)/usr
-- non-critical programs and data/home
-- user home directories. isolate on separate partition to protect user data./root
-- root user home directory/var
-- transient, frequently modified files/var/tmp
-- temporary files; not to be deleted on reboot
/tmp
-- temporary files to be deleted on reboot (ok to delete)/mnt
-- removable media mount point with subdirectories for each mounted filesystem/media
-- new(er) mount point for removable media, with subdirectories for mounted filesystems/dev
-- device files and system hardware directories
- FHS access standards -- users can access
/media
and/mnt
, but not most system directories. - executable directory program files -- stored in
/sbin
,/bin
,/usr/bin
,/usr/sbin
,/usr/local/sbin
, and/usr/local/bin
. - library directories -- stored in
/lib
,/usr/lib
, and/usr/local/lib
. - example distribution of a single program's files -- executables in
/usr/bin
; libraries in/usr/lib
; configuration files in/etc
or/home/user
.
2015 Objective Updates
SECTION 24
Upstart
- Upstart -- replaces old SysVInit daemon init program.
- can start jobs/services asynchronously.
- can listen for and execute jobs based on system events.
- config in
/etc/init
. - backwards compatible with run levels and SysVInit.
service
-- command to manage jobs.
- Upstart new commands:
initctl list
-- list jobs from/etc/init
.init-checkconfig /etc/file.conf
-- check job config syntax.start [jobname]
-- start a job.stop [jobname]
-- stop a job.restart [jobname]
-- restart a job.- job management backwards compatible with
service
command.
SECTION 25
Systemd
- Systemd -- system-wide daemon-management daemon.
- first daemon to start at boot; last daemon to stop at shutdown.
- allows for the running of proc/daemon/services in parallel during bootup, etc.
- start daemons on-demand; SysVInit was sequencial (one-by-one) and limited.
- controls
shutdown
,cron
,journald
, and other low-level components. - more utilities to be added to systemd over time.
journald
-- new systemd daemon for event logging; by default non-persistent; persistence can be enabled.systemctl
-- new command which replacesservice
.- also replaces
chkconfig
.
- also replaces
- targets -- replaces run levels.
- systemd PID = 1.
journalctl
-- query systemd journal
SECTION 26
Systemd Commands and Directories
systemctl restart httpd.service
-- restart httpd.systemctl enable httpd.service
-- enable to start at boot.systemctl stop httpd.service
-- stop httpd.systemctl isolate graphical.target
-- move into graphical target.systemctl set-default graphical.target
-- make graphical the default target to boot into.systemctl get-default
-- get current default target setting./usr/lib/systemd/system
-- core system unit config file directory./etc/systemd/system
-- custom config directory. overridden by like-configurations in system unit config library.systemctl -t help
-- display available unit types on system.systemctl list-units --type=target | grep target
-- show all active (enabled) targets.systemctl list-unit-files --type=target -all
-- show all available targets, enabled or disabled.- default target symlink -- goes from
/etc/systemd/system/default.target
to target config file (?). wall
-- broadcast message to all logged in users.-n
-- suppress 'from user' notification.- type message, end with
ctrl+d
to send message.
SECTION 27
Managing MBR and GPT Partitions
- GPT -- 128 partitions max.
- GPT -- 9.4ZB or 8ZiB max size.
- MBR -- older partition format; 4 max.
- MBR -- 2TiB max size.
fdisk
-- manage MBR partition tables.gdisk
-- manage GPT partition tables.parted
-- manage GPT partition tables.
SECTION 28
Commands and Compression
screen
-- full-screen window manager. multiplexes physical terminal between several processes.-d
-- start in detached mode. forks a new process.-D
-- start in detached mode. same process. command exists if session terminates (?).-S
-- session name.-x
-- attach to a session that is not detached.-X
-- send specified command to an already running screen session.screen -list
-- list all current screens.screen -r [name]
-- reattach named screen.
- XZ compression:
- better compression ratio than
gzip
. - more memory intensive.
xz -flag [filename]
syntax.-z
-- compress-d
-- decompress/uncompress.-l
-- list compressed file info and compression ratio.
- must first
tar
(archive) the directory.
- better compression ratio than
pkill
andpgrep
- identify process based on regex/pattern
pgrep -u user
-- list all processes from 'user'.pgrep -l -u user
-- list and display all processes from 'user' (?).pkill -t ttyid
-- kill all processes from specified terminal.pgrep -v -u user
-- show all processes not belonging to 'user'.pgrep -n user
-- show PID for most recent process from 'user'.pgrep -l -u user sshd
-- show allsshd
processes from 'user'.pkill httpd
-- kill allhttpd
processes.pkill -u user sshd
-- kill allsshd
processes from 'user'.
dmesg
-- view messages in kernel ring buffer.- troubleshoot kernel, memory, boot issues.
dmesg > boot_messages
-- output contents to 'boot_messages' file.dmesg | grep -l tty
-- output first 'tty' message in kernel ring buffer.dmesg | grep memory
-- output messages about memory.
SECTION 29
GRUB2
grub2-mkconfig > /boot/grub2/grub.cfg
-- make or remake grub2 config file./boot/grub2/grub.cfg
-- comprised of configuration files from/etc/default/grub
and/etc/grub.d
.grub2-install /dev/device
-- install or reinstall grub2 on specified device.