0% found this document useful (0 votes)
9 views10 pages

Linux

The document provides a comprehensive guide on Linux basics, including differences between Linux and Unix, Linux file system hierarchy, shell types, and commands for system management. It also covers intermediate and advanced interview questions related to process management, system security, and performance tuning. Key topics include runlevels, file permissions, the boot process, and troubleshooting techniques.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views10 pages

Linux

The document provides a comprehensive guide on Linux basics, including differences between Linux and Unix, Linux file system hierarchy, shell types, and commands for system management. It also covers intermediate and advanced interview questions related to process management, system security, and performance tuning. Key topics include runlevels, file permissions, the boot process, and troubleshooting techniques.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

Linux Basics (Beginner Level)

1. What is Linux and how is it different from Unix?

Linux is an open-source, Unix-like operating system based on the Linux kernel. Unlike Unix, which is
typically proprietary, Linux is free and can be modified and distributed by anyone.

Differences:

• Linux is open-source; Unix is mostly proprietary.


• Linux runs on many hardware platforms; Unix is hardware-specific.
• Linux has many distributions; Unix has limited flavors.

2. What is the difference between Linux and Windows?

Feature Linux Windows

Source Open-source Proprietary

Security More secure More targeted by malware

Customization Highly customizable Limited

CLI Usage Essential Optional

3. What is the Linux file system hierarchy?

Linux follows a tree-like structure:

• / : Root directory
• /bin : Essential binaries
• /etc : Configuration files
• /home : User directories
• /var : Logs and variable data
• /tmp : Temporary files

4. What is a shell? What are some common types of shells?

A shell is a command-line interpreter that lets users interact with the OS. Common shells:

• bash (default in most distros)


• sh (Bourne shell)
• zsh , csh , ksh

1
5. What are runlevels in Linux?

Runlevels define the state of a Linux system:

• 0: Halt
• 1: Single-user
• 3: Multi-user (non-GUI)
• 5: Multi-user (with GUI)
• 6: Reboot

Use runlevel or systemctl get-default in systemd systems.

6. How do you check the current working directory?

pwd

7. What does chmod 755 mean?

It sets permissions:

• 7: Owner (read, write, execute)


• 5: Group (read, execute)
• 5: Others (read, execute)

chmod 755 filename

8. How do you view hidden files?

ls -a

9. What is the difference between > and >> ?

• > : Overwrites file


• >> : Appends to file

2
10. How do you search for a string in a file?

grep 'search_term' filename

11. How do you check memory usage?

free -h

12. What command shows disk usage per directory?

du -sh *

13. How do you find a file by name?

find /path -name filename

14. What is cron and how do you schedule a job?

cron automates tasks. To schedule:

crontab -e
# Example: Run script at 5 AM daily
0 5 * * * /path/to/script.sh

15. What is the use of top, ps, and kill commands?

• top : Real-time process monitoring


• ps : Snapshot of processes
• kill : Terminate processes by PID

3
Intermediate Linux Interview Questions

1. How do you check which process is using the most CPU/memory?

top
htop
ps aux --sort=-%mem | head

2. What’s the difference between nice and renice?

• nice : Sets priority when starting a process


• renice : Changes priority of a running process

nice -n 10 command
renice -n 5 -p PID

3. What’s the difference between kill, pkill, and killall?

• kill : Requires PID


• pkill : Kills by name
• killall : Kills all instances

4. How do you analyze and troubleshoot a system that is running slowly?

• top , htop , iotop , vmstat , dstat


• Check CPU, memory, disk I/O, and load average

5. How do you check logs for a failed service?

journalctl -u servicename

6. What is the use of netstat, ss, and lsof?

• netstat : Show network connections


• ss : Faster alternative to netstat
• lsof -i : List open network files

4
7. How do you check if a port is open and listening?

netstat -tuln
ss -tuln
lsof -i :PORT

8. Difference between scp and rsync?

• scp : Secure copy


• rsync : Faster, supports resume and sync

scp file user@host:/path


rsync -av file user@host:/path

9. How do you configure a static IP address?

Edit /etc/network/interfaces or use nmcli :

nmcli con mod eth0 ipv4.addresses 192.168.1.10/24


nmcli con mod eth0 ipv4.gateway 192.168.1.1
nmcli con mod eth0 ipv4.method manual
nmcli con up eth0

10. How do you flush DNS cache?

sudo systemd-resolve --flush-caches

11. How do hard links differ from soft links?

• Hard link: Same inode, can't cross filesystems


• Soft link (symlink): Pointer to original file

ln file1 file2 # Hard link


ln -s file1 link # Soft link

5
12. How do you mount and unmount file systems?

mount /dev/sdX /mnt


umount /mnt

13. How do you view disk partitions and usage?

lsblk
fdisk -l
df -h

14. How do file permissions work in Linux?

Each file has three sets of permissions: Owner, Group, Others. Types:

• r = read
• w = write
• x = execute

15. What is sticky bit, setuid, and setgid?

• Sticky Bit: Restricts file deletion (e.g., /tmp)


• setuid: Run file as file owner
• setgid: Run as group owner

chmod +t dir
chmod u+s file
chmod g+s file

Advanced Linux Interview Questions

1. What happens during the Linux boot process (BIOS → GRUB → init → systemd)?

• BIOS: Initializes hardware


• GRUB: Loads bootloader and selects kernel
• initramfs: Prepares root filesystem
• Kernel: Loads system drivers and mounts root
• systemd/init: Initializes user space and services

6
2. What is initrd or initramfs?

A temporary root filesystem used during boot before the actual root is mounted. Contains drivers and tools
needed for early boot stages.

3. What are cgroups and namespaces? How do they work?

• cgroups: Limit resources (CPU, memory) per process


• namespaces: Provide isolation (PID, net, mount, etc.) Used in containers like Docker for process
isolation and control.

4. How does Linux handle process scheduling?

Uses Completely Fair Scheduler (CFS) with priorities. Processes are scheduled based on time slices and
priority (nice value).

5. Explain the role of systemd and how you manage services with it.

systemd initializes the system and manages services.

systemctl start service


systemctl enable service
systemctl status service

🔒 Security & Access

6. What is SELinux/AppArmor? How do you troubleshoot permission issues related to


them?

• SELinux/AppArmor: Security modules that enforce access control policies. To troubleshoot:

sestatus
journalctl | grep -i denied

7
7. How do you securely copy files between Linux systems?

scp file user@host:/path


rsync -e ssh file user@host:/path

8. How do you set up SSH key-based authentication?

ssh-keygen
ssh-copy-id user@host

9. How do you audit system activity or monitor unauthorized access?

• Use auditd , ausearch , auditctl


• Check /var/log/auth.log

10. What is sudo and how is it different from su?

• sudo : Run specific commands as root


• su : Switch to another user (default is root)

🧐 Performance & Tuning

11. How do you identify and resolve a memory leak?

• Use top , ps , valgrind


• Identify high memory usage processes and trace via logs/debugging

12. What tools would you use for profiling a system under heavy load?

• top , htop , iotop , vmstat , perf , strace

8
13. How do you analyze I/O wait using tools like iostat, vmstat, or iotop?

iostat -x 1
vmstat 1
iotop

High I/O wait indicates disk bottlenecks.

14. What are kernel modules? How do you manage them?

Modules are pieces of code that can be loaded/unloaded into the kernel.

lsmod
modprobe module_name
rmmod module_name

15. How do you tune kernel parameters with sysctl?

sysctl -a
sysctl -w net.ipv4.ip_forward=1

Persist by adding to /etc/sysctl.conf

📂 Bonus: Real-World Scenario-Based Questions

16. A process is stuck in uninterruptible sleep (D state). How do you investigate it?

• Use ps -eo pid,stat,cmd | grep D


• Check disk/NFS issues, I/O waits
• Use lsof , strace for debugging

17. A cron job isn’t running. What steps would you take to debug it?

• Check crontab -l
• Review /var/log/cron.log or journalctl
• Ensure script has execute permissions and uses full paths

9
18. A service fails to start after a reboot. How do you trace the problem?

• Check systemctl status servicename


• View logs with journalctl -u servicename
• Look for failed dependencies or permission errors

End of Linux Interview Guide.

10

You might also like