Linux Troubleshooting Interview Questions on AWS EC2 Servers: SSH, Boot, Disk, CPU, Memory and Network (50 Questions)
This page has 50 Linux troubleshooting interview questions with full answers, all set on AWS EC2 servers. Interviewers love these questions, because they show how you think when something is broken and users are waiting.
1. An everyday example: a doctor in the emergency room
Why do interviewers ask troubleshooting questions?
Anyone can follow a setup guide. Real value is shown when the server will not boot, the disk is full at 2 a.m., or the site is slow for no clear reason. A calm, ordered method is what separates a senior engineer from a junior one.
Think of a doctor in an emergency room. First they check the basics: breathing, pulse, blood pressure. Then they run targeted tests. Then they treat, and later they find the root cause so it does not happen again. For a Linux server, the basics are: can I reach it, is it up, CPU, memory, disk, network and logs.
How to answer these questions
- Start with the impact and the quickest safe check.
- Say the exact command and what output you expect.
- Fix the symptom first if users are affected, then find the root cause, then prevent it.
2. Fresher level questions
Start here if you are a fresher or have less than two years of experience. Try to answer each question aloud first. Then open it and compare.
Q1. SSH to an EC2 instance says "Connection timed out". What does that tell you? Fresher
A timeout means your connection never got a reply. The problem is the network path, not your key.
Check in this order:
- Is the instance running and has it passed status checks?
- Are you using the right IP (the public IP may have changed after a stop and start)?
- Does the security group allow TCP 22 from your current public IP?
- Is the instance in a public subnet with a route to an internet gateway?
- Does the network ACL allow port 22 in and ephemeral ports out?
- Is a company firewall blocking outbound port 22 from your laptop?
Q2. SSH says "Permission denied (publickey)". What are the common causes on EC2? Fresher
The network is fine: the server answered, but rejected your key.
Common causes:
- Wrong user name, for example ubuntu instead of ec2-user.
- Wrong private key file for this instance's key pair.
- The key in authorized_keys was changed or removed.
- Wrong permissions on ~/.ssh or authorized_keys on the server, so sshd ignores it.
Debug with verbose output:
ssh -v -i shop-key.pem ec2-user@203.0.113.25 2>&1 | grep -E "Offering|denied"Output:
debug1: Offering public key: shop-key.pem RSA SHA256:Qm9...
ec2-user@203.0.113.25: Permission denied (publickey).The key was offered and refused, so check the user name and the key on the server.
Q3. Why does SSH refuse to use your .pem file with "UNPROTECTED PRIVATE KEY FILE"? Fresher
SSH does not trust a private key that other users on your computer can read.
ls -l shop-key.pemOutput:
-rw-r--r-- 1 ravi ravi 1675 Nov 20 10:02 shop-key.pemEveryone can read the file (r for group and others), so SSH refuses it.
Fix: chmod 400 shop-key.pem, so only you can read it.
On Windows, fix the file's security settings so only your user has access, or keep the key inside WSL with Linux permissions.
Q4. SSH warns "REMOTE HOST IDENTIFICATION HAS CHANGED" when you connect to an EC2 IP address. Why? Fresher
Your computer remembers the host key of every server it connected to, in ~/.ssh/known_hosts.
In the cloud, public IP addresses are reused. Yesterday's instance at 203.0.113.25 was terminated, and today a new instance with a new host key has the same IP. SSH sees a different key for the same address and warns you, because this can also mean a man-in-the-middle attack.
If you are sure the instance is new and yours, remove the old entry:
ssh-keygen -R 203.0.113.25Output:
# Host 203.0.113.25 found: line 14
/home/ravi/.ssh/known_hosts updated.The old key was removed. Better: verify the new host key from the console output, and use DNS names or Session Manager instead of raw IPs.
Q5. How do you see what a broken EC2 instance printed during boot? Fresher
You can read its console output and take a screenshot without logging in.
aws ec2 get-console-output --instance-id i-0a1b2c3d4e5f60001 --latest --output text | tail -3Output:
[FAILED] Failed to mount /data.
[DEPEND] Dependency failed for Local File Systems.
You are in emergency mode. After logging in, type "journalctl -xb" to view system logsThe boot stopped because /data could not be mounted. An fstab entry without nofail is the likely cause.
The console screenshot (Get instance screenshot in the console) helps when the screen shows a kernel panic or a GRUB menu.
Q6. The root disk of an EC2 instance is 100% full. What do you check first? Fresher
- Confirm which file system is full:
df -h. - Find the biggest folders on that file system only:
sudo du -xh / --max-depth=2 2>/dev/null | sort -h | tail. - Common culprits on servers: /var/log (big or unrotated logs), /var/lib/docker (images and containers), /tmp, old application releases, core dumps and package caches.
- Free space safely: rotate or compress logs, prune unused Docker images, clean package caches.
Then fix the cause: logrotate settings, log retention, a CloudWatch disk alarm and, if needed, a larger volume.
Q7. An EC2 instance is stuck in the "stopping" state for a long time. What can you do? Fresher
Usually the operating system is slow to shut down, for example a service that ignores the stop signal or a hung file system.
- Wait a few minutes first. A normal stop can take some time.
- Then stop it again with the force option:
aws ec2 stop-instances --instance-ids i-0a1b2c3d4e5f60001 --forceOutput:
"CurrentState": { "Name": "stopping" }EC2 forces the stop without waiting for a clean OS shutdown. Like pulling the power cable, unsaved data in memory may be lost, so check file systems after the next start.
If it still does not stop, it may be a problem with the underlying host. Contact AWS Support.
Q8. What does "No space left on device" mean when df shows free space? Fresher
The file system may have run out of inodes. Each file uses one inode, so millions of tiny files can use all inodes while bytes are still free.
df -i /Output:
Filesystem Inodes IUsed IFree IUse% Mounted on
/dev/nvme0n1p1 10M 10M 0 100% /No free inodes. Find folders with huge file counts, for example old session files or a mail queue, and clean them.
XFS (default on Amazon Linux) allocates inodes dynamically, so this happens more often on ext4 file systems, such as on Ubuntu.
Q9. What does load average mean, and is a load of 8 bad? Fresher
Load average is the average number of processes running or waiting to run (including waiting for disk I/O) over 1, 5 and 15 minutes.
uptimeOutput:
10:15:02 up 12 days, 3:44, 1 user, load average: 8.12, 7.95, 6.40It depends on the number of vCPUs. On an instance with 8 vCPUs, a load of 8 means the CPUs are fully busy. On 2 vCPUs, it means many tasks are waiting.
Check nproc for the vCPU count, then top to see whether the load is CPU (high us/sy) or I/O wait (high wa).
Q10. How do you check whether the Linux kernel killed a process because of low memory? Fresher
The out-of-memory (OOM) killer writes to the kernel log.
sudo dmesg -T | grep -i "killed process"Output:
[Fri Nov 20 09:41:12 2026] Out of memory: Killed process 2314 (java) total-vm:6012340kB, anon-rss:3801224kBJava was killed by the kernel at 09:41 because the server ran out of memory.
Also check journalctl -k and the application restarts. Fix by right-sizing memory, fixing leaks, limiting heap sizes, or choosing a larger instance.
Q11. How do you see why a systemd service failed to start? Fresher
sudo systemctl status shop-api --no-pagerOutput:
Active: failed (Result: exit-code) since Fri 2026-11-20 10:05:11 IST
Process: 4120 ExecStart=/usr/bin/node /opt/shop/server.js (code=exited, status=1/FAILURE)sudo journalctl -u shop-api -n 5 --no-pagerOutput:
Error: Cannot find module 'express'The service started and exited with an error because a dependency is missing. Install dependencies in /opt/shop and start it again.
Always read the journal for the unit. The status line alone rarely shows the real reason.
Q12. An app works when started by hand but not after the instance reboots. Why? Fresher
The service was started manually and never enabled to start on boot.
systemctl is-enabled shop-apiOutput:
disabledFix: sudo systemctl enable --now shop-api.
Other reasons:
- It starts before the network or a mounted disk is ready. Add After=network-online.target and the right RequiresMountsFor in the unit.
- It depends on environment variables that existed only in your shell. Put them in the unit file or an EnvironmentFile.
- Instance store data was lost on stop and start.
Q13. How do you check which process is using a port on the server? Fresher
sudo ss -tlnp | grep ":8080"Output:
LISTEN 0 511 0.0.0.0:8080 0.0.0.0:* users:(("java",pid=2314,fd=45))Java (PID 2314) listens on port 8080 on all interfaces.
If the app reports "Address already in use", an old copy or another service is still holding the port. Stop it or change the port.
If the app listens on 127.0.0.1:8080 instead of 0.0.0.0:8080, a load balancer cannot reach it directly, because it accepts only local connections.
Q14. What is the EC2 serial console and when do you use it? Fresher
The EC2 serial console gives you a text console to the instance, like plugging a keyboard into a physical server. It works even when the network or SSH is broken.
Use it when:
- The instance is stuck in emergency mode because of fstab.
- A firewall rule inside the OS blocked SSH.
- Boot loader or kernel problems.
It must be allowed at the account level, works on Nitro-based instances, and you need an OS user with a password to log in. Access is controlled with IAM, so restrict it to admins.
Q15. How do you check whether a server can resolve DNS names inside a VPC? Fresher
cat /etc/resolv.conf | grep nameserverOutput:
nameserver 10.20.0.2dig +short shop-prod-db.abc123xyz.ap-south-1.rds.amazonaws.comOutput:
10.20.12.45The instance uses the VPC resolver (the VPC base address plus 2), and the RDS name resolves to a private IP.
If dig hangs, check that enableDnsSupport is on for the VPC, and that nobody replaced resolv.conf with an unreachable DNS server. 169.254.169.253 also reaches the VPC resolver.
Q16. How do you test whether a server can reach another service on a port? Fresher
nc -zv 10.20.12.45 5432Output:
Connection to 10.20.12.45 5432 port [tcp/postgresql] succeeded!The TCP connection works, so routes, security groups and NACLs allow it.
- "timed out": something on the path drops packets (security group, NACL, route).
- "Connection refused": the host answered, but nothing listens on that port, or a local firewall rejected it.
For HTTP services, curl -v https://... also shows DNS, TLS and HTTP status in one command.
Q17. What should you do before troubleshooting a broken production EC2 instance? Fresher
- Check the impact: is the service down for users, or is one instance out of many broken?
- If the instance is behind a load balancer or Auto Scaling group, take it out of service (or let the group replace it) so users are not affected.
- Take an EBS snapshot if you might need the data or evidence.
- Tell the team in the incident channel what you are doing.
Then troubleshoot calmly. In cloud setups, the fastest fix for users is often to replace the instance, and debug the old one separately.
3. Mid level questions
These questions check how you use the service in real projects. Interviewers expect the why, the how and one real example.
Q18. How do you fix an instance that will not boot because of a bad /etc/fstab line, without the serial console? Mid level
Use a rescue instance:
- Stop the broken instance and detach its root volume.
- Attach it to a healthy rescue instance in the same AZ as a second disk.
- Mount it. For XFS, use
-o nouuidif both disks came from the same AMI and have the same UUID:
sudo mount -o nouuid /dev/nvme1n1p1 /mnt/rescue- Edit /mnt/rescue/etc/fstab: fix the line or add nofail.
- Unmount, detach, attach it back as the root device of the original instance, and start it.
Take a snapshot before you change anything.
Q19. Why can AWS CLI or SDK calls fail with "Signature expired" or "Request has expired" on a server? Mid level
AWS signs every request with a timestamp. If the server clock is off by more than a few minutes, AWS rejects the request.
chronyc tracking | grep "System time"Output:
System time : 412.512345 seconds slow of NTP timeThe clock is almost 7 minutes slow, so signed requests look too old.
Fix: make sure chrony runs and can reach the Amazon Time Sync Service (169.254.169.123), then let it correct the time (sudo chronyc makestep).
Common causes: chrony stopped, a custom NTP server that is unreachable, or a firewall rule inside the OS.
Q20. A t3 instance is slow and top shows high %st. What is happening? Mid level
%st (steal time) is CPU time the hypervisor did not give to your instance.
On burstable instances (t3, t4g), this usually means CPU credits ran out. The instance is limited to its baseline performance, for example 20% of a vCPU.
Check in CloudWatch: CPUCreditBalance falling to zero, and CPUUtilization flat at the baseline.
Fixes:
- Turn on unlimited mode (you pay for extra CPU used above baseline).
- Move to a larger burstable size or a fixed-performance type like m7g or m7i.
- Reduce CPU use: caching, fixing busy loops, moving batch work elsewhere.
Q21. Load average is high but CPU usage is low. What do you check? Mid level
This usually means processes are waiting for I/O, often disk.
vmstat 1 3Output:
procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu-----
r b swpd free buff cache si so bi bo in cs us sy id wa st
1 9 0 201344 10240 801232 0 0 8120 9450 910 1500 4 3 30 63 09 processes are blocked (b) and 63% of CPU time is I/O wait (wa). The disk is the bottleneck.
Next: iostat -xz 1 to find the busy device, then compare with EBS IOPS and throughput limits in CloudWatch. Also check for EFS or NFS mounts that are hanging.
Q22. How do you see if network packets are being dropped because of EC2 instance network limits? Mid level
The ENA driver has counters that show when the instance exceeded its network allowances.
ethtool -S ens5 | grep allowance_exceededOutput:
bw_in_allowance_exceeded: 0
bw_out_allowance_exceeded: 1532
pps_allowance_exceeded: 0
conntrack_allowance_exceeded: 0
linklocal_allowance_exceeded: 0outbound traffic was queued or dropped 1532 times because the instance exceeded its outbound bandwidth allowance.
Fix: use a larger or network-optimised instance type, spread load across more instances, or reduce traffic. linklocal_allowance_exceeded points to too many DNS, metadata or time requests.
Q23. An application reports intermittent DNS failures on a very busy EC2 instance. What could cause it? Mid level
The VPC resolver (and other link-local services, such as IMDS and Time Sync) has a per-network-interface limit of about 1024 packets per second.
A busy app that resolves the same names for every request can hit this limit, and some DNS queries are dropped.
Check: ethtool -S ens5 | grep linklocal_allowance_exceeded.
Fixes:
- Add a local DNS cache, such as systemd-resolved, dnsmasq or nscd, so repeated lookups do not leave the instance.
- Fix the application to reuse connections and cache DNS results for a sensible time.
Q24. What do many TIME_WAIT connections on a server mean, and when are they a problem? Mid level
TIME_WAIT is a normal TCP state after a connection closes. It keeps the port reserved briefly to catch late packets.
ss -s | grep -i timewaitOutput:
TCP: 30412 (estab 210, closed 30100, orphaned 0, timewait 30098)about 30,000 recently closed connections. This happens when an app opens a new connection for every request.
It becomes a problem when the client runs out of local ephemeral ports, and new connections fail.
Fix: use connection pooling and HTTP keep-alive, so connections are reused. Only tune kernel settings like the local port range after fixing the application pattern.
Q25. Nginx returns 413 Request Entity Too Large when users upload files. How do you fix it on EC2? Mid level
Nginx limits request body size with client_max_body_size, which is 1 MB by default.
Fix: raise it in the right server or location block, then test and reload:
sudo nginx -t && sudo systemctl reload nginxOutput:
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successfulThe new config is valid and loaded without dropping connections.
Also check the app framework's own upload limit, and any limit on the ALB, API Gateway or CloudFront in front. For large files, upload directly to S3 with presigned URLs.
Q26. How do you check if a TLS certificate on a server has expired or is wrong? Mid level
echo | openssl s_client -connect shop.example.com:443 -servername shop.example.com 2>/dev/null | openssl x509 -noout -subject -enddateOutput:
subject=CN = shop.example.com
notAfter=Nov 18 23:59:59 2026 GMTThe certificate for shop.example.com expired on 18 November 2026, so browsers show a security warning.
Fix: renew it (for example, Certbot on the server), or move TLS to an ALB or CloudFront with ACM, which renews automatically.
Also check the chain: a missing intermediate certificate causes errors on some clients even when the date is fine.
Q27. An app on Amazon Linux gets "Permission denied" reading a file even though Unix permissions look correct. What else can block it? Mid level
- SELinux in enforcing mode can block a process from reading files with the wrong label, for example Nginx serving files from /data/www.
sudo ausearch -m avc -ts recent | tail -1Output:
type=AVC msg=audit(...): avc: denied { read } for pid=1820 comm="nginx" name="index.html" scontext=system_u:system_r:httpd_t:s0 tcontext=unconfined_u:object_r:default_t:s0SELinux denied Nginx reading a file labelled default_t. Fix the label with semanage fcontext and restorecon, instead of turning SELinux off.
- Parent folder permissions: every directory in the path needs execute (x) permission for the user.
- ACLs or immutable attributes (lsattr).
Q28. A cron job works when run by hand but fails from cron. Why? Mid level
Cron runs jobs with a very small environment.
- PATH is short, so commands like aws or node may not be found. Use full paths or set PATH in the crontab.
- Environment variables from your login shell (like AWS_PROFILE) are missing.
- The working directory is the user's home, not the script folder.
- The script may need execute permission.
Capture output to find the error: */5 * * * * /opt/shop/bin/report.sh >> /var/log/shop/report.log 2>&1.
On EC2 fleets, prefer EventBridge Scheduler with Run Command or a container task, so the job does not depend on one server.
Q29. An EFS mount hangs and commands like ls freeze. What do you check? Mid level
- Network: the EFS mount target security group must allow TCP 2049 from the instance, and the instance's AZ should have a mount target.
- DNS: the file system DNS name must resolve in the VPC.
- Check
sudo grep -i efs /var/log/messagesand the amazon-efs-utils log under /var/log/amazon/efs/. - Performance: in burst mode, an exhausted burst credit balance makes EFS very slow. Elastic throughput mode avoids this.
- Mount options: use the recommended options (hard, timeo=600, retrans=2 with the mount helper) so clients recover instead of returning errors.
Use mount | grep efs to confirm the options in use.
Q30. dnf or apt says another process holds the package lock. What do you do? Mid level
Often, an automatic update is running, for example cloud-init on first boot, unattended-upgrades on Ubuntu, or an SSM patch job.
- Find it:
ps aux | grep -E "dnf|apt|unattended". - Wait for it to finish, especially on a new instance.
- Do not delete lock files while a package manager is running, or you can corrupt the package database.
In automation, wait for cloud-init to finish first (cloud-init status --wait) before installing packages.
Q31. Session Manager says the instance is not connected, but the instance is running. What do you check? Mid level
- The SSM Agent is installed and running.
- The instance profile has AmazonSSMManagedInstanceCore (or equivalent).
- Network: outbound HTTPS to the ssm, ssmmessages and ec2messages endpoints, through NAT or VPC interface endpoints with private DNS.
- IMDS works, because the agent gets credentials from it. A hop limit or IMDS disabled can break this.
- The clock is correct.
- If Session Manager uses KMS encryption or logging to S3 or CloudWatch, the role needs those permissions too.
The agent log at /var/log/amazon/ssm/ usually shows the exact error.
Q32. How do you capture network traffic on an EC2 instance to debug a connection problem? Mid level
sudo tcpdump -ni ens5 host 10.20.12.45 and port 5432 -c 4Output:
10:31:01.120 IP 10.20.1.15.51422 > 10.20.12.45.5432: Flags [S], seq 1001
10:31:02.121 IP 10.20.1.15.51422 > 10.20.12.45.5432: Flags [S], seq 1001The server sends SYN packets to the database but never gets a SYN-ACK. The traffic leaves the instance, so something outside it, such as the database security group or a NACL, is dropping it.
For traffic you cannot capture on the host, use VPC Flow Logs, or VPC Traffic Mirroring for full packets.
Q44. How do you find what changed on a server just before an incident? Mid level
Changes cause most incidents, so look for them first.
- Packages:
rpm -qa --last | head(Amazon Linux) or /var/log/dpkg.log (Ubuntu) shows recently installed or updated packages. - Services and logs:
journalctl --since "2 hours ago"for restarts and errors. - Config files: compare with Git or your configuration management, and check file times with
find /etc -mmin -120. - AWS side: CloudTrail for API changes (security groups, instance type, IAM role), Systems Manager inventory and Run Command history, and deployment history in your pipeline.
Then ask: what changed, who changed it, and can we roll it back?
Q45. How do you find which part of a slow HTTP request takes the time, using curl? Mid level
curl can print timing for each phase.
curl -s -o /dev/null -w "dns=%{time_namelookup} connect=%{time_connect} tls=%{time_appconnect} first_byte=%{time_starttransfer} total=%{time_total}\n" https://shop.example.com/api/ordersOutput:
dns=0.004 connect=0.031 tls=0.092 first_byte=2.874 total=2.881DNS, TCP and TLS are fast, but the server takes about 2.8 seconds to send the first byte. The delay is inside the application or its database, not the network.
Run the same command from inside the VPC to compare, and then look at application traces or slow query logs.
Q46. Network settings added with the ip command disappear after a reboot. Why, and how do you make them permanent? Mid level
Commands like ip addr add or ip route add change only the running kernel. They are not saved.
To make them permanent, use the distribution's network configuration:
- Amazon Linux 2023: systemd-networkd files (with amazon-ec2-net-utils managing EC2 interfaces).
- Ubuntu: a netplan YAML file, then
sudo netplan apply. - RHEL-like systems: NetworkManager with nmcli.
On EC2, most addressing comes from DHCP and metadata, so first ask whether the change belongs in AWS instead, for example a secondary private IP on the ENI or a VPC route table entry.
4. Senior level and scenario questions
These questions check design thinking and troubleshooting. Think aloud. Say what you check first, what you change, and how you prevent it next time.
Q33. An EC2 instance fails its instance status check right after a kernel update. How do you recover? Senior
- Read the console output and screenshot: is there a kernel panic or "unable to mount root fs"?
- Use the serial console to choose the previous kernel in the GRUB menu, if available.
- Or use a rescue instance: attach the root volume, chroot into it, and set the previous kernel as default (grubby --set-default on Amazon Linux), or rebuild the initramfs with the right drivers (NVMe, ENA).
- Boot, confirm, and pin the kernel until the issue is understood.
Prevention: test kernel updates on staging, keep AMI-based rollbacks, and use instance refresh to roll out gradually.
Q34. A production server became slow and SSH takes 30 seconds to log in. Walk through your approach. Senior
Slow SSH login itself is a clue.
- DNS: sshd may try a reverse DNS lookup of your IP. If DNS is broken, login waits for a timeout (UseDNS no avoids this).
- Resource starvation: high load, memory pressure and swapping make everything slow. Check CloudWatch CPU, memory (agent), and disk queue before logging in.
- Full disk: login scripts or logging may hang.
Once in: uptime, free -m, vmstat 1, df -h, dmesg -T | tail, top.
Fix the immediate cause (kill a runaway process, free disk), then find why it happened with metrics and logs.
Q35. A Java service on EC2 is killed every few days by the OOM killer, but heap usage looks fine. What do you check? Senior
The JVM uses memory outside the heap: metaspace, thread stacks, direct buffers, code cache and native libraries. Other processes on the server also use memory.
Steps:
- Compare the process RSS (
ps -o rss) with heap size over time. - Turn on Native Memory Tracking in a test environment to see non-heap growth.
- Check thread count growth (each thread has a stack).
- Check other processes, such as log shippers or cron jobs that spike memory.
Fixes: set heap and direct memory limits so the total fits with headroom, fix leaks, add a memory alarm with the CloudWatch agent, and run at least two instances so one restart does not cause an outage.
Q36. After a restore from snapshot, a database on EC2 is very slow for the first hour. Why? Senior
Volumes created from EBS snapshots load their blocks lazily from S3. The first read of each block is much slower than later reads.
So a database that reads many blocks right after the restore feels slow until most blocks are loaded.
Fixes:
- Initialise the volume before use by reading every block, for example with fio or dd.
- Use Fast Snapshot Restore on the snapshot for the AZ, so volumes are fully initialised at creation (extra cost).
- AWS also offers provisioned volume initialisation rates for faster loading, so check the current options.
Plan this into your RTO for disaster recovery.
Q37. An Auto Scaling group keeps replacing instances because they fail ELB health checks, but the app works when you test it by hand. How do you debug? Senior
- Look at the target group health reason: timeout, wrong status code, or connection refused.
- Test the exact health check path and port from inside the VPC, for example
curl -i http://10.20.1.15:8080/healthfrom another instance. - Check timing: the app may need two minutes to start, but the health check grace period is 60 seconds, so it is killed before it is ready.
- Check the security group allows the ALB to reach the health check port.
- Check whether the health endpoint depends on a slow external service.
Temporarily suspend the ReplaceUnhealthy process to keep an instance for debugging.
Q38. A server can reach the internet by IP address but not by name. How do you fix it? Senior
This is a DNS problem.
- Check /etc/resolv.conf: has someone set a nameserver that is not reachable from the VPC, or has a config tool overwritten it?
- Test the VPC resolver directly:
dig @169.254.169.253 example.com. - If that works, fix the resolver configuration (for example in NetworkManager or systemd-resolved settings), not by editing resolv.conf by hand, because it may be regenerated.
- If it fails, check VPC DNS settings, Route 53 Resolver DNS Firewall rules that may block domains, and outbound rules to on-premises DNS.
Q39. You must investigate a hacked web server on EC2 while keeping the website online. What do you do? Senior
- Scale out a clean replacement from a trusted AMI and put it behind the load balancer.
- Remove the suspicious instance from the target group, isolate it with a restricted security group, and snapshot its volumes.
- Rotate any credentials that were on the server or available through its IAM role, and check CloudTrail for unusual API calls using that role.
- Analyse the snapshots on a separate forensic instance: web shells, new users, cron jobs, modified binaries.
- Patch the vulnerability that allowed the attack before the new servers become the next target.
Q40. A Linux server's file system turned read-only suddenly. What happened and what do you do? Senior
The kernel remounts a file system read-only when it detects errors, to prevent more damage.
- Check the kernel log:
dmesg -T | grep -iE "error|remount|I/O". - Causes: I/O errors on the volume, a file system corruption, or an impaired EBS volume (check the EBS status check and volume events).
- Do not keep writing. Snapshot the volume first.
- Repair on a rescue instance with the right tool (xfs_repair for XFS, fsck for ext4) while unmounted.
- If the volume is impaired, restore from snapshot to a new volume.
Then check application data consistency.
Q41. How do you troubleshoot an application that is slow only on one of several identical EC2 instances? Senior
Compare the bad instance with a good one.
- Instance details: same instance type, AMI, AZ? Is it a noisy t-class with no CPU credits?
- Metrics: CPU steal, memory, disk latency, network allowance counters.
- Configuration drift: different app version, config file, kernel, or a stuck background job.
- Dependencies: is it in another AZ, far from the database, or using a different cache node?
If you cannot find the cause quickly, remove it from service and replace it, then keep investigating with a snapshot.
Q42. A batch job on EC2 fails every night at 01:00 with "Too many open files". How do you fix it properly? Senior
- Confirm the limit of the process:
cat /proc/<pid>/limits. - Check how many files it really opens:
ls /proc/<pid>/fd | wc -lwhile the job runs. - If the count grows without limit, the job is leaking file handles or sockets. Fix the code to close them.
- If the need is real, raise LimitNOFILE in the systemd unit or the cron wrapper, and check the system-wide fs.file-max.
- Add monitoring of open file counts for the job.
Raising limits without checking for a leak only delays the failure.
Q43. How do you make troubleshooting faster for the next incident on your EC2 fleet? Senior
- Central logs and metrics: CloudWatch agent on every instance, with memory, disk and application logs.
- Dashboards per service with the key signals: errors, latency, saturation.
- Runbooks as Systems Manager Automation documents for common fixes, such as clearing disk or restarting a service.
- Session Manager with logging, so access is quick but audited.
- Serial console access prepared for admins.
- Immutable servers, so "replace the instance" is always a safe first step.
- Post-incident reviews that add an alarm or automation for each new failure type.
Q47. You clean the disk, but it fills up again within a few hours. How do you find what is writing? Senior
- Watch growth over time: run
du -xh --max-depth=2on the main folders every few minutes and compare. - Find processes doing heavy writes:
sudo iotop -oorpidstat -d 1. - Check open files of suspicious processes:
sudo lsof -p <pid> | grep -E "REG.*w". - Typical causes: debug logging left on after an incident, a retry loop logging the same error thousands of times per second, a stuck queue spooling to disk, or core dumps from a crashing service.
Fix the writer, then add log rotation limits, a disk alarm and, if needed, move logs off the instance.
Q48. CPU is at 100% because of a process nobody recognises. What do you do? Senior
Treat it as a possible security incident, for example a crypto-mining program.
- Do not just kill it and move on.
- Note the process details:
ps -fp <pid>, its binary path (ls -l /proc/<pid>/exe), network connections (ss -tnp) and parent process. - Check how it started: cron entries, systemd units, user accounts and recent logins.
- Isolate the instance, snapshot its volumes, and follow your incident response process.
- Check GuardDuty findings, which often detect mining or command-and-control traffic.
- Replace the server from a clean AMI, and fix the entry point, such as an exposed admin panel or leaked key.
Q49. After moving to a bigger instance type, the application became slower. How can that happen? Senior
Bigger is not always faster for every workload.
- CPU type changed: different processor family or architecture with different single-thread speed.
- Burstable to fixed or the reverse: the old t-class may have had credits for bursts.
- EBS bandwidth or network limits differ by type. Check the instance's documented EBS and network bandwidth.
- The AMI may lack drivers or settings for the new type (ENA, NVMe).
- More vCPUs can change thread pool sizes, JVM settings or database settings that were tuned for the old size.
- Placement: the new instance may be in another AZ, farther from the database.
Measure before and after with the same load test.
Q50. An application on EC2 suddenly fails with "Unable to locate credentials". What do you check? Senior
The SDK could not get credentials from any source. On EC2, they normally come from the instance profile through IMDS.
- Is an IAM role still attached to the instance? Someone may have removed or replaced it.
- Can the process reach IMDS? Check that IMDS is enabled, that IMDSv2 calls work, and that the hop limit allows containers if the app runs in Docker.
- Is a firewall rule inside the OS blocking 169.254.169.254?
- Is the SDK too old to support IMDSv2 when tokens are required?
- Did someone set empty AWS_* environment variables that override the default chain?
Test from the server with aws sts get-caller-identity.
5. Frequently asked questions
What is the first command you run on a slow Linux server?
Many engineers start with uptime, top (or htop), free -m, df -h and dmesg -T | tail. Together they give load, CPU, memory, disk and kernel errors in about a minute.
How is troubleshooting on EC2 different from a physical server?
You cannot touch the hardware, but you get extra tools: status checks, the serial console, console screenshots, EBS snapshots, rescue instances and CloudWatch metrics from outside the OS. And often the best fix is to replace the instance.
How do I practise safely?
Break a test instance on purpose: fill the disk, add a bad fstab line, stop sshd, or block a port. Then fix it using only the tools in this page.
6. Quick revision
- Timeout means network. "Permission denied" means authentication.
- Instance status check failure means a problem inside the OS. System status check failure means an AWS host problem.
- Disk full but du disagrees: look for deleted files still open with lsof +L1.
- High %st (steal) on a t instance often means CPU credits ran out.
- Clock skew breaks AWS API calls with signature or expired request errors.
7. Related chapters
- Linux Complete Interview Pack 1: 300 Linux Interview Questions and Answers for Beginner, Mid and Senior Level
- Linux Troubleshooting Playbook: 20 Real Production Cases with Commands and Fixes
- Linux Boot Process Step by Step: BIOS/UEFI, GRUB, Kernel, initramfs and systemd
- What Is Amazon EC2 and How Does It Work
- AWS EC2, EBS, Auto Scaling and Load Balancer Interview Questions and Answers (50 Questions)
This page is one part of a 1000-question AWS interview set. Open the full list here: All 1000 AWS interview questions.