Interview Q&A / Linux & Shell
Linux & Shell interview questions
Permissions, processes, pipes and the commands you are expected to know cold.
Prefer rapid revision? Practise Linux & Shell short interview answers →
- How do you check disk space and memory usage on a Linux server?
Use df -h to see free space on each mounted file system, du -sh to see how much space a folder takes, and free -h to see RAM and swap. In free, look at the "available" column, not "free", because Linux uses spare RAM as disk cache and gives it back when programs need it.
IntermediateIn-depth3 min read - How do you read the output of systemctl status?
The header shows Loaded (unit file path and whether it is enabled) and Active (running, inactive or failed, with how long). Below come the main PID, memory and CPU use, the process tree and the last log lines, which usually reveal why a service failed.
BeginnerQuick answer1 min read - How do you check whether a remote port is reachable from a Linux machine?
Use nc -zv host port for a quick TCP check, or curl -v telnet://host:port, or bash's /dev/tcp. A refused connection means nothing listens there; a timeout usually means a firewall or routing problem. ping only tests ICMP, not ports.
IntermediateQuick answer1 min read