LPI101 Notes Day 1
LPI101 Notes Day 1
Module 0: Introduction
Introduction
● LPI
● LPIC-1
● Linux+
● Certification
● LPI 101
● Timetable
● Skytap
● Linux Essentials
● LPIC-1
● LPIC-2
● LPIC-3
LPIC-1
● Earned by passing two exams
○ LPI-101
○ LPI-102
● Focuses on general usage of core system
and utilities
○ Later courses focus much more specialised
applications, network services etc.
● Holders of LPIC-1 are eligible to skip the entry level
Suse Linux Enterprise (SCA) exam and certify directly
at SCE level
Linux+
LPI 101
Friday Virtualization
Install Lab
Certification Review
Q&A
Materials
Skytap
Module Objectives
Module 1
Shell Environment
● env
● echo
● export
● set
● unset
Shell Environment
/usr/lib64/qt-3.3/bin:/usr/local/bin:/bin:/usr/b
in:/usr/local/sbin:/usr/sbin:/sbin:/home/andrew/
bin
Shell Environment
[andrew@pc ~]$ echo $PATH | tr ':' '\n'
/usr/lib64/qt-3.3/bin
/usr/local/bin
/bin
/usr/bin
/usr/local/sbin
/usr/sbin
/sbin
/home/andrew/bin
Shell Environment
[andrew@pc ~]$
Shell Environment
● cd
● pwd
Commands
command [options]
Files
[andrew@pc ~]$ ls -l example.txt
-rw-rw-r--. 1 andrew andrew 0 Nov 18 22:03 example.txt
Never Use: *, ?, /, \, “
Best Practice:
● Use lowercase only
● Avoid spaces
● Use dashes (-), underscores (_) and dots (.)
Shell Environment
● history
● ~/.bash_history
● Tab Completion
Documentation
● man
● info
● /usr/share/doc
Man Categories
Online Documentation
● serverfault.com etc.
● Vendor Documentation
● The Linux Documentation Project (tldp.org)
● Google
uname (1)
uname - print system information, eg,
Exercise 1
● bash ● set
● echo ● unset
● env ● man
● export ● uname
● pwd ● history
● type ● .bash_history
● which ● Quoting
Module 1
Streams
Redirection Operators
Operator Effect
/usr/lib64/qt-3.3/bin:/usr/local/bin:/bin:/usr/b
in:/usr/local/sbin:/usr/sbin:/sbin:/home/andrew/
bin
Pipes
tee (1)
Command Substitution
Command substitution allows the output of a
command to replace the command itself.
`command`
Escape Characters
Character Description
● Redirection Operators
● tee
● xargs
Module 1
● less
● more
● cat
Text Processing
● head
● tail
■ -f, follow
■ -n, number of lines
■ -n +X, start at line number X
wc (1)
sed (1)
awk (1)
sort (1)
uniq (1)
■ -c, count
■ -d, only print duplicates
■ -u, only print unique lines
Checksums
■ -c, count
■ -d, only print duplicates
■ -u, only print unique lines
Text Processing
● tac: cat in reverse
● nl: number lines of files
● od: dump files in octal and other formats
● paste: merge lines of files
● split: split a file into pieces
● cut: remove sections from each line of files
● expand: convert tabs to spaces
● unexpand: convert spaces to tabs
● fmt: simple optimal text formatter
● join: join lines of two files on a common field
● pr: convert text files for printing
Exercise 2
Review: Objective 103.2
● cat ● nl ● split
● cut ● od ● tail
● expand ● paste ● tr
● fmt ● pr ● unexpand
● head ● sed ● uniq
● join ● sort ● wc
● less
Module 1
● ls
■ -l, List
■ -ld, List Directory
■ -la, List all (show hidden)
● file
ls *.txt
ls ???.txt
ls [abc].txt
ls [a-z].txt
ls {a,z}.txt
find (1)
examples:
File Management
● touch
● mkdir
■ mkdir -p (make all directories on path)
File Management
● cp
■ cp -a (archive)
● mv
● rm
■ rm -rf (recursive, force)
● rmdir
File Compression
● gzip, gunzip
● bzip2, bunzip2
● xz, unxz
● zcat, bzcat, xzcat etc.
○ zmore, zless, zgrep etc.
tar (1)
dd (1)
dd if=centos.iso of=/dev/sdb
● cp ● rmdir ● file
● find ● touch ● gzip
● mkdir ● tar ● gunzip
● mv ● cpio ● bzip2
● ls ● dd ● bunzip2
● rm ● globbing ● xz
● unxz
Module 1
grep (1)
■ -R, recursive
■ -i, Case Insensitive
■ -L, Show files that match
■ -c, Count matches
■ -q, Quiet
● Use the -E option with grep (or egrep) to use the extended regular
expression syntax
Grep understands three different versions of regular expression syntax: “basic,” “extended” and “perl.”
In GNU grep, there is no difference in available functionality between basic and extended syntaxes.
In basic regular expressions the meta-characters ?, +, {, |, (, and ) lose their special meaning;
instead use the backslashed versions \?, \+, \{, \|, \(, and \).
Traditional egrep did not support the { meta-character, and some egrep implementations support \{
instead, so portable scripts should avoid { in grep -E patterns and should use [{] to match a literal {.
GNU grep -E attempts to support traditional usage by assuming that { is not special if it would be the
start of an invalid interval specification. For example, the command grep -E '{1' searches for the
two-character string {1 instead of reporting a syntax error in the regular expression. POSIX allows this
behavior as an extension, but portable scripts should avoid it.
Regular Expressions
Repetition
Regular Expressions
● regexes
■ Bracket: [aeiou]
■ Range: [a-z]
■ Start: ^
■ End: $
■ Or: |
■ Repetition: ?, +
sed(1)
sed 's/gr[ae]y/blue/'
sed 's/[[:digit:]]/X/'
Module 1
Exercise 4
● grep
● egrep
● fgrep
● sed
● regex(7)