CTLA study materials
CTLA study resources

CTLA practice questions

One question at a time. Build your CTLA understanding.

First 50 of 199 questions. Each one lists the choices, the correct answer, and an explanation. The checker at the top of this page saves progress in this browser when it is available.

Continue in the practice tool above to load more questions, 50 at a time.

Question 1Linux System Administration

Which command shows the current working directory in a Linux shell?

  1. ls
  2. pwd Correct answer.
  3. cd
  4. dir

Explanation

The pwd utility prints the absolute path of the current working directory by resolving the shell's position in the filesystem. It is a read-only query and does not change location.

Question 2Linux System Administration

Which file normally holds the list of local user accounts on a Linux system?

  1. /etc/passwd Correct answer.
  2. /etc/group
  3. /etc/sudoers
  4. /etc/shadow

Explanation

/etc/passwd stores one line per local account with fields for name, UID, GID, home directory, and login shell. Password hashes were moved out of it into /etc/shadow for security.

Question 3Linux System Administration

What does the octal mode 755 grant to the file owner?

  1. write and execute only
  2. read and execute only
  3. read, write, and execute Correct answer.
  4. read and write only

Explanation

Each octal digit encodes read (4), write (2), and execute (1) for one class. The leading 7 sums to 4+2+1, so the owner receives read, write, and execute permission.

Question 4Linux System Administration

Which signal does the kill command send by default when no signal is specified?

  1. SIGKILL
  2. SIGINT
  3. SIGTERM Correct answer.
  4. SIGHUP

Explanation

The kill utility defaults to SIGTERM (15), which requests a graceful shutdown so the process can clean up. SIGKILL must be requested explicitly because it cannot be caught or ignored.

Question 5Linux System Administration

Which command displays the manual page for the tar utility?

  1. which tar
  2. info tar
  3. tar --help
  4. man tar Correct answer.

Explanation

The man command formats and displays the manual page stored for a given utility. It provides the full reference documentation rather than a short summary.

Question 6Linux System Administration

Which directory is conventionally used for system-wide configuration files?

  1. /usr/bin
  2. /tmp
  3. /etc Correct answer.
  4. /var

Explanation

The Filesystem Hierarchy Standard reserves /etc for host-specific configuration files. Administrators edit files there to change service and system behavior.

Question 7Linux System Administration

Which command changes the owner of a file to the user alice?

  1. chmod alice file.txt
  2. usermod alice file.txt
  3. chgrp alice file.txt
  4. chown alice file.txt Correct answer.

Explanation

chown sets the owning user of a file, and only root or a privileged user may transfer ownership. The other commands modify mode bits, group ownership, or account attributes.

Question 8Linux System Administration

Which command prints the kernel ring buffer messages, showing recent hardware and driver events?

  1. dmesg Correct answer.
  2. who
  3. last
  4. uptime

Explanation

dmesg reads the kernel ring buffer, which records boot-time and runtime messages from the kernel and drivers. Administrators use it to diagnose hardware and driver problems.

Question 9Linux System Administration

A script must append one line to /var/log/audit.txt without truncating existing content. Which redirection accomplishes this?

  1. command 2> /var/log/audit.txt
  2. command >> /var/log/audit.txt Correct answer.
  3. command > /var/log/audit.txt
  4. command < /var/log/audit.txt

Explanation

The double greater-than operator opens the target in append mode, so new output is added after existing bytes. A single greater-than truncates the file first, destroying prior entries.

Question 10Linux System Administration

You need to find every regular file under /srv larger than 100 MB. Which command performs this search?

  1. du -sh /srv
  2. find /srv -type f -size +100M Correct answer.
  3. grep -r 100M /srv
  4. ls -lR /srv

Explanation

find supports a -type f test to restrict results to regular files and a -size test with a + prefix meaning greater than. Combining both predicates yields exactly the oversized files.

Question 11Linux System Administration

Which crontab entry runs /usr/local/bin/report.sh every day at 02:30?

  1. 30 * * * 2 /usr/local/bin/report.sh
  2. * * 2 30 * /usr/local/bin/report.sh
  3. 2 30 * * * /usr/local/bin/report.sh
  4. 30 2 * * * /usr/local/bin/report.sh Correct answer.

Explanation

Cron fields are ordered minute, hour, day of month, month, and day of week. Therefore 30 in the minute field and 2 in the hour field schedule the job at 02:30 daily.

Question 12Linux System Administration

A directory has permissions drwxr-x--- owned by root:developers. Which statement is true for a user who is a member of developers but not root?

  1. The user can read files but cannot list the directory
  2. The user can list the directory but cannot create files in it Correct answer.
  3. The user can create and delete files in the directory
  4. The user has no access to the directory

Explanation

The group class has r-x, so members of developers may read the listing and traverse the directory but lack the write bit. Without write permission on the directory, creating or removing entries is denied.

Question 13Linux System Administration

Which command shows which process is listening on TCP port 443?

  1. traceroute -p 443
  2. ping -p 443
  3. ss -tlnp Correct answer.
  4. arp -n

Explanation

The ss utility reports socket statistics, and the combined flags -tlnp select TCP sockets, listening state, numeric ports, and the owning process. This reveals the daemon bound to port 443.

Question 14Linux System Administration

What is the effect of running chmod g+s on a directory?

  1. The directory becomes read-only for the group
  2. New files inherit the directory's group ownership Correct answer.
  3. New files become owned by the directory owner
  4. Group members gain write access to the directory

Explanation

The setgid bit on a directory causes newly created entries to inherit the directory's group instead of the creator's primary group. This is commonly used for shared team directories.

Question 15Linux System Administration

Which command displays the disk space used by each mounted filesystem in human-readable units?

  1. df -h Correct answer.
  2. free -h
  3. du -h
  4. fdisk -l

Explanation

df reports filesystem-level usage for mounted devices, and -h scales the numbers into human-readable units. It answers how full each filesystem is.

Question 16Linux System Administration

Which command adds the user bob to the supplementary group wheel without removing his existing groups?

  1. usermod -G wheel bob
  2. gpasswd -d bob wheel
  3. groupadd -a bob wheel
  4. usermod -aG wheel bob Correct answer.

Explanation

The -a flag appends to the user's supplementary group list, while -G alone replaces that list entirely. Combining -a with -G preserves existing memberships.

Question 17Linux System Administration

A service fails to start after a configuration change. Which command shows its most recent log entries from the systemd journal?

  1. cat /var/log/messages
  2. journalctl -u service.service -n 50 Correct answer.
  3. systemctl status --all
  4. dmesg | tail

Explanation

journalctl with -u filters entries to a specific unit, and -n limits output to the last 50 lines. This isolates the service's recent messages quickly.

Question 18Linux System Administration

Which entry in /etc/fstab mounts /dev/sdb1 at /data with automatic mounting at boot?

  1. /dev/sdb1 ext4 /data defaults 0 2
  2. mount /dev/sdb1 /data ext4 defaults 0 2
  3. /data /dev/sdb1 ext4 defaults 0 2
  4. /dev/sdb1 /data ext4 defaults 0 2 Correct answer.

Explanation

fstab fields are device, mount point, filesystem type, options, dump flag, and fsck order. Only the first option follows that exact order with the device before the mount point.

Question 19Linux System Administration

Which umask value produces newly created directories with mode 750 by default?

  1. 077
  2. 002
  3. 027 Correct answer.
  4. 022

Explanation

Directories are created with a base mode of 777, and the umask clears the bits it specifies. Subtracting 027 from 777 yields 750, giving the owner full access, the group read and execute, and others nothing.

Question 20Linux System Administration

A process is stuck in uninterruptible sleep and ignores SIGTERM. What is the appropriate administrative response?

  1. Renice the process to a higher priority
  2. Suspend the process with SIGSTOP permanently
  3. Send SIGKILL and expect immediate termination
  4. Investigate the blocking I/O or device before acting Correct answer.

Explanation

Uninterruptible sleep means the process is waiting in the kernel, typically on I/O, and even SIGKILL cannot take effect until that wait completes. The correct action is to identify the blocking resource rather than escalate signals.

Question 21Linux System Administration

An ext4 filesystem reports errors on mount and the system boots into emergency mode. Which sequence best restores service safely?

  1. Delete the journal with tune2fs and remount read-write
  2. Reformat the partition and restore from the last backup
  3. Run fsck on the unmounted device, then remount and verify Correct answer.
  4. Remount the filesystem read-write and continue booting

Explanation

Filesystem consistency checks must run on an unmounted device to avoid further corruption. After fsck repairs metadata, remounting and verifying data integrity confirms the repair succeeded.

Question 22Linux System Administration

A server has a full root filesystem, but df shows free space on the same device. Which condition most likely explains the discrepancy?

  1. Open deleted files still held by running processes Correct answer.
  2. The filesystem is mounted read-only
  3. The swap partition is undersized
  4. The inode table has been exhausted

Explanation

When a process keeps a deleted file open, the blocks are not reclaimed until the descriptor closes, so df reports the space as used. Comparing df output with du often reveals the gap, and lsof can identify the holding process.

Question 23Linux System Administration

You must grant a contractor permission to run only /usr/bin/backup as root, without a password. Which sudoers entry achieves this?

  1. %contractor ALL=(root) NOPASSWD: ALL
  2. contractor ALL=(root) /usr/bin/backup, /bin/*
  3. contractor ALL=(root) NOPASSWD: /usr/bin/backup Correct answer.
  4. contractor ALL=(ALL) ALL

Explanation

The sudoers rule specifies the user, the host, the target user, and the exact command path with NOPASSWD to skip authentication. Limiting the command to a single absolute path enforces least privilege.

Question 24Linux System Administration

A systemd unit needs to start only after the network is fully online and must restart on failure. Which directives accomplish this?

  1. Wants=network.target and RemainAfterExit=yes
  2. After=network-online.target and Restart=on-failure under [Service] Correct answer.
  3. Before=network-online.target and Restart=always under [Unit]
  4. Requires=network.target and Type=oneshot

Explanation

Ordering is controlled by After in the [Unit] section, while Restart belongs in [Service] and governs automatic restarts. Together they delay startup until the network is ready and recover from crashes.

Question 25Linux System Administration

Which command creates a compressed tar archive of /home while preserving permissions and excluding cache directories?

  1. tar -czf backup.tgz --exclude='*/cache' -p /home Correct answer.
  2. cp -a /home backup.tgz
  3. gzip -r /home
  4. tar -xzf backup.tgz /home

Explanation

The -c flag creates an archive, -z compresses with gzip, -f names the file, --exclude skips matching paths, and -p preserves permissions. This combination produces the required backup with caches omitted.

Question 26Linux System Administration

Which command displays the currently loaded kernel modules along with their sizes and reference counts?

  1. depmod
  2. insmod
  3. modinfo
  4. lsmod Correct answer.

Explanation

lsmod reads /proc/modules and prints each loaded module with its memory size and usage count, which makes it the standard tool for inspecting what the kernel currently has loaded. The other commands work with module files or the dependency database rather than the live loaded set.

Question 27Linux System Administration

A user reports that a newly created file in their home directory is readable by group members even though they expected it to be private. Which setting most directly determines the default permission bits applied to newly created files?

  1. The default SELinux context of the home directory
  2. The umask value of the user's shell session Correct answer.
  3. The setgid bit on the home directory
  4. The ACL mask entry on the home directory

Explanation

The umask is subtracted from the base mode requested by the creating program, so it directly controls which permission bits are cleared for new files and directories. ACL masks and SELinux labels affect access decisions in different ways but do not set the traditional mode bits created at file creation.

Question 28Linux System Administration

Which command shows the total amount of RAM and swap currently in use, refreshed interactively, on a typical Linux system?

  1. top Correct answer.
  2. du -sh /
  3. vmstat 1
  4. free -h

Explanation

top provides a continuously refreshed interactive view of memory and swap usage alongside per-process statistics. free prints a single snapshot, vmstat reports virtual memory statistics over intervals, and du measures disk usage rather than memory.

Question 29Linux System Administration

Which command creates a symbolic link named /usr/local/bin/report that points to /opt/tools/report.sh?

  1. ln /opt/tools/report.sh /usr/local/bin/report
  2. ln -h /opt/tools/report.sh /usr/local/bin/report
  3. ln -s /opt/tools/report.sh /usr/local/bin/report Correct answer.
  4. cp -l /opt/tools/report.sh /usr/local/bin/report

Explanation

ln -s creates a symbolic link whose target is the first argument and whose link path is the second argument. Without -s, ln creates a hard link, and cp -l also creates hard links rather than symbolic ones.

Question 30Linux System Administration

A process is consuming 100% CPU and its PID is 4821. Which command sends SIGTERM to that process by PID?

  1. killall -TERM 4821
  2. kill -9 4821
  3. pkill -TERM 4821
  4. kill -TERM 4821 Correct answer.

Explanation

kill -TERM 4821 sends the default termination signal to the specific PID given. killall and pkill select processes by name or pattern rather than by exact PID, and -9 sends SIGKILL instead of SIGTERM.

Question 31Linux System Administration

You need to view lines 200 through 250 of a 10000-line log file. Which command displays exactly that range?

  1. tail -n 250 /var/log/app.log
  2. grep -n '200,250' /var/log/app.log
  3. head -n 250 /var/log/app.log
  4. sed -n '200,250p' /var/log/app.log Correct answer.

Explanation

sed -n '200,250p' suppresses default output and prints only the addressed line range, which yields exactly lines 200 through 250. head and tail select from the start or end of the file, and grep searches for a pattern rather than a line range.

Question 32Linux System Administration

A directory /srv/shared is owned by root:staff with mode 2775. A file created there by user alice should be editable by other members of staff. Which statement describes the effect of the existing permissions on a newly created file?

  1. The file inherits the staff group and is group-writable only if alice's umask permits it Correct answer.
  2. The file is automatically group-writable because the setgid bit forces 0664
  3. The file inherits the staff group but always gets mode 0644 regardless of umask
  4. The file is owned by root because the directory is setgid

Explanation

The setgid bit makes new files inherit the directory's group, but the permission bits still come from the creating program's requested mode minus the user's umask. Setgid does not change ownership to root and does not force group-write.

Question 33Linux System Administration

You want to replace all occurrences of the string 'foo' with 'bar' in a file in place using sed and keep a backup of the original. Which command does this?

  1. sed 's/foo/bar/' file.conf | tee file.conf
  2. sed 's/foo/bar/g' file.conf > file.conf
  3. sed -e 's/foo/bar/g' file.conf
  4. sed -i.bak 's/foo/bar/g' file.conf Correct answer.

Explanation

sed -i.bak edits the file in place and saves the original as file.conf.bak, while the g flag replaces every occurrence on each line. Redirecting output onto the same file truncates it before sed reads it, and the pipeline with tee also risks truncation.

Question 34Linux System Administration

A file has permissions -rw-r----- owned by alice:devs. Bob is not in devs but has been granted read access through a named ACL entry. Which command displays the ACL to verify this?

  1. chacl file
  2. ls -l file
  3. getfacl file Correct answer.
  4. stat -c '%a' file

Explanation

getfacl prints the full access control list, including named user and group entries that ls -l and stat do not show. The ls -l output only indicates that an ACL exists via a trailing plus sign and does not reveal its contents.

Question 35Linux System Administration

A system uses LVM. You need to grow the logical volume /dev/vg0/data and the ext4 filesystem on it while it is mounted. Which sequence accomplishes this?

  1. pvresize /dev/vg0/data then xfs_growfs /dev/vg0/data
  2. lvextend -L +5G /dev/vg0/data then resize2fs /dev/vg0/data Correct answer.
  3. resize2fs /dev/vg0/data then lvextend -L +5G /dev/vg0/data
  4. lvextend -L +5G /dev/vg0/data then mkfs.ext4 /dev/vg0/data

Explanation

The logical volume must be enlarged first, then resize2fs grows the ext4 filesystem to fill the new space; ext4 supports online growth. Running resize2fs before extending the LV leaves no new space to consume, and reformatting destroys data.

Question 36Linux System Administration

You must schedule a job to run once at 03:00 on the next occurrence of the 15th of the month. Which tool is designed for one-time execution at an absolute time?

  1. anacron
  2. systemd timers with OnCalendar
  3. cron
  4. at Correct answer.

Explanation

at schedules a command to run once at a specified absolute time and is intended for one-off jobs. cron and systemd timers are recurring schedulers, and anacron runs missed recurring jobs on systems that are not always on.

Question 37Linux System Administration

A host cannot resolve external names, but pinging an IP address works. Which file should you inspect first to see the configured DNS servers?

  1. /etc/resolv.conf Correct answer.
  2. /etc/hosts
  3. /etc/hostname
  4. /etc/nsswitch.conf

Explanation

/etc/resolv.conf lists the nameserver addresses the resolver queries for DNS lookups. /etc/hosts contains static name mappings, nsswitch.conf sets lookup order, and hostname holds the local host name.

Question 38Linux System Administration

A systemd service unit must not start until the network is online and must be restarted automatically if it exits with a failure. Which pair of directives in the [Unit] and [Service] sections accomplishes this?

  1. Wants=network.target and Restart=always
  2. Requires=network.target and Restart=no
  3. Before=network-online.target and Restart=on-abort
  4. After=network-online.target and Restart=on-failure Correct answer.

Explanation

After=network-online.target orders the unit after the network is fully online, and Restart=on-failure restarts the service only when it exits unsuccessfully. Ordering alone does not pull in the target, so pairing it with Wants or Requires is common, but the restart behavior in the other options is incorrect.

Question 39Linux System Administration

A filesystem is mounted read-only after errors were detected. Which command checks and repairs the filesystem on /dev/sdb1 while it is unmounted?

  1. tune2fs -c 0 /dev/sdb1
  2. fsck -n /dev/sdb1
  3. e2fsck -p /dev/sdb1
  4. fsck -y /dev/sdb1 Correct answer.

Explanation

fsck -y answers yes to repair prompts, allowing automatic correction of detected inconsistencies on the unmounted device. The -n option only reports problems without fixing them, and tune2fs adjusts filesystem parameters rather than repairing damage.

Question 40Linux System Administration

A server has two default routes in its routing table, one via 192.0.2.1 and one via 192.0.2.2. Which factor determines which gateway is used for traffic to an arbitrary external address?

  1. The metric value of each default route, with the lower metric preferred Correct answer.
  2. The interface name alphabetically first among the two routes
  3. The order in which the routes appear in the routing table
  4. The gateway with the higher IP address

Explanation

When multiple routes match the same destination prefix, the kernel prefers the one with the lowest metric, so the default route with the smaller metric wins. Listing order and interface naming do not decide selection, and the gateway address itself is not a tiebreaker.

Question 41Shell Scripting and Command-Line Tools

In a shell command line, which character sequence redirects only standard error of a command to a file named err.log while leaving standard output on the terminal?

  1. 1> err.log
  2. 2> err.log Correct answer.
  3. 2>&1 err.log
  4. &> err.log

Explanation

File descriptor 2 is standard error, so 2> err.log sends only stderr to the file while stdout continues to the terminal. The &> form redirects both streams together, which is not what is asked.

Question 42Shell Scripting and Command-Line Tools

Which construct assigns the string value to variable NAME without executing any command?

  1. export NAME value
  2. NAME = value
  3. NAME="value" Correct answer.
  4. set NAME=value

Explanation

In POSIX shells and bash, a variable assignment has no spaces around the equals sign, and quoting protects the value from word splitting. Spaces around = would make the shell treat NAME as a command name.

Question 43Shell Scripting and Command-Line Tools

A script begins with the line #!/bin/bash. What is the purpose of this line?

  1. It defines the default working directory for the script.
  2. It is a comment ignored by the kernel and the shell.
  3. It enables strict error handling for the whole script.
  4. It tells the kernel which interpreter program should execute the script file. Correct answer.

Explanation

When a file is executed directly, the kernel reads the leading #! line and launches the named interpreter with the script path as an argument. Without it, the file would be interpreted by whatever shell the caller happens to be using.

Question 44Shell Scripting and Command-Line Tools

Which command prints the value of the shell variable HOME?

  1. echo $(HOME)
  2. echo HOME
  3. echo $HOME Correct answer.
  4. echo ${HOME}value

Explanation

A dollar sign followed by a variable name triggers parameter expansion, so echo $HOME prints the stored path. The brace form ${HOME}value would append the literal text value to the result.

Question 45Shell Scripting and Command-Line Tools

Which pipeline counts the number of lines produced by the command ls -l?

  1. ls -l | wc -l Correct answer.
  2. ls -l && wc -l
  3. ls -l | wc -w
  4. ls -l > wc -l

Explanation

The pipe sends stdout of ls -l into stdin of wc, and the -l option of wc counts newline characters, which equals the number of lines. The && operator would run wc without any piped input.

Question 46Shell Scripting and Command-Line Tools

What does the command chmod 644 report.txt set for that file?

  1. Read and write for the owner, read only for group and others Correct answer.
  2. Read and write for everyone, execute for the owner
  3. Execute for the owner, read for group and others
  4. Read only for the owner, write for group and others

Explanation

Each octal digit encodes read as 4, write as 2 and execute as 1 for owner, group and others in that order. The digits 6, 4 and 4 therefore give rw- to the owner and r-- to group and others.

Question 47Shell Scripting and Command-Line Tools

Which command prints the current working directory?

  1. whereami
  2. cd
  3. dirs -c
  4. pwd Correct answer.

Explanation

The pwd builtin writes the absolute pathname of the current working directory to standard output. The cd builtin changes that directory rather than reporting it.

Question 48Shell Scripting and Command-Line Tools

A script runs grep -q "^root" /etc/passwd and then checks $?. What does a value of 0 in $? indicate?

  1. The pattern was not found in the file.
  2. The pattern was found at least once. Correct answer.
  3. The file could not be opened.
  4. The grep command was interrupted by a signal.

Explanation

grep exits with status 0 when at least one line matches, 1 when no line matches, and 2 or more on errors. Because -q suppresses output, the exit status is the only way to learn the result.

Question 49Shell Scripting and Command-Line Tools

Which test expression is true when the file /etc/hosts exists and is a regular file?

  1. [ -f /etc/hosts ] Correct answer.
  2. [ -x /etc/hosts ]
  3. [ -d /etc/hosts ]
  4. [ -s /etc/hosts ]

Explanation

The -f unary operator in test succeeds only for a regular file that exists. The -d operator checks for a directory, and -x checks the execute permission bit.

Question 50Shell Scripting and Command-Line Tools

What does the command find /var/log -name "*.log" -mtime +7 -print do?

  1. Lists .log files under /var/log modified within the last seven days
  2. Deletes .log files under /var/log older than seven days
  3. Lists all files under /var/log regardless of name or age
  4. Lists .log files under /var/log modified more than seven days ago Correct answer.

Explanation

In find, -mtime +7 matches files whose data was last modified more than seven whole days ago, and -name filters on the filename pattern. The -print action then writes matching paths to standard output.