46.3 Linux on EC2 Interview Questions
Amazon Linux habit: sudo yum, sudo service. Permissions, users, logs, processes, SSH keys – Blue daily bread. Dhyan rakho.
Q21. How do you install and start Nginx on Amazon Linux in this course style?
I use sudo yum install nginx -y, then sudo service nginx start, and check with sudo service nginx status. For boot I may use sudo systemctl enable nginx. I stay consistent with yum on Amazon Linux examples in this course rather than switching package managers mid-notes.
Q22. Why is chmod 400 used on an SSH private key?
The SSH client refuses keys that are group- or world-readable. chmod 400 key.pem (or 600) keeps the key private to my user. I never email the .pem or paste it into Slack. On the server I disable password authentication when keys work.
Q23. How do you find failed SSH logins on Amazon Linux?
I check /var/log/secure with commands such as sudo grep -i failed /var/log/secure | tail. Spikes mean brute force. Controls: key-only SSH, security group allow-list, fail2ban, and no root password login.
Q24. What is wrong with chmod 777 /var/www/html?
World-writable web root lets any local user drop or change site files, which often becomes defacement or webshell drop after a foothold. Correct ownership, 755/644 patterns, and no write for the web user except upload dirs that are carefully jailed.
Q25. How do you list listening ports on Linux?
I use ss -tulnp (or netstat where available) and compare to a baseline. Unexpected listeners are investigation triggers. On Sahyadri’s lab EC2 I expect sshd and the web service, not a random reverse shell port.
Q26. Explain users, groups, and sudo at interview level.
Each person should have a named account. Groups collect privileges. sudo grants timed admin for specific commands. I avoid shared root SSH. For Amir the developer I grant only what he needs, not full NOPASSWD ALL without review.
Q27. How do you check a service and restart it safely?
sudo service httpd status, then after config test (sudo apachectl configtest or sudo nginx -t) I run sudo service httpd reload or restart. Blind restart without config test can take production down.
Q28. What Linux process commands do you use daily?
ps aux, top or htop, kill only when I understand the process, and journalctl or log files for service noise. In IR I preserve evidence before killing when policy says so.
Q29. How do you secure SSH on a public EC2 instance?
Key-based auth, disable password auth, disable root login, allow port 22 only from my IP in the security group, keep packages updated with sudo yum update, and consider fail2ban. Optional non-default port is defence-in-depth, not a secret.
Q30. What is the difference between updating packages and patching a web app?
sudo yum update patches OS packages. Application code, WordPress plugins, or custom PHP need their own update path. Equifax-style lessons remind us that internet-facing app components need tracking too.
| Red team (attacker) does | Blue team (defender) detects / stops |
|---|---|
| Brutes SSH on open port 22 | Key-only SSH; fail2ban; SG allow-list; no password auth |
| Hunts world-writable web dirs after foothold | Correct ownership; no 777; file integrity checks |
Ravindra Bagale's Tip
Students systemctl start lihun Amazon Linux notes confuse kartat. Hya book madhe service control = sudo service. Boot enable = sudo systemctl enable OK. Interview madhe pan techsangati bol. He lakshat theva.
Lab
On OWN Free Tier Amazon Linux: sudo yum install httpd -y, sudo service httpd start, open SG 80 from your IP only, browse Elastic IP, then sudo service httpd stop. Six command lines + screenshot for portfolio.