An operating system manages CPU time, memory, storage and devices on behalf of running programs, and Linux is the usual environment for backend and DevOps work. Questions cover processes and threads, CPU scheduling, virtual memory and page replacement, synchronization, race conditions, deadlocks, I/O multiplexing, kernel design, file descriptors and practical Linux usage.
All 38 Linux & OS quiz questions below come with a short explanation, visible right on the page — no sign-in needed. They're grouped by beginner and intermediate levels and 23 subtopics, so you can revise one part at a time. Choose Try Linux & OS quiz above to take a scored run and review the questions you got wrong.
What the Linux & OS quiz covers
Shell4
Filesystem3
Memory3
Networking3
Processes3
Files2
Logs2
Performance2
Permissions2
Containers1
Cron1
Debugging1
Disk1
Limits1
Process1
Security1
SSH1
systemd1
Systemd1
Text Processing1
Time1
Transfer1
Users1
Beginner level — 10 Linux & OS questions
Question 1·Permissions
What does chmod 644 file.txt grant?
A.The owner and the group read and write; others get nothing
B.The owner reads, writes and executes; the group and others read only
C.The owner reads and writes; the group and others read
D.Everyone can read and write the file
Answer: C
Owner: read + write (4+2=6). Group: read (4). Others: read (4). Mnemonic: 4 read, 2 write, 1 execute, summed per group in owner–group–other order.
Which command finds the process occupying port 3000?
A.ps aux | grep 3000 to search the process list
B.lsof -i :3000, or ss -ltnp
C.curl localhost:3000 to see what comes back
D.netstat -a and scan the list by eye
Answer: B
lsof -i :3000 or ss -ltnp | grep 3000 — both give the PID and process name. ss is the modern replacement for netstat; the flags -ltnp mean listening, TCP, numeric, with process.
SSH reports "permissions are too open" for the private key. Fix?
A.chmod 777 to be sure it can be read without an error
B.Add StrictHostKeyChecking no to the SSH configuration
C.Convert the key to PEM format and try again
D.chmod 600 on the private key file
Answer: D
chmod 600 ~/.ssh/id_ed25519 — read/write for the owner only. SSH deliberately refuses a private key that others on the same machine can read, because such a key must be treated as compromised.
Counting lines containing "ERROR" in a 2GB log — tidiest way?
A.grep -c ERROR app.log
B.Open the file in an editor and use its search feature
C.cat app.log | grep ERROR | wc -l
D.awk /ERROR/ app.log and count the results by eye
Answer: A
grep -c ERROR app.log. For large logs grep is very fast because it streams. To count per group add sort | uniq -c; to follow live use tail -f app.log | grep ERROR.
Running a long process over SSH that must survive disconnection. What do you use?
A.Add & to the end of the command to run it in the background
B.Raise ClientAliveInterval in the SSH server's configuration
C.tmux or screen; nohup for something simple
D.Run it with sudo so the process belongs to root
Answer: C
tmux (or screen) is the best choice: the process runs in a detached session, so you can disconnect and reattach to keep watching. nohup command & is enough for simple cases where you don't need interactive output.
Syncing a large directory to a server, sending only changes next time. What do you use?
A.Tar it up, copy it over and extract it again
B.Use sftp and pick the new files by hand
C.rsync -avz, because it transfers only the differences
D.scp -r every time to be sure it is complete
Answer: C
rsync -avz src/ user@host:/dest/. It compares both sides and transfers only what differs, so later syncs are very fast. -a preserves permissions and timestamps, -v prints details, -z compresses in transit.
A user was added to the docker group but still gets permission denied. Why?
A.The Docker socket's permissions must be reset with chmod
B.A new group only takes effect in a new login session
C.The docker group needs sudo rights to work
D.The Docker daemon must be restarted to pick up the new group
Answer: B
The group list is loaded at login, so the current session does not see the new group yet. Log out and back in (or newgrp docker for the current shell). Check with id — if docker is not listed, the session is still stale.
What should a bash script start with so errors are not ignored?
A.trap to catch every signal sent to the script
B.#!/bin/bash is enough for any bash script
C.set -x to print every command before running it
D.set -euo pipefail
Answer: D
set -euo pipefail: -e stops when a command fails, -u errors on use of an undeclared variable, -o pipefail makes a pipeline fail if any command in it fails (not just the last one).
Extracting backup.tar.gz into a specific directory — which command?
A.unzip backup.tar.gz -d /target/dir
B.tar -xzf backup.tar.gz > /target/dir
C.tar -xzf backup.tar.gz -C /target/dir
D.gunzip backup.tar.gz and copy the files over
Answer: C
tar -xzf backup.tar.gz -C /target/dir. Mnemonic for the flags: x extract, z gzip, f file, C change directory. To compress, swap x for c, and add v if you want to see the file list.
A./tmp is root-only while /var/tmp is for everyone
B./var/tmp lives in RAM so it is faster than /tmp
C./tmp is usually cleared at reboot while /var/tmp persists
D.They are symlinks to each other so there is no difference
Answer: C
/tmp holds short-lived temp files, usually cleared on reboot (and on many distributions mounted as tmpfs, i.e. in RAM). /var/tmp survives reboots and is for temp files that need to live longer.
A.SIGKILL can be sent to child processes while SIGTERM cannot
B.SIGTERM can be caught for cleanup while SIGKILL cannot
C.SIGTERM needs root while SIGKILL does not
D.SIGTERM stops the process while SIGKILL only pauses it
Answer: B
SIGTERM (the default of kill) can be caught: the process runs a handler to close connections, flush data, then exit. SIGKILL (kill -9) is carried out by the kernel, cannot be caught and cannot be ignored — the process stops immediately.
df -h shows a full disk but du -sh / totals far less. Why?
A.du cannot count hidden files so its total is smaller
B.The two commands use different units so the numbers differ
C.A deleted file is still held open by a process's file descriptor
D.df includes the space reserved for root
Answer: C
Usually it's a deleted file still held open by a process: the filename is gone but the file descriptor remains, so the space isn't reclaimed. Find it with lsof | grep deleted, fix it by restarting that process.
A Node process is killed by the kernel with "Out of memory" in system logs. Cause?
A.The OOM killer picked the biggest memory consumer to kill
B.Node exceeded its heap limit and exited by itself
C.Too many child processes exceeded the process limit
D.The disk is full so it cannot write the temporary memory area
Answer: A
Kernel OOM killer: when RAM and swap are both exhausted, the kernel picks a process (usually the biggest consumer, by oom_score) to kill to keep the system alive. It is not the fault of the process that got selected.
A load average of 8.0 on a 4-core machine means what?
A.On average 8 processes are running or waiting: the machine is overloaded
B.The CPU is running at 800% of its maximum
C.Memory in use is 8× the machine's physical capacity
D.There are 8 processes running at the moment of measurement
Answer: A
On average 8 processes are running or waiting in the measured interval. Against 4 cores the machine is carrying double its capacity — everything slows down because things have to queue. The three numbers are the 1, 5 and 15 minute averages.
A.It occupies the CPU continuously while doing nothing
B.It is hung and responds to no signal
C.It lost its parent process so it now runs independently
D.It has exited but the parent has not read its exit status
Answer: D
The process has finished but its parent has not called wait() to read the exit status, so the kernel keeps an entry in the process table. It uses no CPU or memory — it only occupies a slot in the table.
A server reports "too many open files". How do you check and fix it?
A.Raise ulimit -n to its maximum and call it done
B.Check ulimit -n and the number of open fds, and look for the leak
C.Restart the server periodically to release file descriptors
D.Delete unnecessary files to reduce the number of open files
Answer: B
Check the limit with ulimit -n, check actual usage with lsof -p <pid> | wc -l. If the fd count grows steadily over time, that is a leak — connections or files not being closed. Raising the limit only buys time.
A systemd service dies and does not restart. What is missing?
A.Type=simple so systemd tracks the right main process
B.WantedBy=multi-user.target in the Install section
C.After=network.target to wait for the network
D.Restart=always with RestartSec in [Service]
Answer: D
Restart=always (or on-failure) in [Service], plus RestartSec=5 to wait between attempts. The default is Restart=no — systemd runs the service once, and once it dies, it stays dead.
A.A symlink points at a path while a hard link points at an inode
B.Symlinks are only for directories and hard links for files
C.A hard link consumes as much space again as the original file
D.A symlink is faster because it needs no inode resolution
Answer: A
A symlink stores a path (like a shortcut): if the original file is deleted or moved, the link breaks. A hard link is another name for the same inode: deleting the original name leaves the data intact because another name still points to it.
Application logs fill the disk. What is the durable fix?
A.Delete old log files with a nightly cron job
B.Add more disk to that server
C.Lower the log level to errors only
D.Configure logrotate by size with a retained copy count
Answer: D
logrotate: rotate files by size or time, compress old copies, keep N copies then delete. Crucially it sends a signal (or uses copytruncate) so the process reopens the file — deleting by hand does not reclaim the space.
A.It writes each stream to its own separate log file
B.It runs the command twice and merges the output
C.It sends stdout to stderr so it appears in the terminal
D.It sends stderr to wherever stdout currently points
Answer: D
Redirects stderr (2) to the same destination that stdout (1) currently points to — here out.log. That way both normal output and errors land in the same file, which matters for cron jobs because errors also need to be captured.
A script works by hand but not in cron. Most common cause?
A.Cron has a minimal environment: a different PATH and no profile loaded
B.Cron lacks permission to run the user's script
C.The time syntax in the crontab is malformed
D.Cron can only run bash scripts, not other languages
Answer: A
cron's environment is very minimal: short PATH, no .bashrc or .profile loaded, none of your environment variables. So node or pnpm that work in your terminal become "command not found" in cron.
free -h shows memory nearly full but apps run fine. Why?
A.The application uses virtual memory so it is not counted as real RAM
B.Most of it is page cache, which the kernel releases when needed
C.free counts the memory of processes that have already exited
D.The system is swapping so RAM looks full
Answer: B
Most of the "used" memory is page cache — the kernel keeps disk data in RAM for fast reads and releases it as soon as an app needs it. Look at the available column instead of free: free RAM is wasted RAM.
What is the core difference between a container and a virtual machine?
A.A container shares the host's kernel while a VM has its own
B.A container is faster because it is precompiled for each machine
C.Containers cannot be used with Microsoft Windows
D.A VM isolates better because it has its own internal firewall
Answer: A
Containers share the host kernel (isolated via namespaces and cgroups), while a VM runs its own kernel on top of a hypervisor. That's why containers start in a few hundred ms and use little RAM, but isolation is weaker than a VM's.
A host resolves a domain incorrectly. Where does it look first?
A.The browser's cache before asking the operating system
B.Check nsswitch.conf line hosts: for lookup order.
C.A public DNS such as 8.8.8.8 if it was configured earlier
D.The system's DNS servers first, with /etc/hosts only as a fallback
Answer: B
Check /etc/nsswitch.conf, the hosts: line, to see the resolution order. /etc/hosts may be consulted before DNS, but not always; the actual order is decided by configuration.
Deleting all .log files older than 30 days in a large tree. Safe approach?
A.ls -R | grep .log and delete from the printed list
B.find . -name "*.log" | xargs rm for brevity
C.rm -rf *.log in each subdirectory in turn
D.find . -name "*.log" -mtime +30 -delete, after a dry run
Answer: D
find . -name "*.log" -mtime +30 -delete. Always run it without -delete first to review the list. If you must pipe to another command, use -print0 | xargs -0 so filenames with spaces don't break it.
New files default to 644 instead of 664. What decides that?
A.The parent directory's permissions
B.The umask of the process creating the file
C.The mount options of the filesystem in use
D.The default group of the user running the command
Answer: B
umask — the mask of bits that get removed. With umask 022, a file created with requested mode 666 becomes 644, and a directory 777 becomes 755. Change it with umask 002 if you want group write.
You mounted a new disk and want it to persist across reboots. What do you do?
A.Add the mount command to root's .bashrc
B.Mount it by hand after every reboot
C.Add the mount command to the crontab with @reboot
D.Declare it in /etc/fstab, preferring the UUID over the device name
Answer: D
Add a line to /etc/fstab using the UUID (get it with blkid) rather than /dev/sdb1 — device order can change between boots, and mounting the wrong disk is a serious incident.
Should swap be enabled on a web application server?
A.Have a little as a buffer, but do not let the system rely on it
B.Yes, twice the RAM as the traditional rule says
C.Only if the machine has less than 4GB of physical memory
D.No, swap always slows the system so it should be off entirely
Answer: A
A little swap acts as a buffer so short memory spikes don't immediately lead to an OOM kill, with a low vm.swappiness (10–20) so the kernel prefers keeping data in RAM. But if the system swaps continuously, you need more RAM, not more swap.
Viewing a service log for the last 30 minutes — which journalctl command?
A.journalctl | grep <service> and hunt by timestamp
B.systemctl status <service> to see the whole log
C.journalctl -u <service> --since "30 min ago"
D.cat /var/log/syslog | tail -1000
Answer: C
journalctl -u <service> --since "30 min ago". Add -f to follow live, -p err to see only error level, -n 200 for the last 200 lines, --no-pager when piping to another command.
Server logs are 7 hours off from local time. How should you handle it?
A.Keep the server on UTC and convert at the display layer
B.Add 7 hours in your head when reading the logs
C.Configure the application to log in local time
D.Change the system timezone to Asia/Ho_Chi_Minh
Answer: A
Keep the system and logs in UTC, and convert to local time at the display layer (dashboard, UI). That way you don't have to convert when comparing logs across machines and regions, and there's no drift from daylight saving conventions.
Finding the top CPU consumer in real time — what do you read in top?
A.The %MEM column, since a memory-hungry process is CPU-hungry too
B.The %CPU column, remembering 100% means one full core
C.The TIME+ column because it shows current consumption
D.The load average line at the top of the screen
Answer: B
The %CPU column (press P to sort by it). Note 100% = one full core, so a multithreaded process on an 8-core machine can show up to 800%. Press 1 to see each core individually, M to sort by memory.
Server A cannot reach an API on server B. Sensible check order?
A.Check server B's application logs first
B.Restart both services and try again
C.Check the endpoint's TLS certificate
D.Name resolution, then reachability of the port, and only then the application layer
Answer: D
Bottom-up: (1) getent hosts B — is the name resolving correctly; (2) nc -vz B 443 or curl -v — does the port respond; (3) only if it responds, then check TLS, path, authentication, and application logs.
Letting a user run exactly one command as root. Correct approach?
A.Add the user to the sudo group for convenience
B.Tell the user the root account's password
C.Set the setuid root bit on that script file
D.Declare the specific command in sudoers through visudo
Answer: D
Declare a single line for exactly that command in sudoers via visudo, e.g. deploy ALL=(root) NOPASSWD: /usr/bin/systemctl restart myapp. Use visudo because it checks the syntax before saving — an editing mistake can lock you out of sudo entirely.
A TLS certificate error from curl — which flag diagnoses, which merely hides it?
A.-L to follow the redirect to the right address
B.-k to confirm the problem is the certificate and then keep it
C.--compressed to reduce the data while checking
D.-v to see the handshake detail; -k merely hides it
Answer: D
-v (or openssl s_client -connect host:443) shows the certificate chain, the names on the certificate, and its expiry date. -k merely bypasses the check — use it to confirm a hypothesis, not to keep in code.
Finding which files and connections a process has open — what do you use?
A.ps -p <pid> -o args to see the command line
B.lsof -p <pid> or looking at /proc/<pid>/fd
C.du -sh on the process's working directory
D.netstat -a to see every connection on the machine
Answer: B
lsof -p <pid> lists every file descriptor: regular files, sockets, pipes, even deleted-but-still-held files. The equivalent is reading /proc/<pid>/fd — useful when lsof isn't installed.
Variables set in .bashrc are missing for non-interactive SSH commands. Why?
A.Each kind of shell reads a different startup file
B.SSH does not allow passing environment variables
C.The variables only take effect after a reboot
D.Commands run over SSH always use the system's default shell
Answer: A
A Bash login shell reads /etc/profile, then the first existing file among ~/.bash_profile, ~/.bash_login, or ~/.profile; an interactive non-login shell reads ~/.bashrc; a non-interactive shell usually reads none of these unless BASH_ENV is set or they are explicitly sourced.
What advantages do systemd timers offer over cron?
A.They automatically run several copies of the same task in parallel
B.No schedule needs declaring
C.Centralized logs, declared dependencies, and catch-up runs
D.They can run with millisecond precision
Answer: C
Three main benefits: logs go into the common system log so they are searchable like any service; dependency declarations to run after the network or another service is ready; and catch-up runs when the machine was off at the scheduled time.
You started a long command and want to move it to the background in the same session. How?
A.Suspend it and then resume it in the background
B.Open a new session and rerun the command there
C.There is no way; it must be decided at the start
D.Kill the process and rerun it with an ampersand at the end
Answer: A
Press the suspend key combination to stop the process, then use the command to continue it in the background. To have it survive after the session closes, detach it from the shell with the disown command, or use a terminal multiplexer from the start.