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
- 19.1 Files, directories and the filesystem
- 19.2 Permissions, users and sudo
- 19.3 Processes, jobs and signals
- 19.4 systemd, services and logs
- 19.5 Pipes, redirection and text processing
- 19.6 Bash scripting
- 19.7 Networking and SSH
- 19.8 Performance and troubleshooting
- 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
What is the difference between a hard link and a symbolic link?
- They're identical; `ln` and `ln -s` create exactly the same kind of link
- Hard links work across file systems, while symlinks only work within one
- A symlink is another name for the inode; a hard link stores a path that can break
- 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`.
What does `chmod 750 deploy.sh` set?
- Owner, group and others can all read and execute
- Owner: read only; group and others: read and write
- Owner: rwx; group: read and execute; others: nothing
- 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).
Which command shows running processes with live CPU and memory usage?
- `top` or `htop`
- `ls -la /proc`
- `pwd -P`
- `cat /etc/passwd`
Answer: A. `top` or `htop` `ps aux` prints a one-time snapshot.
What does `systemctl restart myapp` do on a systemd-based system?
- Restarts only the network for `myapp`
- Stops and starts the `myapp` service unit
- Reinstalls the `myapp` package from scratch
- Reboots the whole server, including `myapp`
Answer: B. Stops and starts the `myapp` service unit `systemctl enable` makes a unit start at boot.
What does the pipe `|` do?
- Writes the command's output into a named file
- Feeds one command's stdout into the next one's stdin
- Runs two commands at the same time, unconnected
- 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.
What does `set -euo pipefail` at the top of a Bash script do?
- Suppresses every error message the script would otherwise print
- Turns on verbose debug output for every command, and nothing else
- Exits on errors and unset variables, and fails on any pipeline failure
- 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.
Which command shows which process is listening on port 8080?
- `chmod 8080 /proc/net`
- `ss -ltnp` or `lsof -i :8080`
- `df -h :8080`
- `ping localhost:8080`
Answer: B. `ss -ltnp` or `lsof -i :8080` `-l` listening, `-t` TCP, `-n` numeric, `-p` process.
A server is slow. Which commands give a quick first look?
- `reboot` right away, then see whether it's still slow
- `rm -rf /tmp/*` to free up space, then check again
- `chmod -R 777 /` to rule out permission problems
- `uptime`, `top`, `df -h`, `free -h` and recent logs
Answer: D. `uptime`, `top`, `df -h`, `free -h` and recent logs Check before changing anything.
A script works when you run it but fails in cron. What's a common cause?
- Cron runs every scheduled script twice in a row
- Cron's minimal environment and PATH lack what your shell had
- Cron can't run Bash scripts, only plain `sh` scripts
- 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.
Where do system-wide configuration files conventionally live on Linux?
- `/bin`
- `/etc`
- `/home`
- `/tmp`
Answer: B. `/etc` Logs usually live under `/var/log`.
More Server Side
- HTTP fundamentals
- REST API design
- GraphQL
- gRPC & real-time APIs
- OAuth 2.0, OIDC & JWT
- Sessions, cookies & web app security
- C# & .NET
- Java & Spring Boot
- Node.js & Express
- Python, Django & FastAPI
- Go (Golang)
- Concurrency & multithreading
- OOP & SOLID
- Design patterns
- Dependency injection
- Logging & observability
- Data structures
- Algorithms & Big-O