Linux Midterm Notes

BCIT CISA 1340: Linux Essentials

Complete Midterm Exam Flashcard Master Deck (Chapters 1 – 9)

SECTION 1: DIRECT IMPORT FORMAT (Tab-Separated Values)

How to import into Quizlet / Anki / Brainscape / Cram:

  1. Highlight and copy the text inside the code box below.

  2. Open Quizlet (click Create -> Study set -> Import) or Anki (File -> Import).

  3. Set the delimiter to Tab between Front and Back, and New line between rows.

  4. Click Import.

In what year was UNIX created, at what lab, and by whom?	1969; AT&T Bell Labs; Ken Thompson and Dennis Ritchie.
Is the term UNIX trademarked, and who certifies compliance?	Yes, UNIX is a trademarked specification certified by The Open Group consortium.
What are the two major historical branches of UNIX?	System V (SysV) and BSD (Berkeley Software Distribution).
In what year was MINIX created, by whom, and what was its original design purpose?	1987; Andrew Tanenbaum; created for educational operating systems instruction (16-bit microkernel architecture).
In what year was Linux created, by whom, and what architecture did it originally target?	1991; Linus Torvalds; 32-bit architecture targeting the Intel 80386 processor.
What organization did Richard Stallman found, and what project provided the userland tools for Linux?	Free Software Foundation (FSF); the GNU Project (GNU's Not Unix).
What package management format and frontend tools are used by Red Hat/CentOS/Rocky/Fedora?	RPM package format; frontend tools are dnf and yum.
What package management format and frontend tools are used by Debian/Ubuntu?	.deb package format; frontend tools are apt and dpkg.
What package management format and tool is used by openSUSE?	RPM package format; frontend tool is zypper.
What are the three components of standard Linux command line grammar?	command [options/switches] [arguments]
How do short options differ from long options in syntax?	Short options begin with a single hyphen (-) and are single letters; long options begin with double hyphens (--) and use full words.
Can multiple short options without arguments be combined under a single hyphen?	Yes (e.g., ls -l -a can be written as ls -la or ls -al).
In command line grammar, what part of speech is a command analogous to?	A verb (an action).
In command line grammar, what part of speech is an option/switch analogous to?	An adverb or adjective (modifies how the action is performed).
In command line grammar, what part of speech is an argument analogous to?	A noun or direct object (the target acted upon, such as a file or directory).
If a short option takes an argument (such as -w 40), is a space required between the option and its argument?	No, a space is optional; both -w 40 and -w40 are valid.
How do you pass arguments to long options?	Using an equals sign or a space (e.g., --width=40 or --width 40).
What does the Bash command 'history 5' display?	Displays the last 5 commands executed from the history buffer.
What does the Bash shortcut '!!' do?	Re-executes the immediately preceding command line.
What does the Bash shortcut '!n' do (where n is a number)?	Re-executes command line number n from the history list.
What does the Bash shortcut '!-n' do (where n is a number)?	Re-executes the command n lines back from the bottom of history.
What does the Bash shortcut '!cat' do?	Re-executes the most recent command starting with the string 'cat'.
What Bash editing shortcut jumps the cursor directly to the beginning of the line?	Ctrl + A
What Bash editing shortcut jumps the cursor directly to the end of the line?	Ctrl + E
What Bash editing shortcut deletes/cuts text from the cursor position to the start of the line?	Ctrl + U
What Bash editing shortcut deletes/cuts text from the cursor position to the end of the line?	Ctrl + K
What Bash keyboard shortcut aborts, cancels, or sends SIGINT to the current foreground process?	Ctrl + C
What Bash keyboard shortcut clears the terminal screen buffer?	Ctrl + L (equivalent to typing 'clear').
What Bash editing shortcut moves forward one character?	Ctrl + F (or Right Arrow).
What Bash editing shortcut moves backward one character?	Ctrl + B (or Left Arrow).
In which directory hierarchy are system manual pages stored?	/usr/share/man
What category of documentation is contained in Section 1 of the man pages?	User shell commands and executable programs (e.g., ls, pwd, cat, date).
What category of documentation is contained in Section 5 of the man pages?	File formats and configuration file specifications (e.g., /etc/passwd, /etc/shadow).
What category of documentation is contained in Section 8 of the man pages?	System administration and root-only maintenance commands (e.g., useradd, fdisk).
What is the difference between running 'man passwd' and 'man 5 passwd'?	'man passwd' defaults to Section 1 (the user command to change passwords); 'man 5 passwd' opens Section 5 (the syntax of the /etc/passwd config file).
How do you initiate a forward text search inside a man page?	Type / followed by the search pattern, then press Enter.
How do you initiate a backward text search inside a man page?	Type ? followed by the search pattern, then press Enter.
While searching in a man page, what keystroke moves to the next occurrence in the same direction?	n (lowercase n).
While searching in a man page, what keystroke moves to the previous occurrence (opposite direction)?	N (uppercase N).
What keystrokes jump directly to the top and bottom of a man page?	1G (or g) jumps to the top; G jumps to the bottom.
What keystroke exits a man page viewer and returns to the shell?	q
What command searches the short descriptions inside man pages for a keyword (equivalent to 'man -k')?	apropos
What command displays a one-line summary from man page header descriptions (equivalent to 'man -f')?	whatis
What command provides built-in documentation for Bash internal commands (like cd, history, pwd)?	help (e.g., help cd)
What is the top-level parent directory of the entire Linux filesystem tree?	/ (the root directory).
What is stored inside the /boot directory?	Linux kernel images (vmlinuz), initial RAM disk (initramfs), and GRUB bootloader configuration files.
What is stored inside the /dev directory?	Device nodes/special files used by the OS to communicate with physical/virtual hardware (e.g., /dev/sda, /dev/null, /dev/zero).
What is stored inside the /etc directory?	Host-specific, static, system-wide text configuration files that persist across system reboots.
What type of data is stored in /var?	Variable data dynamically written during operations (logs in /var/log, spool files, databases, mail).
What is stored inside the /run directory, and what happens to it on reboot?	Volatile runtime process state data (PID files, sockets); stored in RAM (tmpfs) and completely wiped upon reboot.
What is stored inside the /usr directory?	Installed user-space programs, libraries, shared data, and system documentation (/usr/share).
Where are /bin and /sbin located on modern RHEL/CentOS systems?	They are symbolic links pointing to /usr/bin and /usr/sbin.
What distinguishes commands in /sbin from those in /bin?	/bin contains general user commands; /sbin contains system administration commands intended for the superuser (root).
What are the defining characteristics of an absolute pathname?	It begins with / (root) or ~ (tilde); it resolves unambiguously from anywhere in the filesystem.
What are the defining characteristics of a relative pathname?	It never begins with / or ~; its resolution depends entirely on the current working directory (pwd).
What does a single dot (.) represent in Linux path syntax?	The current working directory (pwd).
What does double dots (..) represent in Linux path syntax?	The immediate parent directory of the current directory.
What does 'cd -' do in Bash?	Changes the working directory to the previous working directory ($OLDPWD).
What does 'cd' or 'cd ~' without arguments do in Bash?	Changes the working directory to the current user's home directory ($HOME).
If 'cp' is given 3 or more arguments (e.g., cp file1 file2 /target/), what must the final argument be?	An existing directory.
What switch must be passed to 'cp' to copy an entire directory tree recursively?	-r or -R (recursive).
What does the 'cp -p' switch do?	Preserves file attributes (timestamps, ownership, and permission mode bits).
What happens if you run 'mv file1 file2' when file2 does not exist?	It renames file1 to file2.
What happens if you run 'mv file1 file2' when file2 is an existing directory?	It moves file1 into the directory file2/ without renaming it.
Does the 'mv' command require a recursive switch (-r) to move a directory?	No, mv moves or renames directories without any special switches.
What does 'mkdir -p /a/b/c' do?	Creates the leaf directory /c along with any missing parent directories (/a, /b) without returning an error.
Under what condition will the 'rmdir' command fail?	When the specified directory contains any files or subdirectories (it is not empty).
What command deletes a non-empty directory and all nested contents without any interactive prompting?	rm -rf <directory_name>
What does the wildcard asterisk (*) match in Bash file globbing?	Zero or more characters (any characters except a leading dot for hidden files).
What does the wildcard question mark (?) match in Bash file globbing?	Exactly one single character.
Does 'ls *' display hidden files? Why or why not?	No; in Linux hidden files begin with a dot (.), and wildcards do not match a leading dot unless explicitly specified (e.g., .*).
What does the file globbing pattern 'ls [abc]*' match?	Any visible file whose filename begins with lowercase a, b, or c.
What does the file globbing pattern 'ls [!abc]*' or 'ls [^abc]*' match?	Any visible file whose filename does NOT begin with a, b, or c.
What does the file globbing pattern 'ls [a-z]*' match?	Any visible file whose name begins with any lowercase letter from a through z.
What does the file globbing pattern '???' match?	Any visible filename that consists of exactly three characters.
What globbing pattern matches files with exactly 7 characters where the middle character is a lowercase vowel?	???[aeiou]???
What globbing pattern matches visible filenames that contain the character 'p' anywhere in the name?	*p*
What globbing pattern matches visible filenames that end with the letter 'z'?	*z
How do you match hidden files ending with the letter 'p'?	.*p
What are the two syntaxes for command substitution in Bash?	Modern syntax: $(command) | Legacy syntax: `command` (backticks).
What does Tilde Expansion '~' evaluate to?	The absolute path of the current user's home directory ($HOME).
What does '~username' evaluate to in Bash?	The absolute path of the specified user's home directory (e.g., /home/username).
What files are generated by running 'touch file{1..4}'?	file1, file2, file3, file4 (via Brace Expansion).
What files are generated by running 'touch file{a,b}{1,2}.txt'?	filea1.txt, filea2.txt, fileb1.txt, fileb2.txt
How do hard links and symbolic (soft) links compare regarding inode allocation?	A hard link shares the exact same inode number as the target; a symbolic link receives its own unique inode containing the target's path string.
Can hard links span across different physical partitions or filesystems?	No; hard links are restricted to a single filesystem because inode tables are per-filesystem.
Can symbolic (soft) links point across different physical partitions or filesystems?	Yes, symbolic links store a path string and can freely span filesystems.
Can a regular user create a hard link pointing to a directory?	No; hard links to directories are disallowed to prevent circular directory loops.
Can a symbolic link point to a directory?	Yes (e.g., ln -s /tmp /home/user/mytemp).
What is a 'dangling link' in Linux?	A symbolic link whose target file or directory has been deleted or moved.
What happens to data on disk when the original name of a hard-linked file is removed with 'rm'?	The data remains fully accessible via the remaining hard link as long as the inode link count is 1 or higher.
What command is used to remove a symbolic link?	rm <linkname> (deletes the link itself, never the original target).
What command creates a symbolic link named 'myconfig' pointing to '/etc/hosts'?	ln -s /etc/hosts myconfig
What are the three standard POSIX I/O streams and their integer file descriptors?	0: stdin (Standard Input); 1: stdout (Standard Output); 2: stderr (Standard Error).
What is the default device source for stdin, and default destination for stdout and stderr?	stdin defaults to the keyboard; stdout and stderr default to the terminal screen.
What is the difference between '>' and '>>' redirection operators?	'>' redirects stdout and overwrites the destination file; '>>' redirects stdout and appends to the end of the file.
What command line syntax redirects only Standard Error (stderr) to a file named 'errors.log'?	command 2> errors.log
What is '/dev/null' and why is it used in redirection?	The null device / bit bucket; any data redirected into it (e.g., 2> /dev/null) is discarded permanently.
What are the two valid syntaxes to redirect both stdout and stderr into the same file?	command &> file  OR  command > file 2>&1
What syntax redirects stdout to 'out.txt' and stderr to 'err.txt' simultaneously?	command > out.txt 2> err.txt
What does the pipe operator (|) connect?	Connects the Standard Output (FD 1) of the command on the left to the Standard Input (FD 0) of the command on the right.
Does a standard pipe (|) redirect Standard Error (stderr) by default?	No, stderr prints directly to the terminal unless combined using '|&' or '2>&1 |'.
What do the switches '-l', '-w', and '-c' do in the 'wc' command?	-l counts lines; -w counts words; -c counts bytes/characters.
What command outputs the first 15 lines of '/etc/services'?	head -n 15 /etc/services (or head -15 /etc/services).
What command outputs the last 10 lines of a file by default?	tail <filename>
What does the '-f' switch do in 'tail /var/log/messages'?	Follow mode: keeps the file open and continuously prints newly appended lines in real time.
What command sorts lines alphabetically, removes consecutive duplicates, and outputs counts of occurrences?	sort <file> | uniq -c
What does the 'tee' command do in a pipeline (e.g., ls | tee out.txt)?	Reads stdin and writes simultaneously to both stdout (the screen) and one or more files.
What UID is strictly assigned to the superuser (root)?	UID 0
What UID range is typically reserved for system users on modern RHEL/CentOS systems?	UID 1 through 999
What UID range is assigned to regular human user accounts on modern RHEL/CentOS systems?	UID 1000 and higher (1000 to 60000+).
What shell is assigned to system accounts to prevent interactive console/SSH login?	/sbin/nologin (or /bin/false).
List the 7 colon-separated fields of '/etc/passwd' in exact order:	1: Username, 2: Password placeholder (x), 3: UID, 4: Primary GID, 5: Comment/GECOS, 6: Home directory, 7: Login shell.
What does the letter 'x' signify in the second field of '/etc/passwd'?	The encrypted password hash is protected and stored securely inside /etc/shadow.
List the 4 colon-separated fields of '/etc/group' in exact order:	1: Group name, 2: Group password placeholder (x), 3: GID, 4: Comma-separated list of secondary members.
What is a User Private Group (UPG)?	A group automatically created by useradd that shares the exact name and GID as the newly created user account.
Why does field 4 of '/etc/group' often appear blank for a user's private group?	Field 4 only records secondary group memberships; primary group membership is defined in field 4 of /etc/passwd.
What directory provides default skeleton template configuration dotfiles when a new home directory is created?	/etc/skel/
What useradd switch specifies a custom home directory location?	-d /path/to/home
What useradd switch specifies a custom default login shell?	-s /path/to/shell (e.g., -s /sbin/nologin).
What useradd switch assigns secondary (supplementary) groups to a user?	-G group1,group2
What useradd switch specifies an account expiration date?	-e YYYY-MM-DD
What is the critical behavioral difference between 'usermod -G devs john' and 'usermod -aG devs john'?	-G without -a removes john from all other secondary groups; -aG appends devs while preserving all existing secondary memberships.
What usermod switch locks an account's password, and how does it alter '/etc/shadow'?	usermod -L <user>; prepends an exclamation mark (!) to the encrypted password string in /etc/shadow.
What usermod switch unlocks a locked user account?	usermod -U <user>
What usermod switch renames an existing username?	usermod -l <new_name> <old_name>
What does 'userdel -r <user>' do that plain 'userdel <user>' does not?	The -r switch removes the user's home directory and mail spool along with the account record.
What happens when a regular user runs 'passwd' vs. when root runs 'passwd john'?	A regular user is prompted for their current password before setting a new one; root can change any user's password directly without knowing the old password.

SECTION 2: CHAPTER-BY-CHAPTER DETAILED DRILL CARDS

Chapter 1: Linux & Open Source History
  • Q: Who wrote UNIX, when was it released, and where was it created?

    • A: Dennis Ritchie and Ken Thompson in 1969 at AT&T Bell Labs.

  • Q: What were the two main branches that evolved from initial UNIX releases?

    • A: System V (SysV) and BSD (Berkeley Software Distribution).

  • Q: What was MINIX, when was it released, who created it, and what was its purpose?

    • A: Released in 1987 by Andrew Tanenbaum; an educational, microkernel-based 16-bit UNIX-like operating system intended for academic computer science study.

  • Q: Who created the Linux kernel, in what year, and what chip did it target?

    • A: Linus Torvalds in 1991, targeting the 32-bit Intel 80386 processor.

  • Q: What was Richard Stallman's contribution to modern Linux systems?

    • A: Founded the Free Software Foundation (FSF) in 1985 and initiated the GNU Project in 1983, providing essential compilers (gcc), userland utilities (coreutils), and the GNU GPL license.

  • Q: Distinguish package formats for Debian/Ubuntu vs. Red Hat/CentOS/Fedora vs. openSUSE.

    • A:

      • Debian/Ubuntu: .deb package format, managed using apt and dpkg.

      • Red Hat/CentOS/Fedora: RPM package format (.rpm), managed using dnf (or yum).

      • openSUSE: RPM package format (.rpm), managed using zypper.

Chapter 2: Command Line Grammar & Bash Editing Shortcuts
  • Q: What is the formal grammatical structure of a Linux command line?

    • A: command [options/switches] [arguments]

  • Q: What are the differences between short options and long options?

    • A: Short options use a single dash and single character (e.g., -l, -a) and can be bundled (-la). Long options use double dashes and full words (e.g., --all, --human-readable).

  • Q: Explain the following history expansion operators: !!, !5, !-2, !grep.

    • A:

      • !!: Re-executes the last command.

      • !5: Re-executes command number 5 in the history buffer.

      • !-2: Re-executes the command run 2 commands ago.

      • !grep: Re-executes the most recent command that began with grep.

  • Q: What do the following Bash cursor shortcuts do: Ctrl+A, Ctrl+E, Ctrl+U, Ctrl+K, Ctrl+C, Ctrl+L?

    • A:

      • Ctrl+A: Move cursor to beginning of the line.

      • Ctrl+E: Move cursor to end of the line.

      • Ctrl+U: Cut line from cursor backward to the beginning.

      • Ctrl+K: Cut line from cursor forward to the end.

      • Ctrl+C: Send interrupt signal (SIGINT) to terminate the current foreground process.

      • Ctrl+L: Clear terminal screen.

Chapter 3: Getting Help & Documentation
  • Q: In which exact directory are system man pages stored?

    • A: /usr/share/man

  • Q: What manual sections do Section 1, Section 5, and Section 8 represent?

    • A:

      • Section 1: Executable user programs and shell commands (ls, date).

      • Section 5: File formats and configuration specifications (/etc/passwd).

      • Section 8: System administration and root-only utilities (useradd).

  • Q: What does man 5 passwd show vs. man passwd?

    • A: man passwd defaults to section 1 (the passwd user binary for changing passwords). man 5 passwd displays the file format specification of the /etc/passwd file.

  • Q: How do you search, step forward, step backward, jump to top, jump to bottom, and exit inside a man page?

    • A:

      • /pattern then Enter: Search forward.

      • n: Next match in the same direction.

      • N: Previous match in reverse direction.

      • 1G (or g): Jump to start.

      • G: Jump to end.

      • q: Quit.

  • Q: What is the functional difference between apropos and whatis?

    • A: apropos keyword (equivalent to man -k) searches the descriptions of manual pages for the keyword. whatis command (equivalent to man -f) returns the short one-line description from the man page header.

Chapter 4: Filesystem Hierarchy Standard (FHS) & Paths
  • Q: What is the purpose of the following root directories: /boot, /dev, /etc, /var, /run, /usr?

    • A:

      • /boot: Linux kernel, initramfs, GRUB bootloader files.

      • /dev: Special hardware and pseudo-device files (/dev/sda, /dev/null).

      • /etc: System-wide, host-specific plain text configuration files (persistent).

      • /var: Variable runtime files (logs in /var/log, databases, printer spools).

      • /run: Ephemeral process runtime data since boot (PID files); wiped on reboot.

      • /usr: Static user-space binaries, documentation, libraries, and shareable data.

  • Q: What are /bin and /sbin linked to on modern RHEL systems?

    • A: Symbolic links pointing to /usr/bin and /usr/sbin.

  • Q: What syntax marks an absolute pathname versus a relative pathname?

    • A: Absolute pathnames must begin with / (root) or ~ (tilde). Relative pathnames never start with / or ~ and resolve relative to pwd.

  • Q: What do . and .. represent in Linux path traversal?

    • A: . represents the current working directory; .. represents the immediate parent directory.

  • Q: What does cd - do?

    • A: Changes back to the previous working directory (toggles between current and OLDPWD).

Chapter 5: Managing Files & Directories
  • Q: What is the rule when cp is given 3 or more arguments (e.g., cp f1 f2 f3 dir/)?

    • A: The final argument must be an existing directory, or the command terminates with an error.

  • Q: What switch enables recursive directory copying with cp?

    • A: -r or -R.

  • Q: What switch enables preserving timestamps, ownership, and mode bits with cp?

    • A: -p.

  • Q: Does mv require a -r flag to move or rename directories?

    • A: No. mv moves or renames directories natively without any recursive flag.

  • Q: How does mv behave if the destination argument is an existing directory vs. a non-existent name?

    • A: If destination is an existing directory, it moves the source item inside. If destination does not exist, it renames the source item.

  • Q: What flag enables mkdir to construct missing parent directories automatically?

    • A: -p (e.g., mkdir -p /hw/linux/labs).

  • Q: When does rmdir succeed, and when does it fail?

    • A: It succeeds only if the target directory is completely empty; it fails if the directory contains any files or nested folders.

  • Q: What command forces removal of a non-empty directory structure without prompting?

    • A: rm -rf <directory_name>.

Chapter 6: File Globbing (Wildcards)
  • Q: What does * represent in file globbing?

    • A: Matches zero or more characters (except a leading dot of a hidden file).

  • Q: What does ? represent in file globbing?

    • A: Matches exactly one single character.

  • Q: Does ls * list .bashrc or .hiddenfile? Why or why not?

    • A: No. In Linux, wildcards do not match a leading dot; matching hidden files requires an explicit dot (e.g., ls .*).

  • Q: What does ls [abc]* match?

    • A: Visible files starting with lowercase a, b, or c.

  • Q: What does ls [!abc]* (or ls [^abc]*) match?

    • A: Visible files whose first character is not an a, b, or c.

  • Q: What pattern matches visible files of exactly 5 characters?

    • A: ?????

  • Q: What pattern matches visible files containing at least 4 characters?

    • A: ????*

  • Q: What pattern matches visible files containing lowercase x anywhere in their name?

    • A: *x*

  • Q: What pattern matches files with exactly 7 characters where the 4th character is a digit?

    • A: ???[0-9]???

Chapter 7: Shell Expansions & Links
  • Q: What are the modern and legacy syntaxes for Bash command substitution?

    • A: Modern: (command); Legacy: `command` (backticks).

  • Q: What does Tilde expansion ~ evaluate to? What does ~john evaluate to?

    • A: ~ expands to current user's $HOME; ~john expands to john's home directory (e.g., /home/john).

  • Q: What files are created by touch file{1..3}.txt?

    • A: file1.txt, file2.txt, and file3.txt.

  • Q: What files are created by touch {a,b}{1,2}?

    • A: a1, a2, b1, and b2.

  • Q: Compare Hard Links vs. Symbolic Links across 4 criteria: Inodes, Filesystems, Target Types, Target Deletion.

    • A:

      1. Inodes: Hard link shares the identical inode; symbolic link creates a new, separate inode.

      2. Filesystems: Hard links cannot span across filesystems; symbolic links can.

      3. Target Types: Hard links cannot link directories; symbolic links can link directories.

      4. Target Deletion: Hard link data stays intact until link count is 0; symbolic link becomes dangling (broken).

  • Q: What command removes a symbolic link named mylink without touching the original file?

    • A: rm mylink.

  • Q: What command creates a symbolic link named syslog pointing to /var/log/messages?

    • A: ln -s /var/log/messages syslog.

Chapter 8: I/O Redirection & Text Filters
  • Q: Name the 3 standard I/O streams and their integer file descriptors.

    • A: 0: stdin (Standard Input), 1: stdout (Standard Output), 2: stderr (Standard Error).

  • Q: Distinguish > from >>.

    • A: > redirects stdout, overwriting file contents. >> redirects stdout, appending to the end of the file.

  • Q: How do you redirect only stderr to a file named err.txt?

    • A: command 2> err.txt.

  • Q: How do you discard stderr completely?

    • A: command 2> /dev/null.

  • Q: How do you redirect both stdout and stderr to output.txt?

    • A: command &> output.txt or command > output.txt 2>&1.

  • Q: How do you send stdout to good.txt and stderr to bad.txt in one line?

    • A: command > good.txt 2> bad.txt.

  • Q: What does a pipe (|) connect?

    • A: Connects the stdout (FD 1) of the command on the left to the stdin (FD 0) of the command on the right.

  • Q: What do wc -l, wc -w, and wc -c count?

    • A: -l counts newline lines; -w counts whitespace-delimited words; -c counts byte/character count.

  • Q: How do you inspect the first 7 lines and last 7 lines of /etc/passwd?

    • A: head -n 7 /etc/passwd and tail -n 7 /etc/passwd.

  • Q: How do you follow /var/log/messages live in real time as new lines write?

    • A: tail -f /var/log/messages.

  • Q: What command filters duplicate adjacent lines and prints the frequency count of each?

    • A: sort <file> | uniq -c.

  • Q: What command reads stdin and outputs to both the terminal screen and a file named report.log simultaneously?

    • A: tee report.log (e.g., ls -l | tee report.log).

Chapter 9: Users & Groups
  • Q: What UID is assigned to the root superuser?

    • A: UID 0.

  • Q: What UID range is assigned to system service accounts in modern RHEL?

    • A: UIDs 1 through 999.

  • Q: What UID range is assigned to regular human users?

    • A: UIDs 1000 and higher.

  • Q: List all 7 fields of /etc/passwd in order for john:x:1001:1001:John Doe:/home/john:/bin/bash.

    • A:

      1. Username (john)

      2. Password placeholder (x)

      3. User ID / UID (1001)

      4. Primary Group ID / GID (1001)

      5. Comment / GECOS field (John Doe)

      6. Home directory path (/home/john)

      7. Default login shell (/bin/bash)

  • Q: List all 4 fields of /etc/group in order for wheel:x:10:john,lisa.

    • A:

      1. Group name (wheel)

      2. Group password placeholder (x)

      3. Group ID / GID (10)

      4. Comma-separated list of secondary group members (john,lisa)

  • Q: What shell is assigned to system accounts to disable interactive logins?

    • A: /sbin/nologin (or /bin/false).

  • Q: What directory provides skeleton template configuration dotfiles for new user home directories?

    • A: /etc/skel/

  • Q: What do the useradd flags -u, -d, -g, -G, -s, and -e do?

    • A:

      • -u: Sets custom UID.

      • -d: Sets custom home directory path.

      • -g: Sets primary group (name or GID).

      • -G: Sets secondary (supplementary) group(s).

      • -s: Sets login shell.

      • -e: Sets account expiration date (YYYY-MM-DD).

  • Q: Why must you use usermod -aG group user instead of usermod -G group user?

    • A: -G replaces all current secondary memberships with only the specified group. Adding -a (append) preserves existing group memberships.

  • Q: How do you lock and unlock a user's password using usermod?

    • A: Lock: usermod -L username (prepends ! to hash in /etc/shadow); Unlock: usermod -U username.

  • Q: What userdel switch removes the user's home directory and mail spool?

    • A: -r (e.g., userdel -r username).