Real-time troubleshooting in Linux:-
🧑💻👨💻Let's shoot the answers in interview below:
Question 1: A user reports that their cron jobs are not running.How would you troubleshoot this issue?
Answer: Ensure the cron service is running: systemctl status cron.
Verify the cron job syntax: List the cron jobs for the user: crontab -l -u username
Check cron logs: Cron jobs are logged in /var/log/ syslog or /var/log/cron
Question 2: How do you monitor CPU and memory usage in real time?
Answer: top: Provides a real-time view of CPU and memory usage
htop: A more user-friendly version of top (if installed)
Question 3:How would you reset a forgotten root password?
Answer: Boot into single-user mode. Reboot the system. When GRUB appears, press e to edit the boot options.
Find the line that starts with linux, append single or init=/bin/bash at the end, and boot.
Remount the root filesystem: In single-user mode, the root filesystem might be mounted as read-only.
Remount it in read-write mode:
mount -o remount, rw / Change the root password: Use the passwd command to change the root password: passwd && reboot
Question 4: How would you extend a logical volume and resize the filesystem?
Answer: Ensure you have free space in the volume
group: vgdisplay
Extend the logical volume: Ivextend -L +10G/dev/ mapper/vg_name-lv_name
Resize the filesystem: resize2fs/dev/mapper/ vg_name-lv_name
For xfs: xfs_growfs/mount/point
Question 5: How would you recover a system where the /etc/ fstab file has been misconfigured, preventing the system from booting?
Answer: Boot into Rescue Mode or Single User Mode: Reboot the system and access the bootloader (GRUB).
Edit the boot options by adding single or rescue at the end of the kernel boot line to enter single-user mode. You can specify init=/bin/bash in the GRUB boot parameters to get a basic shell with limited functionality.
Fix the /etc/fstab file: nano/etc/fstab
Remount the root filesystem: mount -o remount,rw / Reboot: After fixing the file, reboot the system: reboot
Question 6: How would you troubleshoot a slow-performing server?
Answer: Check CPU usage: Use top or htop to check for high CPU usage: top
Identify any processes consuming excessive CPU and investigate further.
Check memory usage: free -m
Check for high swap usage, which might indicate memory pressure.
Question 7: How would you troubleshoot a system that's running out of disk space?
Answer: Use the df command to see which partitions are full: df -h
This will show disk usage in a human-readable format.Find large files: du-ah / | sort -rh | head -n 20 This command lists the top 20 largest files and directories.
Question 8: How do you set file permissions recursively on a directory?
Answer: Change permissions on a directory and its contents: Use chmod with the -R option: chmod -R 755/path/to/directory
Change ownership recursively: Use chown to change the owner and group of the directory and its contents: chown -R user:group/path/to/directory