First 50 of 200 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 Fundamentals
On a Linux system, which directory is conventionally used to store system-wide configuration files for installed software?
- /var
- /usr/bin
- /etc Correct answer.
- /opt
Explanation
The Filesystem Hierarchy Standard designates /etc as the location for host-specific, system-wide configuration files such as /etc/passwd and /etc/fstab. Programs read their settings from here at startup, which is why administrators back it up and version it.
Question 2Linux Fundamentals
A user runs `pwd` in a shell and sees `/home/alice/projects`. Which statement best describes what this command reports?
- The location of the user's home directory regardless of where the shell is
- The list of directories on the PATH search variable
- The absolute path of the current working directory Correct answer.
- The path of the last command executed in the shell
Explanation
pwd stands for print working directory and outputs the absolute pathname of the directory the shell is currently in. Because the shell reports /home/alice/projects, that is where relative path operations will resolve from.
Question 3Linux Fundamentals
Which command displays the manual page for the `tar` utility?
- tar --help
- man tar Correct answer.
- info -k tar
- help tar
Explanation
The man command opens the manual page for a named command, so `man tar` shows the reference documentation for tar. Manual pages are organized into numbered sections and are the standard on-disk documentation on Linux systems.
Question 4Linux Fundamentals
Which command creates a new empty file named notes.txt in the current directory without altering an existing file's contents if it already exists?
- echo notes.txt
- touch notes.txt Correct answer.
- mkdir notes.txt
- cat notes.txt
Explanation
The touch utility updates file timestamps and, if the file does not exist, creates an empty file. Running it on an existing file leaves the contents intact while updating access and modification times.
Question 5Linux Fundamentals
Which command shows the permissions, owner, group, size, and modification time of files in a directory in long listing format?
- ls -R
- ls -h
- ls -l Correct answer.
- ls -a
Explanation
The -l option to ls produces a long listing that includes the file mode, link count, owner, group, size, timestamp, and name. The other options change which files are shown or how sizes are formatted, but not the long format itself.
Question 6Linux Fundamentals
Which command displays the kernel ring buffer messages, commonly used to inspect hardware and boot-time messages?
- dmesg Correct answer.
- whoami
- free
- uptime
Explanation
dmesg prints the kernel ring buffer, which contains boot messages, driver initialization, and hardware detection events. Administrators use it to diagnose device and kernel issues shortly after boot or after plugging in hardware.
Question 7Linux Fundamentals
Which command changes the permissions of a file so that the owner can read and write it, the group can read it, and others have no access?
- chmod 640 file Correct answer.
- chmod 604 file
- chmod 660 file
- chmod 644 file
Explanation
Octal permissions encode read=4, write=2, execute=1 per class. Owner read+write is 6, group read is 4, and others none is 0, giving 640. This denies all access to other users while allowing the group to read.
Question 8Linux Fundamentals
Which command searches for the string 'error' inside all files under /var/log and prints matching lines with filenames?
- which error
- grep -r error /var/log Correct answer.
- find /var/log -name error
- locate error
Explanation
grep -r recursively searches the contents of files under a directory and prints matching lines, prefixing filenames when multiple files are searched. This is the standard way to scan a log tree for a pattern.
Question 9Linux Fundamentals
Which command displays the disk space used by mounted filesystems in human-readable units?
- free -h
- df -h Correct answer.
- lsblk -h
- du -h
Explanation
df reports filesystem-level usage for mounted filesystems, and -h formats sizes in human-readable units. It answers how full each mount point is, whereas du measures the size of directory trees.
Question 10Linux Fundamentals
A process is running in the foreground of a terminal and the user presses Ctrl+Z. What happens to the process?
- It is suspended and moved to the background stopped state Correct answer.
- It is terminated immediately
- It is detached from the terminal and continues running normally
- It is restarted with a new process ID
Explanation
Ctrl+Z sends SIGTSTP, which suspends the foreground job and returns the shell prompt. The stopped job can later be resumed in the background with bg or in the foreground with fg.
Question 11Linux Fundamentals
A directory listing shows the mode string `-rwxr-x---` for a file. Which statement about access is correct?
- All users can read and execute; only the owner can write
- The owner can read and write; the group can execute; others can read
- The owner can read, write, and execute; the group can read and execute; others have no access Correct answer.
- The owner can read and execute; the group can write; others can execute
Explanation
The mode string is read in three triplets after the leading file-type character: owner rwx, group r-x, others ---. That means the owner has full access, the group can read and execute, and other users are denied all access.
Question 12Linux Fundamentals
Which command sequence replaces the string 'foo' with 'bar' in every line of a file and writes the result to a new file, leaving the original unchanged?
- sed 's/foo/bar/g' input > output Correct answer.
- sed 's/foo/bar/g' input -o output
- sed -i 's/foo/bar/g' input > output
- grep 's/foo/bar/g' input > output
Explanation
sed writes its transformed output to standard output by default, so redirecting with > captures the result in a new file while the input stays intact. The g flag ensures every occurrence on a line is replaced, not just the first.
Question 13Linux Fundamentals
A user wants a command's standard error to be discarded while standard output still appears on the terminal. Which redirection accomplishes this?
- command > /dev/null
- command 2>&1
- command 2> /dev/null Correct answer.
- command < /dev/null
Explanation
File descriptor 2 is standard error, so redirecting 2> to /dev/null discards error output while descriptor 1 continues to point at the terminal. This is a common way to silence warnings without hiding normal results.
Question 14Linux Fundamentals
Which command displays the environment variables currently set in the shell session?
- alias
- history
- set -o
- env Correct answer.
Explanation
The env command prints the exported environment variables and their values, and can also run a command with a modified environment. This is the standard way to inspect variables that child processes will inherit.
Question 15Linux Fundamentals
Which command reports which user is currently logged in and their terminal, session start time, and remote host if applicable?
- groups
- who Correct answer.
- lastlog
- id
Explanation
who reads the utmp records and shows active login sessions with username, terminal, login time, and source host. It answers who is logged on right now, unlike tools that describe a single user's identity.
Question 16Linux Fundamentals
A file must be readable and executable by every user but writable only by its owner. Which chmod command achieves this?
- chmod 700 file
- chmod 755 file Correct answer.
- chmod 644 file
- chmod 775 file
Explanation
755 gives the owner read, write, and execute (7), and group and others read and execute (5 each). This makes the file universally readable and executable while restricting writes to the owner.
Question 17Linux Fundamentals
Which command displays the full path of the executable that would run when a user types `python3`, based on the current PATH?
- type -a python3
- which python3 Correct answer.
- whereis python3
- locate python3
Explanation
which searches the directories listed in PATH and prints the first matching executable, which is exactly the one the shell would launch. It reports the resolved path rather than all known copies.
Question 18Linux Fundamentals
A user needs to find all files under /home that are larger than 100 MB. Which command accomplishes this?
- ls -l /home | grep +100M
- find /home -type f -size 100M
- find /home -type f -size +100M Correct answer.
- du -sh /home -size +100M
Explanation
The find predicate -size +100M matches files strictly larger than 100 mebibytes, and -type f restricts results to regular files. This is the standard idiom for size-based file discovery.
Question 19Linux Fundamentals
Which command displays running processes with their PID, parent PID, CPU and memory usage, and full command line in a snapshot?
- top -n 1
- jobs
- ps aux Correct answer.
- pgrep -l
Explanation
ps aux produces a snapshot listing every process with user, PID, PPID, CPU and memory percentages, and command line. It is the conventional way to capture a point-in-time view of the process table.
Question 20Linux Fundamentals
A user creates a symbolic link with `ln -s /data/reports /home/alice/reports`. What happens if /data/reports is later deleted?
- The link is converted into a hard link to the inode
- The link is automatically removed when the target disappears
- The link remains but becomes dangling and resolves to nothing Correct answer.
- The link retains a copy of the target's contents
Explanation
A symbolic link stores a path to its target rather than the target's inode, so deleting the target leaves the link in place but broken. Accessing it yields a no-such-file error until the target path exists again.
Question 21Linux Fundamentals
Which command changes both the owner to 'web' and the group to 'www-data' for the file app.log?
- chgrp web:www-data app.log
- chown web:www-data app.log Correct answer.
- usermod web:www-data app.log
- chmod web:www-data app.log
Explanation
chown accepts owner:group syntax, so chown web:www-data app.log sets both ownership fields in one operation. This requires appropriate privileges, typically root.
Question 22Linux Fundamentals
A script must append a timestamped line to a log file without truncating existing content. Which redirection operator should be used?
- 2>
- >> Correct answer.
- >
- <
Explanation
The >> operator opens the file for appending, so new output is added after existing content. The single > operator truncates the file first, which would destroy prior log entries.
Question 23Linux Fundamentals
Which command displays the last 20 lines of /var/log/syslog and then keeps following the file as it grows?
- head -n 20 -f /var/log/syslog
- cat -f /var/log/syslog
- tail -n 20 -f /var/log/syslog Correct answer.
- less -f /var/log/syslog
Explanation
tail prints the end of a file, and -f leaves it open to print newly appended lines as they arrive. Combining -n 20 with -f shows the last 20 lines and then live updates, which is standard for log monitoring.
Question 24Linux Fundamentals
Which statement about hard links on a Linux filesystem is correct?
- Hard links can span different filesystems freely
- Hard links may point to directories by default
- Hard links share the same inode, so the data persists until the last link is removed Correct answer.
- Deleting the original name removes the data even if another hard link exists
Explanation
A hard link is an additional directory entry for the same inode, and the link count tracks how many names refer to it. The data is freed only when the last link is unlinked and no process holds the file open.
Question 25Linux Fundamentals
A process is consuming excessive CPU. An administrator runs `renice -n 10 -p 4321`. What is the effect on process 4321?
- Its nice value is reset to zero, restoring default priority
- It is immediately terminated and its resources reclaimed
- Its scheduling priority is lowered, making it less likely to receive CPU time Correct answer.
- It is pinned to a single CPU core for exclusive execution
Explanation
The nice value ranges from -20 (highest priority) to 19 (lowest), and increasing it lowers scheduling priority. Setting -n 10 raises the nice value to 10, so the process yields CPU time more readily to others.
Question 26Linux Fundamentals
Which command shows the absolute path of the current working directory in a Linux shell?
- dirname
- cd
- ls -l
- pwd Correct answer.
Explanation
The pwd builtin prints the absolute pathname of the directory the shell is currently in. It reports the same value that the shell stores in the PWD variable, which is why it works after relative navigation as well.
Question 27Linux Fundamentals
A user runs `mkdir -p /srv/app/config` on a system where /srv/app does not yet exist. What is the result?
- Both /srv/app and /srv/app/config are created Correct answer.
- Only /srv/app/config is created as a single directory name
- The command fails because the parent directory is missing
- The command prompts interactively before creating parents
Explanation
The -p option makes mkdir create any missing intermediate directories and suppresses the error when the final directory already exists. Without it, mkdir would refuse to create a child of a nonexistent parent.
Question 28Linux Fundamentals
Which file on a Linux system holds the list of user accounts, including UID, primary GID, home directory, and login shell?
- /etc/passwd Correct answer.
- /etc/group
- /etc/shadow
- /etc/login.defs
Explanation
/etc/passwd contains one line per account with seven colon-separated fields: name, password placeholder, UID, GID, comment, home directory, and shell. It is world-readable, so password hashes were moved to /etc/shadow.
Question 29Linux Fundamentals
What does the command `tar -czf backup.tar.gz /home/alice` do?
- Extracts the archive backup.tar.gz into /home/alice
- Lists the contents of backup.tar.gz without extracting
- Creates a gzip-compressed tar archive named backup.tar.gz from /home/alice Correct answer.
- Verifies the checksum of /home/alice against backup.tar.gz
Explanation
In tar, -c creates an archive, -z filters it through gzip, and -f names the archive file, which must come immediately before the filename. The remaining argument is the path to include.
Question 30Linux Fundamentals
A user wants to see the manual page for the `cp` command. Which command displays it?
- cp --help-all
- whatis cp
- info --cp
- man cp Correct answer.
Explanation
man is the standard interface for reading the reference manuals installed under /usr/share/man. It renders the page for the named command, and the pages are organized into numbered sections such as 1 for user commands.
Question 31Linux Fundamentals
Which command displays the amount of free and used memory in the system in mebibytes?
- df -m
- vmstat -m
- du -m
- free -m Correct answer.
Explanation
free reports total, used, free, shared, buffer/cache, and available memory; the -m flag expresses values in mebibytes. It reads the kernel's memory statistics, so it reflects RAM and swap rather than disk usage.
Question 32Linux Fundamentals
A file named notes.txt has mode 644 and is owned by alice. Bob, who is not in alice's group, tries to execute it with `./notes.txt`. What happens?
- It fails with a permission denied error Correct answer.
- It runs only if Bob uses sudo
- It runs because read permission implies execute permission
- It is copied to a temporary location and executed
Explanation
On Linux, read, write, and execute are independent permission bits. Mode 644 grants others read only, so the kernel refuses execution for Bob with EACCES; the script's content is irrelevant to that check.
Question 33Linux Fundamentals
Which command prints the lines of file1.txt and file2.txt concatenated to standard output?
- paste file1.txt file2.txt
- cat file1.txt > file2.txt
- tee file1.txt file2.txt
- cat file1.txt file2.txt Correct answer.
Explanation
cat accepts multiple file arguments and writes their contents in order to standard output. It does not modify either file.
Question 34Linux Fundamentals
Which command displays the first 10 lines of a file named access.log by default?
- wc -l access.log
- head access.log Correct answer.
- less access.log
- tail access.log
Explanation
head prints the beginning of a file and defaults to 10 lines; the count can be changed with -n. It is the counterpart of tail, which prints the end of a file.
Question 35Linux Fundamentals
What does the command `chown alice:developers report.txt` do?
- Copies report.txt into alice's home directory
- Changes only the group of report.txt to developers
- Adds alice to the developers group
- Changes the owner to alice and the group to developers Correct answer.
Explanation
chown accepts an owner:group specification; the part before the colon sets the user and the part after sets the group. Only root, or a user with appropriate privileges, can give a file away to another owner.
Question 36Linux Fundamentals
Which command shows the UUID and filesystem type of each block device, which is useful before editing /etc/fstab?
- lsblk -f
- mount
- fdisk -l
- blkid Correct answer.
Explanation
blkid prints the UUID, label, and filesystem type for each block device by probing the filesystem superblocks. These UUID values are commonly used in /etc/fstab so that entries survive device reordering.
Question 37Linux Fundamentals
A script needs to check whether a directory named /opt/data exists before writing to it. Which test accomplishes this?
- [ -f /opt/data ]
- [ -e /opt/data ]
- [ -x /opt/data ]
- [ -d /opt/data ] Correct answer.
Explanation
The -d test succeeds only when the path names a directory. Using -e would also succeed for a regular file of the same name, which could cause the script to write to the wrong kind of object.
Question 38Linux Fundamentals
A system administrator wants to add read and write permission for the group on a file without changing any other permission bits. Which command does this?
- chmod 666 file
- chmod g=rw file
- chmod u+rw file
- chmod g+rw file Correct answer.
Explanation
The symbolic form g+rw adds the read and write bits to the group class while leaving the owner, other, and setuid/setgid/sticky bits untouched. That is important when a file has special bits set.
Question 39Linux Fundamentals
An administrator runs `find /var/log -type f -name '*.log' -mtime +7`. Which files does this match?
- Regular files ending in .log modified more than 7 days ago Correct answer.
- Any file or directory named with .log regardless of age
- Regular files ending in .log with a size greater than 7 blocks
- Regular files ending in .log modified within the last 7 days
Explanation
find applies all tests as an AND, so a match must be a regular file, end in .log, and have a modification time older than 7 full days because of +7. The -mtime test counts 24-hour periods since the last content modification.
Question 40Linux Fundamentals
A user's shell reports `command not found` for a program that exists at /usr/local/bin/tool. Which condition most directly explains this?
- The shell was started with the -n option
- The file lacks the setuid bit
- The directory /usr/local/bin is absent from the PATH variable Correct answer.
- The file is owned by root
Explanation
When a command name has no slash, the shell searches each directory listed in PATH in order. If /usr/local/bin is not in PATH, the existing executable is never considered, producing the not-found message regardless of its contents.
Question 41System Administration Fundamentals
A Linux administrator wants to see the manual page for the `tar` command, including a section describing its options. Which command displays the tar manual page?
- man tar Correct answer.
- less tar
- info --tar
- cat tar
Explanation
The man command formats and displays the on-line reference manual pages installed on the system, so `man tar` opens the tar manual. The other commands either try to read a file named tar in the current directory or use an invalid option.
Question 42System Administration Fundamentals
Which command shows the current working directory of the shell?
- cd
- whoami
- pwd Correct answer.
- ls
Explanation
pwd prints the absolute path of the shell's current working directory. cd changes directory, ls lists directory contents, and whoami prints the effective user name.
Question 43System Administration Fundamentals
An administrator needs to create a new empty regular file named `report.txt` in the current directory, failing if it already exists. Which command does this?
- mkdir report.txt
- mkfifo report.txt
- ln -s report.txt
- python3 -c "open('report.txt', 'x').close()" Correct answer.
Explanation
Python's 'x' mode creates a file exclusively: if report.txt is absent, this command creates an empty regular file and closes it; if the path already exists, it raises FileExistsError and exits unsuccessfully. This satisfies both the regular-file and fail-if-present requirements.
Question 44System Administration Fundamentals
Which command changes the permissions of `script.sh` so that the owner can read, write, and execute it, while group and others get no permissions?
- chmod 777 script.sh
- chmod 111 script.sh
- chmod 644 script.sh
- chmod 700 script.sh Correct answer.
Explanation
Octal permissions are read=4, write=2, execute=1 per class, so 700 gives the owner rwx and nothing to group and others. 777 grants full access to everyone, 644 grants rw to owner and r to others, and 111 grants execute only.
Question 45System Administration Fundamentals
On a systemd-based Linux distribution, which command shows the status of the `sshd` service, including whether it is active?
- service sshd show
- systemctl status sshd Correct answer.
- initctl status sshd
- journalctl sshd status
Explanation
systemctl status queries the service manager for the unit's state, recent log lines, and main PID. The other forms are not valid commands for inspecting a unit on a systemd host.
Question 46System Administration Fundamentals
Which command displays the disk usage of each mounted filesystem in human-readable units?
- free -h
- lsblk -h
- du -h
- df -h Correct answer.
Explanation
df reports filesystem-level space usage per mount point, and -h scales the numbers to KiB, MiB, and GiB. du summarizes space used by files under a path, free reports memory, and lsblk lists block devices.
Question 47System Administration Fundamentals
A user wants to append the text `done` as a new line to `log.txt` without overwriting existing content. Which shell redirection does this?
- echo done > log.txt
- echo done | log.txt
- echo done >> log.txt Correct answer.
- echo done < log.txt
Explanation
>> opens the file in append mode, so existing content is preserved. A single > truncates the file, a pipe sends output to a program rather than a file, and < redirects input.
Question 48System Administration Fundamentals
Which command shows the groups a user belongs to, including the primary group?
- last
- passwd
- id Correct answer.
- who
Explanation
id prints the user's UID, primary GID, and supplementary group memberships. passwd changes passwords, who lists logged-in users, and last shows login history.
Question 49System Administration Fundamentals
An administrator runs `ps aux` and wants to find processes consuming the most CPU. Which command sorts the process list by CPU usage in descending order?
- ps aux | grep cpu
- ps -ef --top cpu
- ps aux --sort=-%cpu Correct answer.
- ps aux --sort=%cpu
Explanation
The --sort key accepts a field name; prefixing it with a minus sign reverses the order so the highest CPU consumers appear first. Plain --sort=%cpu sorts ascending, grep only filters text, and --top is not a valid ps option.
Question 50System Administration Fundamentals
A long-running foreground process in a terminal must be suspended and then resumed in the background. Which sequence of keystrokes and commands accomplishes this?
- Ctrl+Z, then kill
- Ctrl+D, then jobs
- Ctrl+Z, then bg Correct answer.
- Ctrl+C, then fg
Explanation
Ctrl+Z sends SIGTSTP, suspending the foreground job, and bg resumes the most recently stopped job in the background. Ctrl+C terminates the process, Ctrl+D signals end of input, and kill would terminate rather than resume.