Linux Interview questions beginner to expert ❤️
How do you check disk space usage in Linux?
df -h
du -sh * // To check size in particular directory only top lvl
du -ah . // Show size of file recursively
Where are system logs stored?
Most Linux logs are stored in /var/log/. Important logs include authentication logs, system logs, boot logs, and application logs.
/var/log/messages
/var/log/secure
/var/log/syslog
/var/log/boot.log
If a server is not starting properly, how do you debug it?
systemctl --failed
df -h
free -m
reboot logs
Explain file permissions and give execute permission.
Linux permissions are Read, Write, Execute for owner, group, others. To give execute permission to a user-owned file
chmod u+x script.sh // For single user
chmod +x script.sh // For all users
ls -l filename // To view permission
How do you change file permissions?
chmod 755 file.sh
chmod +x file.sh
What does 777 permission mean?
777 means full permissions to owner, group, others.
7 = read + write + execute
4 = Read (
r)2 = Write (
w)1 = Execute (
x)
Default permissions of file and directory?
Usually files get 644 and directories get 755 depending on umask.
Change ownership of file?
chown user:group file.txt
Root user but cannot create file?
I will check the disk space is full or not and check the i nodes once
df -h
df -i
Create user and assign group?
useradd rama
usermod -aG devops rama
userdel username
Create user in Linux?
useradd username // To create user
passwd username // To set Password
getent passwd // To get list of users
Create Group in Linux ?
groupadd <groupname> // To create a group
groupdel <groupname> // to delete a group
getent group // To get list of groups
Where are user details stored?
/etc/passwd → user info
/etc/shadow → encrypted passwords
/etc/group → groups
Disk free but cannot perform actions?
I will check disk space , i nodes and mount access whether it ro or rw
df -h
mount
Find largest files in directory?
du -ah . | sort -rh | head -10
What is zombie process?
A zombie process is completed child process whose parent has not collected exit status
ps -ef // To get all process in full format
Networking issue commands?
ping //Checks basic network connectivity and latency
nslookup // Check DNS resolution
dig // Advanced DNS lookup.
traceroute // To trace route and hops
ip a // Ip address
route -n
Server not coming after reboot?
If a server doesn’t come up after reboot, I first use console access to determine whether it’s a boot or network issue. Then I review boot logs with journalctl -xb, check failed services, disk space, /etc/fstab, network config, and SSH service. If needed, I boot into rescue mode for filesystem repair
Soft link vs Hard link?
Soft link
Shortcut to file/path
Breaks if original deleted
ln -s file link
Hard link
Same inode
Works even if original deleted
ln file link
What is journalctl used for ?
journalctl is used to check system logs, service logs, boot logs, kernel logs, and troubleshooting logs on Linux systems that use systemd
