Linux Fundamentals

Paul Cobbaut

lt-0.970.452

Sun 01 Aug 2010 05:43:31 PM CEST

Abstract

This book is meant to be used in an instructor-led training. For self-study, the intent is to read this book next to a working Linux computer so you can immediately do every subject, practicing each command.

This book is aimed at novice Linux system administrators (and might be interesting and useful for home users that want to know a bit more about their Linux system). However, this book is not meant as an introduction to Linux desktop applications like text editors, browsers, mail clients, multimedia or office applications.

More information and free .pdf available at http://www.linux-training.be .

Feel free to contact the authors:

  • Paul Cobbaut: paul.cobbaut@gmail.com, http://www.linkedin.com/in/cobbaut

Contributors to the Linux Training project are:

  • Serge van Ginderachter: serge@ginsys.be, docbook xml and pdf build scripts; svn hosting

  • Hendrik De Vloed: hendrik.devloed@ugent.be, buildheader.pl script

We'd also like to thank our reviewers:

  • Wouter Verhelst: wouter@grep.be, http://grep.be

  • Geert Goossens: mail.goossens.geert@gmail.com, http://www.linkedin.com/in/geertgoossens

  • Elie De Brauwer: elie@de-brauwer.be, http://www.de-brauwer.be

  • Christophe Vandeplas: christophe@vandeplas.com, http://christophe.vandeplas.com

  • Bert Desmet: bert@devnox.be, http://bdesmet.be

  • Rich Yonts: richyonts@gmail.com,

Copyright 2007-2010 Paul Cobbaut


Table of Contents

1. Introduction to Unix and Linux
Unix History
AT&T Bell Labs
The Unix Wars
University of California, Berkeley
GNU's not Unix
Linux
Licensing
Proprietary
BSD
GNU General Public License (GPL)
Others...
Current Distributions
What is a distribution ?
Linux Distributions
BSD Distributions
Major Vendors of Unix
Solaris
Certification
LPI: Linux Professional Institute
Red Hat Certified Engineer
MySQL
Novell CLP/CLE
Sun Solaris
Other certifications
Discovering the classroom
2. Getting help
man pages
man $command
man $configfile
man $daemon
man -k (apropos)
whatis
whereis
man sections
man $section $file
man man
mandb
online help
Google
Wikipedia
The Linux Documentation Project
Red Hat
Ubuntu
www.linux-training.be
3. First steps
working with directories
pwd
cd
absolute and relative paths
path completion
ls
mkdir
rmdir
practice : working with directories
solution : working with directories
working with files
file
touch
rm
cp
mv
rename
practice : working with files
solution : working with files
file contents
head
tail
cat
tac
more and less
strings
practice : file contents
solution : file contents
4. The Linux file system tree
all files are case sensitive
everything is a file
/ (the root directory)
man hier
filesystem hierarchy standard
common directories
/bin binaries
/boot static files to boot the system
/dev device files
/etc configuration files
/home sweet home
/initrd
/lib shared libraries
/media for removable media
/mnt standard mount point
/opt optional software
/proc conversation with the kernel
/root the superuser's home
/sbin system binaries
/srv served by your system
/sys Linux 2.6 hot plugging
/tmp for temporary files
/usr Unix system resources
/var variable data
practice : file system tree
solution : file system tree
5. Introduction to the shell
about shells
several shells
external or built-in commands
type
running external commands
which
alias
echo
shell expansion
displaying shell expansion
practice: about shells
solution: about shells
control operators
; semicolon
& ampersand
&& double ampersand
|| double vertical bar
Combining && and ||
# pound sign
\ escaping special characters
end of line backslash
practice: control operators
solution: control operators
shell variables
$ dollar sign
case sensitive
$PS1
$PATH
$? dollar question mark
unbound variables
creating and setting variables
set
unset
env
exporting variables
delineate variables
quotes and variables
practice: shell variables
solution: shell variables
shell arguments
white space removal
single quotes
double quotes
echo and quotes
shell embedding
back ticks
back ticks or single quotes
practice: shell arguments
solution: shell arguments
file globbing
* asterisk
? question mark
[] square brackets
a-z and 0-9 ranges
$LANG and square brackets
bash shell options
shell history
history variables
repeating commands in bash
repeating commands in ksh
practice : shell globbing, options and history
solution: shell globbing, options and history
shell i/o redirection
stdin, stdout, and stderr
> output redirection
noclobber
>> append
2> error redirection
2>&1
< input redirection
<< here document
confusing i/o redirection
quick file clear
swapping stdout and stderr
practice : i/o redirection
solution : i/o redirection
6. Pipes and filters
pipes
about pipes
| vertical bar
multiple pipes
filters
about filters
cat does nothing
tee
grep
cut
tr
wc
sort
uniq
comm
od
sed
some pipeline examples
who | wc
who | cut | sort
grep | cut
practice : pipes and filters
solution : pipes and filters
7. Basic Unix tools
common tools
find
locate
date
cal
sleep
time
compression tools
gzip - gunzip
zcat - zmore
bzip2 - bunzip2
bzcat - bzmore
practice : basic Unix tools
solution : basic Unix tools
8. Introduction to vi
about vi(m)
introduction to using vi(m)
command mode and insert mode
start typing (a A i I o O)
replace and delete a character (r x X)
undo and repeat (u .)
cut, copy and paste a line (dd yy p P)
cut, copy and paste lines (3dd 2yy)
start and end of a line (0 or ^ and $)
join two lines (J) and more
words (w b)
save (or not) and exit (:w :q :q! )
Searching (/ ?)
Replace all ( :1,$ s/foo/bar/g )
Reading files (:r :r !cmd)
text buffers
multiple files
abbreviations
key mappings
setting options
practice : vi(m)
solution : vi(m)
9. Introduction to scripting
about shell scripting
hello world
she-bang
comment
Variables
Shell
for loop
while loop
until loop
parameters
test [ ]
if if, then then, or else
let
runtime input
sourcing a config file
case
shopt
Practice : scripts
Solutions
10. Introduction to users
Identify yourself
whoami
who
who am i
w
id
users
user management
/etc/passwd
root
useradd
/etc/default/useradd
userdel
usermod
passwords
passwd
/etc/shadow
password encryption
password defaults
disabling a password
editing local files
home directories
creating home directories
/etc/skel/
deleting home directories
user shell
login shell
chsh
switch users with su
su to another user
su to root
su as root
su - $username
su -
run a program as another user
about sudo
setuid on sudo
visudo
sudo su
practice: users
solution: users
shell environment
/etc/profile
~/.bash_profile
~/.bash_login
~/.profile
~/.bashrc
~/.bash_logout
Debian overview
RHEL5 overview
11. Introduction to groups
about groups
groupadd
/etc/group
usermod
groupmod
groupdel
groups
gpasswd
vigr
practice: groups
solution: groups
12. Standard file permissions
file ownership
user owner and group owner
chgrp
chown
list of special files
permissions
rwx
three sets of rwx
permission examples
setting permissions (chmod)
setting octal permissions
umask
practice: standard file permissions
solution: standard file permissions
sticky and setgid bits
sticky bit on directory
setgid bit on directory
setgid and setuid on regular files
practice: sticky, setuid and setgid bits
solution: sticky, setuid and setgid bits
access control lists
acl in /etc/fstab
getfacl
setfacl
remove an acl entry
remove the complete acl
the acl mask
eiciel
13. File links
inodes
inode contents
inode table
inode number
inode and file contents
about directories
a directory is a table
. and ..
hard links
creating hard links
finding hard links
symbolic links
removing links
practice : links
solution : links
14. Process management
terminology
process
PID
PPID
init
kill
daemon
zombie
basic process management
$$ and $PPID
pidof
parent and child
fork and exec
exec
ps
pgrep
top
signalling processes
kill
list signals
kill -1 (SIGHUP)
kill -15 (SIGTERM)
kill -9 (SIGKILL)
killall
pkill
top
SIGSTOP and SIGCONT
practice : basic process management
solution : basic process management
priority and nice values
introduction
pipes (mkfifo)
some fun with cat
top
top -p
renice
impact of nice values
nice
practice : process priorities
solution : process priorities
background processes
jobs
control-Z
& ampersand
jobs -p
fg
bg
practice : background processes
solution : background processes
A. Keyboard settings
About Keyboard Layout
X Keyboard Layout
Shell Keyboard Layout
B. Hardware Settings
buses
about buses
/proc/bus
/usr/sbin/lsusb
/var/lib/usbutils/usb.ids
/usr/sbin/lspci
interrupts
about interrupts
/proc/interrupts
dmesg
io ports
about io ports
/proc/ioports
dma
about dma
/proc/dma
Index

List of Tables

1.1. Early Unix Timeline
1.2. Eighties Unix Timeline
1.3. Current BSD Timeline
8.1. getting to command mode
8.2. switch to insert mode
8.3. replace and delete
8.4. undo and repeat
8.5. cut, copy and paste a line
8.6. cut, copy and paste lines
8.7. start and end of line
8.8. join two lines
8.9. words
8.10. save and exit vi
8.11. searching
8.12. replace
8.13. read files and input
8.14. text buffers
8.15. multiple files
8.16. abbreviations
10.1. Debian User Environment
10.2. Red Hat User Environment
12.1. Unix special files
12.2. standard Unix file permissions
12.3. Unix file permissions position
12.4. Octal permissions