GNU and Unix commands

GNU and Unix commands is the heaviest objective on the 101 paper. It covers the shell itself, text processing, file management, redirection and pipes, process control, priorities, regular expressions and vi. Objective 103 of LPIC-1 Exam 101-500, worth 43.33% of the exam.

Share of the exam
43.33%
Questions in a real sitting
roughly 26 of 60
Questions in this bank
130
Signed for by a person
0
Machine-checked only
130

Partly checked. None of the 130 questions here has been read against the cited source by a person. 130 questions have been checked against their cited clause by an automated pass — which is not the same thing, and is not a signature.

Only questions a person has signed for are used in mock exams here. That is the whole difference between the two kinds of checking above.

How these questions are written — where each question comes from, what the verification ledger records, and what happens when one is found wrong.

What this objective covers

The 130 questions written for this objective cite 8 LPI exam objectives (103.1, 103.2, 103.3, 103.4, 103.5, 103.6, 103.7, 103.8) and 34 manual pages (bash(1), bzip2(1), cp(1), cpio(1), crontab(1), dd(1), env(1), find(1), getpriority(2), glob(7), grep(1), gzip(1), ls(1), man(1), mv(1), nano(1), nice(1), nohup(1), ps(1), regex(7), renice(1), rmdir(1), screen(1), sed(1), signal(7), tar(1), tee(1), top(1), touch(1), uname(1), vi(1p), vim(1), wc(1), xargs(1)).

They break down as 88 single-answer questions, 18 choose-several questions and 24 type-the-answer questions.

What this objective is really about

At more than forty per cent of the paper, this objective decides whether you pass. It is also the most practical: nearly every question is about what a specific command or shell construct does, so the material rewards typing it more than reading it.

Shell, quoting and redirection

Bash reads different startup files depending on the kind of shell. An interactive login shell reads /etc/profile and then the first of ~/.bash_profile, ~/.bash_login and ~/.profile that exists — only the first. An interactive non-login shell, which is what a new terminal window in a desktop session gives you, reads ~/.bashrc. That is why aliases belong in .bashrc and why most .bash_profile files source it.

Single quotes suppress every expansion; double quotes still perform parameter expansion, command substitution and backslash escapes, and only stop word splitting and globbing. Exporting a variable is what makes it part of the environment child processes inherit; without export it stays a shell variable, which is why env shows a smaller list than set.

Redirection is about file descriptors: 0 stdin, 1 stdout, 2 stderr. > truncates and >> appends. 2> redirects only errors. n>&m makes descriptor n a duplicate of whatever m points at right now — which is why order matters, and why cmd 2>&1 > file sends errors to the terminal and only stdout to the file, while cmd > file 2>&1 sends both to the file. A here-document, <<, feeds inline text to standard input; <<< is a here-string for a single line.

Text processing and finding files

The filters divide by what they do to a stream. sort orders it (-n numerically, -r reversed, -u deduplicating, -k by field). uniq collapses only adjacent duplicates, which is why sort almost always comes first, and -c counts. cut extracts fields (-d sets the delimiter, which defaults to tab). paste merges lines positionally while join matches on a key field and needs sorted input. tr translates or deletes characters and reads only from standard input. sed substitutes, with the g flag for every match on a line rather than the first. wc counts, nl numbers non-empty lines by default, and tail -n sets how many lines to show from the end.

For finding files, find searches live and precisely: -name is case-sensitive and -iname is not, patterns must be quoted so the shell does not expand them first, and -print0 paired with xargs -0 is the safe idiom for names containing spaces. locate is a fast database lookup that is only as current as the last updatedb run. which searches PATH and reports the file it would find there — but the shell checks aliases, functions and builtins first, so which is not a reliable answer to "what will actually run". type is, and a question that mentions any of those three is asking for type.

Processes, priorities and regular expressions

kill sends SIGTERM by default, not SIGKILL. Escalate to -9 only when a process has ignored SIGTERM, because SIGKILL gives it no chance to flush data or release locks. SIGHUP is conventionally a reload signal for daemons. killall and pkill signal by name; kill needs a PID; pgrep only reports. To survive a logout, use nohup, disown, or a screen or tmux session — nice does nothing for this.

Nice values run from -20, most favourable, through 0 to 19, least favourable, and the direction is counterintuitive: a higher number means lower priority. An unprivileged user may only raise their own processes' nice value, never lower it back. nice starts a new command with an adjustment; renice changes one that already exists.

For regular expressions, the split to learn is basic versus extended. Both treat . * [ ] ^ $ as metacharacters. In a basic expression the characters + ? { } ( ) | need a backslash to take on their special meaning; in an extended expression (grep -E) they are special as typed. grep -F disables regular expressions entirely and treats the pattern as fixed text, which is the answer whenever a question worries about dots matching any character.

vi, and why it is examined at all

vi opens in command mode, which is why typing text at first appears to do strange things. i, a and o all enter insert mode and differ only in where the cursor lands; Esc returns to command mode. dd cuts a line, yy copies one, p pastes. To leave: :w writes, :q quits and refuses if the buffer is modified, :q! discards, and :wq writes then quits. The reason vi is examined at all is that a vi-compatible editor is effectively guaranteed to exist on any Unix-like system, including rescue images where nano is not installed.

Lessons in this objective

The objective cut into the pieces the blueprint declares. Each one has the material written out and the questions that test it.

Drill this objective

The trainer can run a short practice set drawn from this objective alone, which is what the weight column above is for: revise the heavy objectives first.

Practise GNU and Unix commands

Questions on this objective (page 1 of 7)

Practise GNU and Unix commands

The other objectives in LPIC-1 Exam 101-500