Linux and shell scripting for developers – Server Side interview prep

261 interview-style multiple-choice questions on Linux and shell scripting for developers, organized by topic: concepts, scenarios, code to read and tradeoffs, each with a short explanation. Learn the 142 key terms with the flashcards first, then test yourself.

Take the practice test · Flashcards · All study tools

What it covers

  1. 19.1 Files, directories and the filesystem
  2. 19.2 Permissions, users and sudo
  3. 19.3 Processes, jobs and signals
  4. 19.4 systemd, services and logs
  5. 19.5 Pipes, redirection and text processing
  6. 19.6 Bash scripting
  7. 19.7 Networking and SSH
  8. 19.8 Performance and troubleshooting
  9. 19.9 Packages, scheduling and administration

Key terms

19.1 Files, directories and the filesystem

/var
Variable data
/proc
Kernel and process info
/dev/null
Discards writes
Dotfile
Hidden file
mkdir -p
Make parent dirs
du
Disk usage of files
Inode exhaustion
No space with free blocks
Deleted but open
Space not freed
mount
Attach a file system
tar
Archive files
rsync
Incremental copy
realpath
Absolute resolved path

19.2 Permissions, users and sudo

chmod
Change file permissions
chown
Change file owner and group
Symbolic link
File pointing to another path
/etc
Directory for system configuration
umask
Default permission mask
setuid
Run as file owner
Sticky bit
Only owner deletes
setgid dir
Inherit group
/etc/shadow
Password hashes
usermod -aG
Append a group
UID 0
Root
visudo
Safe sudoers edit
sudo tee
Write as root
ACL
Extra user permissions
Capabilities
Split root powers
SELinux/AppArmor
Mandatory access control

19.3 Processes, jobs and signals

Process ID
Number identifying a running process
SIGTERM
Polite termination signal
systemd
Init system and service manager
journalctl
Tool for reading systemd logs
PID
Process ID
SIGINT
Ctrl+C
SIGTSTP
Ctrl+Z
SIGHUP
Hangup or reload
nohup
Survive logout
tmux
Detachable sessions
nice
Lower CPU priority
Orphan
Reparented to PID 1
D state
Uninterruptible sleep
strace
Trace system calls
lsof
List open files
ulimit -n
Open file limit
fork/exec
Copy then replace

19.4 systemd, services and logs

Unit file sections
Unit, Service, Install
enable vs start
Boot vs now
daemon-reload
Reread unit files
Restart=on-failure
Auto restart on error
After vs Requires
Order vs dependency
Drop-in override
systemctl edit
Type=notify
Service signals ready
journalctl -b
Logs since boot
Persistent journal
/var/log/journal
systemd timer
Scheduled unit
mask
Block a unit
Socket activation
Start on connection
TimeoutStopSec
SIGKILL deadline
dmesg
Kernel ring buffer
logrotate
Rotate old logs

19.5 Pipes, redirection and text processing

Pipe
Connects one command's output to another's input
Redirection
Sending output to or input from files
grep
Searches text for patterns
awk
Field-based text processing language
2>&1
stderr to stdout
tee
Screen and file
cut
Pick fields
sort -k
Sort by field
uniq
Adjacent duplicates
grep -o
Only matching parts
awk END
Runs after input
jq
JSON processor
Here-document
Inline input
Process substitution
Output as a file
PIPESTATUS
Each pipe status
find -exec +
Batch arguments
zgrep
Grep gzip files

19.6 Bash scripting

Shebang
First line naming a script's interpreter
set -euo pipefail
Strict mode for Bash scripts
Exit status
Number a command returns; 0 means success
cron
Scheduler for recurring commands
$@
All arguments
[[ ]]
Bash test
-f / -d / -z
File, dir, empty
while read -r
Line-by-line loop
local
Function-scoped var
$(cmd)
Command substitution
$(( ))
Integer arithmetic
trap EXIT
Cleanup on exit
${var%suffix}
Strip suffix
source
Run in current shell
export
Pass to children
ShellCheck
Shell linter
nullglob
Empty glob

19.7 Networking and SSH

ip addr
Show interfaces
ip route
Routing table
/etc/hosts
Local name overrides
127.0.0.53
systemd-resolved stub
getent hosts
System resolver lookup
0.0.0.0
All interfaces
TIME_WAIT
Closed, waiting
nc -zv
Port check
Refused vs timeout
Closed vs dropped
tcpdump
Packet capture
nftables
Kernel firewall
ssh-copy-id
Install public key
~/.ssh modes
700 and 600
ssh -L
Local port forward
ProxyJump
Hop via bastion
fail2ban
Ban brute-force IPs
sysctl
Kernel parameters

19.8 Performance and troubleshooting

Load average
Running plus waiting tasks
available memory
Reclaimable included
Thrashing
Constant swapping
OOM killer
Kernel ends a process
oom_score_adj
OOM preference
iowait
CPU waiting on disk
Steal time
Hypervisor took CPU
sar
Historical stats
Flame graph
CPU by stack
USE method
Utilization, saturation, errors
truncate -s 0
Empty open file
RSS vs VSZ
Resident vs virtual
Page cache
File data in RAM
eBPF tools
Low-overhead tracing
swappiness
Swap vs cache bias

19.9 Packages, scheduling and administration

apt update vs upgrade
Lists vs packages
dpkg -S
Which package owns a file
unattended-upgrades
Automatic security updates
apt-mark hold
Pin a package
signed-by
Per-repo apt key
Cron fields
min hour dom mon dow
/etc/cron.d
System crontab with user
anacron
Catch-up for missed jobs
at
One-off scheduled job
nologin
No interactive shell
fstab UUID
Stable mount reference
lsblk
List block devices
lvextend -r
Grow LV and file system
/etc/os-release
Distro info
cloud-init
First-boot VM setup
Live patching
Kernel fixes without reboot

Sample practice questions

  1. What is the difference between a hard link and a symbolic link?

    1. They're identical; `ln` and `ln -s` create exactly the same kind of link
    2. Hard links work across file systems, while symlinks only work within one
    3. A symlink is another name for the inode; a hard link stores a path that can break
    4. A hard link is another name for the inode; a symlink stores a path that can break

    Answer: D. A hard link is another name for the inode; a symlink stores a path that can break Create a symlink with `ln -s target linkname`.

  2. What does `chmod 750 deploy.sh` set?

    1. Owner, group and others can all read and execute
    2. Owner: read only; group and others: read and write
    3. Owner: rwx; group: read and execute; others: nothing
    4. Owner, group and others can all read, write and execute

    Answer: C. Owner: rwx; group: read and execute; others: nothing Each digit adds read (4), write (2) and execute (1).

  3. Which command shows running processes with live CPU and memory usage?

    1. `top` or `htop`
    2. `ls -la /proc`
    3. `pwd -P`
    4. `cat /etc/passwd`

    Answer: A. `top` or `htop` `ps aux` prints a one-time snapshot.

  4. What does `systemctl restart myapp` do on a systemd-based system?

    1. Restarts only the network for `myapp`
    2. Stops and starts the `myapp` service unit
    3. Reinstalls the `myapp` package from scratch
    4. Reboots the whole server, including `myapp`

    Answer: B. Stops and starts the `myapp` service unit `systemctl enable` makes a unit start at boot.

  5. What does the pipe `|` do?

    1. Writes the command's output into a named file
    2. Feeds one command's stdout into the next one's stdin
    3. Runs two commands at the same time, unconnected
    4. Runs the second command only if the first fails

    Answer: B. Feeds one command's stdout into the next one's stdin `ps aux | grep nginx` filters the process list.

  6. What does `set -euo pipefail` at the top of a Bash script do?

    1. Suppresses every error message the script would otherwise print
    2. Turns on verbose debug output for every command, and nothing else
    3. Exits on errors and unset variables, and fails on any pipeline failure
    4. Makes the script run faster by skipping some error checks

    Answer: C. Exits on errors and unset variables, and fails on any pipeline failure It catches many silent failures in scripts.

  7. Which command shows which process is listening on port 8080?

    1. `chmod 8080 /proc/net`
    2. `ss -ltnp` or `lsof -i :8080`
    3. `df -h :8080`
    4. `ping localhost:8080`

    Answer: B. `ss -ltnp` or `lsof -i :8080` `-l` listening, `-t` TCP, `-n` numeric, `-p` process.

  8. A server is slow. Which commands give a quick first look?

    1. `reboot` right away, then see whether it's still slow
    2. `rm -rf /tmp/*` to free up space, then check again
    3. `chmod -R 777 /` to rule out permission problems
    4. `uptime`, `top`, `df -h`, `free -h` and recent logs

    Answer: D. `uptime`, `top`, `df -h`, `free -h` and recent logs Check before changing anything.

  9. A script works when you run it but fails in cron. What's a common cause?

    1. Cron runs every scheduled script twice in a row
    2. Cron's minimal environment and PATH lack what your shell had
    3. Cron can't run Bash scripts, only plain `sh` scripts
    4. Cron ignores exit codes, so failures stop the job

    Answer: B. Cron's minimal environment and PATH lack what your shell had Use full paths and set needed variables in the script.

  10. Where do system-wide configuration files conventionally live on Linux?

    1. `/bin`
    2. `/etc`
    3. `/home`
    4. `/tmp`

    Answer: B. `/etc` Logs usually live under `/var/log`.

Practice all 261 questions

More Server Side