Linuxacademy Lpic101 Studysheetmarch2015 1426896104
Linuxacademy Lpic101 Studysheetmarch2015 1426896104
2015
LPIC-1 Exam 101 – Study Sheet
1
LPIC-1 Exam 101 – Study Sheet
2
LPIC-1 Exam 101 – Study Sheet
Introduction
This study sheet is intended to help you do a targeted review of key topics that are very likely to
be covered during your LX0-101 LPIC exam. This is not intended to replace any quizzed, labs or
lectures here at Linux Academy, but can be used as a final review just prior to your exam.
3
LPIC-1 Exam 101 – Study Sheet
4
LPIC-1 Exam 101 – Study Sheet
• Boot Process
1. CPU starts and then runs the BIOS.
2. BIOS checks for hardware, configuring hardware and looking for a boot sector.
• Newer systems can use EFI/UEFI instead of BIOS
3. Boot loader (grub) takes over for the bios.
4. Find a kernel, load it into memory and execute it.
5. Kernel takes over, performs systems tasks, and loads the final process of
executing the initial program for your system. By default, this is the program
/sbin/init.
6. The initial program gets the process ID (pid) of 1.
• /var/log/messages
• Contains detailed post boot messages for your system as well as
messages/errors/information from applications that communicate with your
kernel, kernel modules (drivers, etc) – often referred to as the contained of
“global system messages”
• dmesg
• /var/log/dmesg: on some Linux distributions
• Contains “kernel ring buffer information”
• prints number of messages on the screen that display information about the
hardware devices that the kernel detected during the boot process
5
LPIC-1 Exam 101 – Study Sheet
6
LPIC-1 Exam 101 – Study Sheet
7
LPIC-1 Exam 101 – Study Sheet
8
LPIC-1 Exam 101 – Study Sheet
9
LPIC-1 Exam 101 – Study Sheet
10
LPIC-1 Exam 101 – Study Sheet
11
LPIC-1 Exam 101 – Study Sheet
• unexpand
• converts spaces to tabs
• expand
• converts tabs to spaces
• cut
• used to remove sections from each line of files
• head
• output the first part of a file
• –c: XX bytes
• –n: XX lines
• nl
• add line numbers to a file for display or redirect to another file
• 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
• short for regular expressions
• referred to as the GNU tool implementation of the regular expression POSIX
standard
• encompasses tools like sed, awk, grep, egrep, ed, etc
• examples:
• [ \t] would match white space tabs
• [ \t\r\n] would match line breaks
• ([A-Z]) would match the alpha characters in caps
• tail
• output the last part of a file
• –c: XX bytes
• –n: XX lines
• uniq
• report or omit repeated lines
• –d: only print duplicate lines
• –u: only print unique lines
• –r: recursive
• od
• dump files in octal format
• paste
• merge lines of files
• sort
12
LPIC-1 Exam 101 – Study Sheet
13
LPIC-1 Exam 101 – Study Sheet
• –q: quiet
• –t: test
• –v: verbose
• mkdir
• make directories
• –p: make all directories in parent chain
• tar
• tape archive utility, used for backups
• -d Find differences between archive and file system
• --delete Delete from archive
• -c Create a new archive
• -A Append tar files to an archive
• -r Append files to the end of an archive
• -u Only append files newer than copy in archive
• -t List contents of an archive
• -x Extract files from an archive
• -z filter through gzip
• -j filter through bzip2
• -J filter through xz compression
• file
• Determine file type
• bzip2
• compression utility, used in conjunction with tar for archiving
14
LPIC-1 Exam 101 – Study Sheet
• The tee command will save standard input to a file as well as sending it to
standard output. t command can be used to save standard input into a file as
well as send it to standard output
• xargs
• Build and execute command
• -a Reads items from file instead of standard input
• -0 Input items are terminated by a null character instead of by white spaces.
• -d Input items are terminated by the specified character
15
LPIC-1 Exam 101 – Study Sheet
§ This signal is unblock able and causes the program to terminate abruptly.
Only use if you can’t terminate with 15.
• SIGTERM 15 TERMINATION SIGNAL
• It asks the program to finish what it is doing then exit. Clean exists and is
the preferred way of killing processes.
• SIGSTOP 17,19,23 STOP THE PROCESS
• When a child process exits from a parent process it sends signal 1.
• Signals in the man page man –k signal
16
LPIC-1 Exam 101 – Study Sheet
• grep
• -v - Selected lines are those not matching any of the specified patterns.
• egrep is the same as grep -E: interpret pattern as an extended regular
expression.
• fgrep is the same as grep -F: interpret pattern as a list of fixed strings,
separated by new lines any of which is to be matched.
• -i Ignores case and Matches any single character
• [^] Matches any character not contained in brackets [^abc] matches any
character other than a, b, or c.
• ^ Matches the starting position of a line.
• $ Matches the ending position of a string or the position just before a
string ending new line it matches the ending position of any line
• * Matches the preceding element 0 or more times ab*c matches b zero or
more times. IE ac, abc, abbbbc, abbbbbbbbbbbbbc.
• + Matches the preceding element 1 or more times
17
LPIC-1 Exam 101 – Study Sheet
18
LPIC-1 Exam 101 – Study Sheet
Description: Candidates should be able to maintain a standard filesystem, as well as the extra
data associated with a journaling filesystem.
• du
• estimate file space usage
• -c Produce a grand total
• -h Human readable
• --max-depth - Print the total for a directory only if it is N or fewer levels
below the command line argument.
• -b – Bytes
• dumpe2fs
• Obtains file system information. xfs_info does the same thing but for ifs
file system
• df
• Displays the filesystem usage, but not a breakdown within the file system
• df . - Will show where your working directory is mounted
• mke2fs
• create an EXT2/3/4 filesystem
• equivalent of “mkfs –t ext2/3/4”
• tune2fs
• Allows you to change the file system parameters such as: maximum
mount count, time between checks, add a journal, set desire reserve
blocks, obtain file system level. FILE SYSTEM CANNOT BE
MOUNTED
• fsck
• checks and repairs filesystems
• -A Walk through /etc/fstab file and try to check all file systems
• -a Attempt to automatically repair all errors
• -C Display completion/progress
• -N Don't execute; just show what would be done
• debugfs
• Interactively modify a file system. Features: program provides abilities of
tune2fs and dump2fs use debug fs to undelete a file if needed. Do not use
on a mounted file system.
19
LPIC-1 Exam 101 – Study Sheet
20
LPIC-1 Exam 101 – Study Sheet
• chmod
• change file/directory access attributes
• 1 - execute
• 2 - write
• 4 - read
• chgrp
• change group ownership of files/directories
• umask
• change default user level permissions for files and directories when created
• chown
• change ownership of files and directory
• –R: all “ch” commands use this switch for recursion
104.7 Find System Files and Place Files in the Correct Location
Weight: 2
Description: Candidates should be thoroughly familiar with the Filesystem Hierarchy Standard
(FHS), including typical file locations and directory classifications.
• find
• find files on the local or any mounted file system
• which
• display path the indicated command is in (if in PATH variable)
• whereis
• locates the sources/binary and manuals section for specific files
• /etc/updatedb.conf
• Location database configuration file
• locate
• find files by name, uses the location database
• FHS
21
LPIC-1 Exam 101 – Study Sheet
Linux uses unified directory trees - therefore every partition, removable disk, network file
share, and other disk or disk-like storage device is accessible from a single directory tree
(filesystem)
• user files vs system files
• system files - Files that control how the computer operates
• System startup scripts, and daemons
• Program files, both binary and scripts
• Program support files, such as fonts and icons
• Configuration files that define how the system works (ex: network config
settings, disk layout information etc)
• Configuration files that most servers and other daemons
• Data storage for system programs, such as the database that describes what
programs are installed
• System Log files, which record normal system activity
• You would not want regular users to be able to access either read or write for
example on your system configs - other example
• /etc/shadow - this file holds encrypted passwords for instance
• Such systems files are usually owned by root or by system accounts that have
more limited rights
• Many server programs rely on there own specific system users accounts.
• Because ROOT user has access to read and write any files you protect access to
config files of server apps and system settings by having the owned by root.
• User files typically live under the /home/user directories
• Even on personal laptop Linux installs systems files are separated by rights from
root to your user to protect form accidental deletion or modification.
22
LPIC-1 Exam 101 – Study Sheet
• Static Files
• Don’t normally change except through direct editing by the
system administrator
• These would be files like the program executables
• Variable files
• Can be changed/edited by users, automated scripts, servers etc
• FHS Common Linux Directories
• / is the root directory - all files appear i the directory and the subdirectories
built off of it
• /etc Holds systems Configuration files
• /boot Holds important boot files, like the Linux kernel, initial RAM disk,
and usually boot loader config files
• /bin Holds program files that are critical for normal operation and that
ordinary users may run
• /sbin Holds program files that are critical for normal operation and that
ordinary users seldom run.
• /lib Holds libraries - code used by many other programs - these are
critical for basic system operation
• /usr Holds programs and data used in normal system operation bu that
aren’t critical for a bare-bones boot of the system
• /home Users’ home directories. By separating this directory in to its own
low-level file system you effectively isolates most user data form the
operating system - which is useful if you want to re install the OS without
losing user data
• /root is the root users home directory this is different than the / folder that
is also pronounced root
• /var Holds miscellaneous transient files. these are things like
files and print spool files. /var/tmp deserves special mention much like
the /mnt (see below) /var/tmp holds temporary files. These files should
not be deleted when the computer reboots
• /tmp Holds temp files - often including temporary files created by users
programs. While many distributions don’t delete these temp files - they
should be deleted when the computer reboots
• /mnt The traditional mount point for removable media; this is usually split
in to subdirectories for each of the then mounted file systems
• /media The new mount point for removable media, again this is split it to
subdirectories for each of the mounted file system
• /dev This holds device files, which in turn provides low-level access to
the systems hardware
23
LPIC-1 Exam 101 – Study Sheet
Executable Directories
• Program files live usually in the /sbin, /bin ,/usr/bin, and /usr/sbin Such
directories further will houses programs files in such directories as
/usr/local/sbin and /usr/local/bin as the locally compiled programs
• Library Directories * Libraries are collections of programming functions
that can be useful to programs. They are stored in separate files to save
disk space and RAM when programs are ran. Most library directories live
in /lib and /usr/lib however some can also reside in /usr/local/lib
• Windows programs typically all live within a single directory (its config
files, binary applications etc) However on LINUX most of the programs
key files are likely to reside in the above standard locations that are shared
with other programs and are scattered out.
• EXAMPLE: Programs executable lives in /usr/bin but its libraries are in
the /usr/lib and even furthermore its configuration files are in the /etc or
even in the users’ home directories.
24
LPIC-1 Exam 101 – Study Sheet
• The
ability
to
start
jobs/services
asynchronously
during
the
startup
process
which
allows
for
a
faster
bootup
period.
• Upstart
“listens”
for
events
on
a
system
and
executes
jobs
based
off
of
events
that
jobs
are
set
to
start/stop
on.
• Job
configuration
files
are
located
in
the
/etc/init
directory
• Upstart
replaces
the
SysVInit
but
replicates
backwards
compatibility
with
the
boot
process
as
well
as
runlevels,
leaving
that
architecture
the
same
on
Upstart
systems
(although
in
some
cases,
older
configuration
files
simply
being
a
text
file
pointing
to
the
new
location
of
method)
• Jobs
can
be
managed
with
the
“service”
command
• initctil
list
(list
all
jobs
located
in
/etc/init
this
does
not
list
service
files
in
/etc/init.d
• init-‐chefconfig
/etc/file.conf
-‐>
Checks
the
syntax
of
the
job
configuration
file
• start
jobname
-‐>
starts
a
job
• stop
jobname
-‐>
stops
a
job
• restart
jobname
-‐>
restarts
a
job
• Job
management
is
also
backwards
compatible
with
the
service
command.
Systemd
• Systemd is a daemon that manages all other system daemons.
• Systemd is the first daemon to start during the boot process and is the last daemon to stop
during shutdown.
• Systemd allows processes, daemons, and services to be started parallel to each other creating a
25
LPIC-1 Exam 101 – Study Sheet
Journalctl
• Used to query the contents of the systemd journal
26
LPIC-1 Exam 101 – Study Sheet
• System
directory
that
contains
the
core
system
unit
configuration
files
• /usr/lib/systemd/system
• Custom
configuration
directory
which
is
override
by
any
matching
configurations
in
the
system
unit
configuration
libraray
• /etc/systemd/system
• Display
different
unit
types
on
the
system
• systemctl
-‐t
help
• Overview
of
available
targets
• systemctl
list-‐units
-‐-‐type=target
|
grep
target
• systemctl
list-‐unit-‐files
-‐-‐type=target
-‐all
(all
will
show
all
enabled
and
disabled)
• What
is
the
default
target?
• The
default
target
is
a
sym
link
from
/etc/systemd/system/default.target
to
the
target
configuration
file
• Wall command is used to broadcast messages to all logged in users on the system
• wall -n will suppress the “from user” information and wall will open the wall console,
just typing the message and ending with crtl+d will send the message
27
LPIC-1 Exam 101 – Study Sheet
• Requires
more
memory
during
compression
but
has
lower
file
size
footprint
when
completed
• Flags
usage:
xz
-‐flag
filename
• -‐z
filename
will
compress
filename
• -‐d
decompresses
also
known
as
uncompressed
• -‐l
list
information
about
compressed
files
and
view
compression
ratios
• To
compress
a
directory
you
must
first
tar
the
directory
then
use
xz
to
compress
it
• pkill
&
pgrep
• Used
to
identify
processes
based
off
of
a
pattern
or
regular
expression
• Examples
• List
all
process
associated
with
a
user
• pgrep
-‐u
username
• List
all
processes
associated
with
a
user
and
display
process
name
• pgrep
-‐l
-‐u
username
• Kill
all
processes
started
from
a
specific
terminal
• pkill
-‐t
ttyid
• Show
all
processes
that
DO
NOT
belong
to
a
user
(inverse)
• pgrep
-‐v
-‐u
username
• Show
the
process
ide
of
the
most
recent
process
started
for
a
user
• pgrep
-‐n
• Show
all
SSHD
processes
associated
with
a
user
• pgrep
-‐l
-‐u
username
sshd
• Kill
all
httpd
processes
• pkill
httpd
• Kill
all
sshd
processes
for
a
specific
user
• pkill
-‐u
username
sshd
• dmesg
• Used
to
view
the
kernel
messages
in
the
kernel
ring
buffer
• Most
commonly
used
for
troubleshooting
kernel,
memory,
or
any
issue
related
to
boot
up
and
the
kernel
activity
• examples
• dmesg
>
boot_messages
• dmesg
|
grep
-‐I
tty
• dmesg
|
grep
memory
• dmesg
will
just
dump
the
entire
ring
buffer
to
standard
output.
GRUB2
grub2-‐mkconfig
>
/boot/grub2/grub.cfg
/boot/grub2/grub.cfg
is
made
by
the
grub2-‐mkconfig
command
and
is
made
of
up
files
in
the
/etc/default/grub
and
the
/etc/grub.d
configuration
locations.
28
LPIC-1 Exam 101 – Study Sheet
grub2-‐install
/dev/device
-‐>
will
install
grub
on
the
specified
device.
If
the
GRUB
bootloader
is
having
issues
then
re-‐installing
is
the
same
process.
29