1/71
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai | Chat |
|---|
No analytics yet
Send a link to your students to track their progress
[013.1] What is the difference between archiving and compression?
Archiving bundles files/directories into one archive; compression reduces data size. tar archives by itself, while gzip/bzip2/xz compress.
[013.1] What does tar stand for historically?
Tape archive.
[013.1] What does tar -c do?
Creates a new tar archive.
[013.1] What does tar -t do?
Lists/views the contents of a tar archive without extracting it.
[013.1] What does tar -x do?
Extracts files from a tar archive.
[013.1] What does tar -f do?
Specifies the archive file to operate on; the archive filename follows the option.
[013.1] What does tar -v do?
Verbose mode: shows file names as tar processes them.
[013.1] What does tar -u do?
Updates an existing uncompressed tar archive by adding/replacing files; the LPI material notes compressed tar archives cannot be updated this way.
[013.1] Interpret: tar -cf backup.tar Documents
Create backup.tar containing the Documents directory and its contents; this creates an archive but does not itself compress it.
[013.1] Interpret: tar -tf backup.tar
List the contents of backup.tar without extracting it.
[013.1] Interpret: tar -xf backup.tar
Extract the contents of backup.tar.
[013.1] Which tar compression options map to gzip, bzip2, and xz?
z = gzip, j = bzip2, J = xz.
[013.1] Interpret: tar -czf backup.tar.gz Documents
Create a tar archive of Documents and compress it with gzip.
[013.1] What do gzip, bzip2, and xz have in common?
They are lossless compression tools; by themselves they compress data but do not create multi-file archives.
[013.1] Which commands decompress gzip, bzip2, and xz files?
gunzip for .gz, bunzip2 for .bz2, and unxz for .xz.
[013.1] How do zip and unzip differ from tar plus gzip/bzip2/xz?
ZIP combines archiving and compression in one format; zip creates ZIP archives and unzip extracts them. For directories, zip -r includes their contents.
[013.2] What are the three standard I/O streams?
Standard input (stdin), standard output (stdout), and standard error (stderr).
[013.2] What numeric file descriptors are normally associated with stdin, stdout, and stderr?
stdin = 0, stdout = 1, stderr = 2.
[013.2] What does > do?
Redirects standard output to a file, creating it if needed and overwriting existing contents.
[013.2] What does >> do?
Redirects standard output to a file and appends instead of overwriting.
[013.2] What does 2> do?
Redirects standard error to a file, overwriting that file's existing contents.
[013.2] What does 2>> do?
Appends standard error to a file.
[013.2] What does < do?
Redirects a file into a command's standard input.
[013.2] What does | do?
Pipes the standard output of the command on the left into the standard input of the command on the right.
[013.2] Interpret: head -n 5 /etc/passwd | sort -r
Take the first 5 lines of /etc/passwd, then pass them to sort for reverse sorting.
[013.2] Interpret: tail -n 9 file.txt | wc -c
Take the last 9 lines of file.txt and count their bytes with wc -c.
[013.2] What does cat mainly do in this objective?
Displays and/or concatenates file contents to standard output.
[013.2] What does less do?
Displays text interactively so you can scroll through it.
[013.2] What do head and tail show by default?
head shows the first 10 lines; tail shows the last 10 lines.
[013.2] What does sort do?
Sorts input lines.
[013.2] What does wc do by default?
Counts lines, words, and bytes; common focused options include -l for lines, -w for words, and -c for bytes.
[013.2] What does cut do?
Extracts selected fields or sections from each input line.
[013.2] [V2 explicit] What does uniq do in normal use?
It filters adjacent duplicate lines; it is commonly paired with sort when you want repeated values grouped before duplicate filtering.
[013.2] Why is sort | uniq a common pattern?
sort groups identical lines next to each other, and uniq can then remove or process those adjacent duplicates.
[013.2] What does grep do?
Searches input/files for lines matching a pattern and outputs matching lines.
[013.2] Why use grep -E?
It enables Extended Regular Expression syntax.
[013.2] In an ERE, what does . mean?
Any single character.
[013.2] In an ERE, what do [abc] or [a-z] mean?
Match one character from the listed set or range.
[013.2] In an ERE, what does * mean?
Zero or more occurrences of the preceding expression.
[013.2] In an ERE, what does ? mean?
Zero or one occurrence of the preceding expression.
[013.3] What is a shebang?
The #! line at the start of a script that specifies which interpreter should execute it.
[013.3] What does #!/bin/bash specify?
Use /bin/bash as the interpreter for the script.
[013.3] How do you normally assign a Bash variable?
name=value with no spaces around =, for example username=Carol.
[013.3] How do you substitute the value of a variable named username?
$username or ${username}.
[013.3] Are Bash variable names case-sensitive?
Yes. username and Username are different variables.
[013.3] What does $1 mean in a shell script?
The first positional argument passed to the script.
[013.3] What do $2 through $9 represent?
Additional positional arguments passed to the script.
[013.3] What does $# contain?
The number of positional arguments passed to the script.
[013.3] What do $@ and $* represent?
All positional arguments passed to the script; the LPI material presents both as holding all script arguments.
[013.3] If ./hello.sh Carol Dave is run, what are $1 and $2?
$1 is Carol and $2 is Dave.
[013.3] What is the basic structure of an if statement used in the LPI material?
if [ condition ]; then commands; else commands; fi — with the test brackets requiring proper spacing.
[013.3] Why do spaces around [ condition ] matter in Bash examples?
[ is parsed as a command/test construct, so missing required spaces can cause syntax/command errors.
[013.3] What does -eq test?
Numeric equality.
[013.3] What does -ne test?
Numeric inequality (not equal).
[013.3] What does -gt test?
Numeric greater-than.
[013.3] What does -ge test?
Numeric greater-than-or-equal.
[013.3] What does -lt test?
Numeric less-than.
[013.3] What does -le test?
Numeric less-than-or-equal.
[013.3] What does == test in the LPI shell-script examples?
String equality, not numeric arithmetic equality.
[013.3] Why can == and -eq produce different results?
[013.3] [V2 explicit] What does [ -e $file ] test in Bash?
Whether a filesystem entry exists at the path stored in $file.
[013.3] [V2 explicit] What does [ -f $file ] test in Bash?
Whether the path exists and is a regular file.
[013.3] What does $? contain?
The exit status of the most recently executed command.
[013.3] What exit status normally indicates success?
0.
[013.3] What does a non-zero exit status generally indicate?
Failure or some error/unsuccessful condition.
[013.3] What does exit 0 do inside a script?
Immediately terminates the script and returns status 0 (success).
[013.3] What does exit 1 do inside a script?
Immediately terminates the script and returns status 1, conventionally indicating failure.
[013.3] What happens to commands after an executed exit statement?
They are not run because the script terminates immediately.
[013.3] What is the basic Bash for-loop form?
for item in LIST; do commands using $item; done
[013.3] What does a for loop do with a space-separated list?
Runs the loop body once for each item in the list.
[013.3] How can a for loop iterate over script arguments?
For example: for arg in $@; do echo $arg; done
[013.3] How can a for loop work with a file glob?
The shell expands the glob to matching filenames, then the loop iterates over those names, e.g. for f in *.txt; do echo $f; done.