LPIC-1 101-500 study materials
LPIC-1 101-500 study resources

LPIC-1 101-500: GNU and Unix Commands

LPIC-1 101-500 · Work through your exam, one topic at a time.

All guide sections

GNU and Unix Commands

GNU and Unix Commands

This domain is the largest and rewards precision about flags and pipelines. Master text processing: grep (-i -v -r -E -c -n), sed (substitution s/old/new/g, -i in-place, -n plus p), awk (-F, $1, NR, NF), and cut, sort (-n -r -k -u), uniq (-c -d only on sorted input), tr, head/tail (-n, -f). Combine with redirection: > truncates, >> appends, 2> redirects stderr, &> both, 2>&1 order matters.

Process management: ps aux, ps -ef, pgrep/pkill, kill with signals (-15 TERM default, -9 KILL uncatchable, -1 HUP), nice/renice for priority, and job control (fg, bg, jobs, Ctrl-Z, trailing &).

Files and search: find with -name, -type, -mtime, -size, -exec {} \; versus -exec {} +, and xargs. Know locate/updatedb. Also tar (-c -x -t -z -j -f -v), gzip/gunzip, bzip2, xz, cpio, dd (if= of= bs= count=`).

Trap: uniq does nothing useful on unsorted input - sort first. Another: -exec {} \; runs the command once per file, whereas -exec {} + batches; questions on efficiency want the plus form. Watch signal defaults: plain kill PID sends SIGTERM (15), not SIGKILL.

Rule of thumb: for pipelines, read right to left and ask what each stage consumes and emits. Example: ps -ef | grep '[h]ttpd' | awk '{print $2}' | xargs kill - the bracket trick avoids matching the grep process itself, awk prints PIDs, xargs feeds them to kill.