Question 1: What is the difference between a Hard Link and a Soft Link in Linux?
1. Question:
What is the difference between a Hard Link and a Soft Link in Linux?
2. Answer:
○ Hard Link: A hard link is a mirror copy of the original file. It shares the same inode
number as the original file. Deleting the original file doesn’t affect the hard link.
○ Soft Link (Symbolic Link): A soft link is more like a shortcut that points to the original
file. It has a different inode number and if the original file is deleted, the soft link
becomes broken (dangling link).
3. What Skills Required to Prepare This Question:
○ Understanding of Linux file systems and inodes
○ Basic knowledge of file linking mechanisms
○ Command-line proficiency (e.g., ln command)
4. How to Study This Question:
○ Study the Linux file system structure and inode concepts
○ Practice creating hard and soft links using commands (ln, ln -s)
○ Experiment by deleting original files and observing the behavior of links
5. Examples for This Question:
Unset
# Create a file
touch file1.txt
# Create a hard link
ln file1.txt file1_hardlink.txt
# Create a soft link
ln -s file1.txt file1_softlink.txt
# Check inodes
ls -li
Question 2: How do you check disk usage in Linux?
1. Question:
How do you check disk usage in Linux?
2. Answer:
You can use the following commands:
○ df -h: Displays disk space usage in a human-readable format.
○ du -sh /path/to/directory: Shows disk usage of a specific directory.
○ lsblk: Lists block devices and their mount points.
○ ncdu: An interactive disk usage analyzer.
3. What Skills Required to Prepare This Question:
○ Familiarity with Linux command-line tools
○ Understanding of file systems and storage
○ Ability to interpret disk usage data
4. How to Study This Question:
○ Practice using the disk usage commands
○ Learn how to interpret the output (e.g., understanding mounted partitions)
○ Study different disk file systems and how Linux handles storage
5. Examples for This Question:
Unset
# Check overall disk usage
df -h
# Check usage of a specific directory
du -sh /var/log
# List block devices
lsblk
# Use ncdu for interactive analysis
ncdu /home
Question 3: Explain the Linux boot process.
1. Question:
Explain the Linux boot process.
2. Answer:
The Linux boot process consists of several stages:
○ BIOS/UEFI: Initializes hardware and finds the boot loader.
○ Boot Loader (GRUB/LILO): Loads the kernel into memory.
○ Kernel: Initializes system components and mounts the root file system.
○ init/systemd: Starts system processes and services.
○ Login: Presents the login prompt or GUI.
3. What Skills Required to Prepare This Question:
○ In-depth understanding of Linux architecture
○ Familiarity with boot loaders (GRUB, LILO)
○ Knowledge of system initialization (init/systemd)
4. How to Study This Question:
○ Study the Linux boot process flow and components
○ Practice troubleshooting boot issues (e.g., GRUB errors)
○ Learn systemd and init commands for service management
5. Examples for This Question:
Unset
# View boot log
dmesg | less
# Check systemd boot process
systemctl list-units --type=service
# Edit GRUB configuration
sudo nano /etc/default/grub
sudo update-grub
Question 4: How do you manage services in Linux?
1. Question:
How do you manage services in Linux?
2. Answer:
Service management in Linux depends on the init system:
○ systemd-based systems (modern Linux distros):
■ Start a service: systemctl start service_name
■ Stop a service: systemctl stop service_name
■ Enable service at boot: systemctl enable service_name
■ Check status: systemctl status service_name
○ SysVinit-based systems (older distros):
■ Start a service: service service_name start
■ Stop a service: service service_name stop
■ Check status: service service_name status
3. What Skills Required to Prepare This Question:
○ Knowledge of Linux service management systems (systemd, SysVinit)
○ Experience with command-line tools for service control
○ Understanding of startup scripts and runlevels
4. How to Study This Question:
○ Practice starting, stopping, and enabling services using systemctl and service
commands
○ Learn the differences between systemd and SysVinit
○ Understand how to debug failed services using logs (journalctl)
5. Examples for This Question:
Unset
# Start and enable Apache service
sudo systemctl start apache2
sudo systemctl enable apache2
# Check the status of SSH service
systemctl status ssh
# View logs for a service
journalctl -u apache2
Question 5: What are file permissions in Linux and how do you modify them?
1. Question:
What are file permissions in Linux and how do you modify them?
2. Answer:
Linux file permissions are divided into three types:
○ Read (r): Allows reading the contents of a file or listing a directory.
○ Write (w): Allows modifying the contents of a file or directory.
○ Execute (x): Allows executing a file or accessing a directory.
3. Permissions are assigned to:
○ User (u): Owner of the file
○ Group (g): Users who belong to the file’s group
○ Others (o): All other users
4. Modify permissions using:
○ chmod to change permissions
○ chown to change ownership
○ chgrp to change group ownership
5. What Skills Required to Prepare This Question:
○ Understanding of Linux file permission model
○ Proficiency in using permission-related commands (chmod, chown, chgrp)
○ Knowledge of numeric (e.g., 755) and symbolic (e.g., u+x) permission notation
6. How to Study This Question:
○ Practice changing file and directory permissions
○ Study permission representation (rwxr-xr--)
○ Learn how special permissions (SUID, SGID, Sticky bit) work
7. Examples for This Question:
Unset
# View file permissions
ls -l
# Grant execute permission to the user
chmod u+x script.sh
# Change file ownership to user 'john'
chown john file.txt
# Set read, write, execute for user, read and execute for group and
others
chmod 755 myfile
Question 6: How do you schedule tasks in Linux?
1. Question:
How do you schedule tasks in Linux?
2. Answer:
Linux offers several tools for scheduling tasks:
○ cron: For recurring tasks
■ List cron jobs: crontab -l
■ Edit cron jobs: crontab -e
■ Cron syntax: * * * * * /path/to/command
○ at: For one-time tasks
■ Schedule a task: echo "command" | at 10:00 AM
■ List scheduled tasks: atq
○ systemd timers: Advanced scheduling using systemd
3. What Skills Required to Prepare This Question:
○ Familiarity with cron and at syntax
○ Understanding of systemd timers
○ Basic shell scripting for scheduled tasks
4. How to Study This Question:
○ Practice setting up cron jobs for various intervals
○ Use at to schedule one-time tasks
○ Explore systemd timers for complex scheduling needs
5. Examples for This Question:
Unset
# Schedule a cron job to run every day at 2 AM
crontab -e
# Add the following line
0 2 * * * /path/to/script.sh
# Schedule a one-time task with at
echo "backup.sh" | at 11:30 PM
# View existing cron jobs
crontab -l
Question 7: How do you check running processes in Linux?
1. Question:
How do you check running processes in Linux?
2. Answer:
You can check running processes using the following commands:
○ ps: Lists running processes.
■ Example: ps aux shows all processes.
○ top: Real-time display of running processes and system resource usage.
○ htop: An enhanced version of top with a user-friendly interface.
○ pgrep: Searches for processes by name.
○ pstree: Displays processes in a tree-like format.
3. What Skills Required to Prepare This Question:
○ Familiarity with Linux process management
○ Proficiency in using process-related commands
○ Understanding of process IDs (PIDs) and parent-child relationships
4. How to Study This Question:
○ Practice using process monitoring commands
○ Study how to interpret CPU and memory usage in top and htop
○ Learn to filter and search for specific processes using pgrep and grep
5. Examples for This Question:
Unset
# List all processes
ps aux
# Display real-time processes
top
# Use htop (if installed)
htop
# Find the PID of nginx
pgrep nginx
# Display processes as a tree
pstree
Question 8: How do you manage users and groups in Linux?
1. Question:
How do you manage users and groups in Linux?
2. Answer:
Linux provides commands for user and group management:
○ User Management:
■ Add a user: useradd username
■ Delete a user: userdel username
■ Modify a user: usermod
■ Set password: passwd username
○ Group Management:
■ Add a group: groupadd groupname
■ Delete a group: groupdel groupname
■ Add user to a group: usermod -aG groupname username
○ User and group information is stored in /etc/passwd, /etc/group, and
/etc/shadow.
3. What Skills Required to Prepare This Question:
○ Understanding of Linux user and group management
○ Familiarity with permission models and file ownership
○ Proficiency with related command-line tools
4. How to Study This Question:
○ Practice adding, modifying, and deleting users and groups
○ Study the structure of /etc/passwd and /etc/group
○ Learn how to set and manage user permissions
5. Examples for This Question:
Unset
# Add a new user
sudo useradd john
# Set a password for the user
sudo passwd john
# Add user to the 'sudo' group
sudo usermod -aG sudo john
# List users
cat /etc/passwd
# List groups
cat /etc/group
Question 9: How do you secure a Linux server?
1. Question:
How do you secure a Linux server?
2. Answer:
Securing a Linux server involves several best practices:
○ User and Access Control:
■ Use strong passwords and SSH keys
■ Disable root login over SSH (/etc/ssh/sshd_config)
○ Firewall and Network Security:
■ Configure firewall using ufw or iptables
■ Close unused ports
○ Updates and Patching:
■ Regularly update the system (apt update && apt upgrade or yum
update)
○ Intrusion Prevention:
■ Use tools like fail2ban to block malicious IPs
○ File Permissions and SELinux/AppArmor:
■ Set correct file permissions
■ Enforce security policies using SELinux or AppArmor
3. What Skills Required to Prepare This Question:
○ Knowledge of Linux security principles
○ Familiarity with firewalls and intrusion prevention tools
○ Experience with user and file permission management
4. How to Study This Question:
○ Practice setting up firewalls (ufw, iptables)
○ Learn how to harden SSH and manage access control
○ Study SELinux/AppArmor basics and how to apply security policies
5. Examples for This Question:
Unset
# Enable UFW firewall
sudo ufw enable
sudo ufw allow ssh
# Disable root login over SSH
sudo nano /etc/ssh/sshd_config
# Set PermitRootLogin no
sudo systemctl restart sshd
# Install and configure fail2ban
sudo apt install fail2ban
sudo systemctl enable fail2ban
Question 10: How do you monitor system performance in Linux?
1. Question:
How do you monitor system performance in Linux?
2. Answer:
You can monitor system performance using several built-in and third-party tools:
○ CPU and Memory Usage:
■ top / htop: Real-time system performance
■ vmstat: Reports memory, CPU, and process statistics
○ Disk I/O:
■ iostat: Monitors disk I/O performance
■ iotop: Displays real-time disk usage by processes
○ Network Usage:
■ iftop: Real-time network traffic
■ nload: Shows network traffic in and out
○ System-wide Monitoring:
■ sar: Collects and reports system activity
■ dstat: Versatile tool for various system resources
3. What Skills Required to Prepare This Question:
○ Understanding of system resource management
○ Familiarity with Linux performance monitoring tools
○ Ability to interpret system metrics for troubleshooting
4. How to Study This Question:
○ Practice using monitoring tools in different system load scenarios
○ Learn how to analyze performance bottlenecks
○ Study how to optimize system resources based on monitoring data
5. Examples for This Question:
Unset
# Real-time CPU and memory usage
top
# View disk I/O statistics
iostat
# Check network traffic
iftop
# Overall system performance
vmstat 5
# Install and use htop
sudo apt install htop
htop
Question 11: How do you configure a firewall in Linux?
1. Question:
How do you configure a firewall in Linux?
2. Answer:
There are multiple tools to configure firewalls in Linux:
○ UFW (Uncomplicated Firewall):
■ Enable UFW: sudo ufw enable
■ Allow SSH: sudo ufw allow ssh
■ Check status: sudo ufw status
○ iptables:
■ View rules: sudo iptables -L
■ Allow traffic on port 80: sudo iptables -A INPUT -p tcp --dport 80
-j ACCEPT
■ Save rules: sudo iptables-save > /etc/iptables/rules.v4
○ firewalld:
■ Start firewalld: sudo systemctl start firewalld
■ Allow service: sudo firewall-cmd --permanent --add-service=http
■ Reload rules: sudo firewall-cmd --reload
3. What Skills Required to Prepare This Question:
○ Knowledge of Linux firewall tools (UFW, iptables, firewalld)
○ Understanding of networking concepts (ports, protocols)
○ Familiarity with security best practices
4. How to Study This Question:
○ Practice setting up firewalls using UFW and iptables
○ Study how to open/close ports and create rules
○ Understand common firewall policies and configurations
5. Examples for This Question:
Unset
# UFW example
sudo ufw enable
sudo ufw allow 22/tcp
sudo ufw status
# iptables example
sudo iptables -A INPUT -p tcp --dport 443 -j ACCEPT
sudo iptables -L
# firewalld example
sudo firewall-cmd --zone=public --add-port=8080/tcp --permanent
sudo firewall-cmd --reload
Question 12: How do you mount and unmount file systems in Linux?
1. Question:
How do you mount and unmount file systems in Linux?
2. Answer:
Mounting and unmounting file systems can be done using the following commands:
○ Mount a file system:
■ mount /dev/sdX1 /mnt/mydisk
○ Unmount a file system:
■ umount /mnt/mydisk
○ View mounted file systems:
■ df -h or mount
○ Mount with specific options:
■ mount -o ro /dev/sdX1 /mnt/mydisk (mount as read-only)
○ Persistent Mounting:
■ Edit /etc/fstab to auto-mount file systems on boot.
3. What Skills Required to Prepare This Question:
○ Understanding of Linux file system structures
○ Knowledge of disk partitions and devices
○ Familiarity with mount options and fstab configurations
4. How to Study This Question:
○ Practice mounting/unmounting drives and network shares
○ Study the structure of /etc/fstab and mount options
○ Learn to troubleshoot mount errors and permissions
5. Examples for This Question:
Unset
# Mount a disk
sudo mount /dev/sdb1 /mnt/data
# Unmount a disk
sudo umount /mnt/data
# View mounted file systems
df -h
# Edit fstab for persistent mount
sudo nano /etc/fstab
# Example line
/dev/sdb1 /mnt/data ext4 defaults 0 2
Question 13: How do you troubleshoot network issues in Linux?
1. Question:
How do you troubleshoot network issues in Linux?
2. Answer:
Network issues can be diagnosed using several tools:
○ Check Network Configuration:
■ ifconfig or ip addr to view network interfaces
■ ip route to check routing tables
○ Test Connectivity:
■ ping to test connectivity to another host
■ traceroute or tracepath to trace the path to a host
○ Check DNS Resolution:
■ nslookup or dig to verify DNS resolution
○ Check Open Ports and Services:
■ netstat -tuln or ss -tuln to list listening ports
■ lsof -i to see which processes are using network ports
○ Analyze Network Traffic:
■ tcpdump or wireshark for packet capture and analysis
3. What Skills Required to Prepare This Question:
○ Understanding of networking fundamentals (IP, DNS, routing)
○ Proficiency with Linux networking tools
○ Ability to diagnose and resolve connectivity and performance issues
4. How to Study This Question:
○ Practice using networking commands in different scenarios
○ Study how to interpret traceroute and packet captures
○ Simulate network issues and practice troubleshooting
5. Examples for This Question:
Unset
# Check network interfaces
ip addr
# Test connectivity to google.com
ping google.com
# Trace the path to a remote host
traceroute google.com
# Check DNS resolution
dig openai.com
# Capture network traffic on eth0
sudo tcpdump -i eth0
Question 14: How do you manage disk space in Linux?
1. Question:
How do you manage disk space in Linux?
2. Answer:
Disk space management involves monitoring usage, cleaning up files, and managing partitions:
○ Check Disk Usage:
■ df -h to display disk space usage
■ du -sh /path/to/directory to check directory size
○ Find Large Files:
■ find / -type f -size +500M to locate files over 500MB
○ Clean Up Space:
■ Remove unused files and logs
■ Use logrotate to manage log file sizes
○ Manage Partitions:
■ fdisk or parted for partition management
■ resize2fs or xfs_growfs to resize file systems
3. What Skills Required to Prepare This Question:
○ Knowledge of Linux file systems and partitions
○ Familiarity with disk monitoring and cleanup tools
○ Understanding of file system resizing and disk optimization
4. How to Study This Question:
○ Practice monitoring and managing disk space
○ Learn how to safely clean up system logs and temporary files
○ Study partitioning tools and file system resizing techniques
5. Examples for This Question:
Unset
# Check overall disk usage
df -h
# Check disk usage in a specific directory
du -sh /var/log
# Find large files over 1GB
find / -type f -size +1G
# Manage partitions
sudo fdisk /dev/sdb
# Resize ext4 file system
sudo resize2fs /dev/sdb1
Question 15: How do you create and manage symbolic and hard links in Linux?
1. Question:
How do you create and manage symbolic and hard links in Linux?
2. Answer:
Linux supports two types of links:
○ Hard Links:
■ Point directly to the inode of a file
■ Cannot span across file systems
■ Created using: ln source_file link_name
○ Symbolic (Soft) Links:
■ Point to the path of the target file
■ Can link directories and cross file systems
■ Created using: ln -s source_file link_name
3. Managing Links:
○ Use ls -l to view links (l indicates a symbolic link)
○ Use readlink to display the target of a symlink
○ Remove links with rm link_name
4. What Skills Required to Prepare This Question:
○ Understanding of Linux file system structures and inodes
○ Familiarity with ln and link management commands
○ Knowledge of differences and use cases for hard and symbolic links
5. How to Study This Question:
○ Practice creating and managing both types of links
○ Study how links behave when the source file is moved or deleted
○ Understand the implications of using links in scripts and applications
6. Examples for This Question:
Unset
# Create a hard link
ln original.txt hardlink.txt
# Create a symbolic link
ln -s /var/www/html website_link
# View links
ls -l
# Check the target of a symlink
readlink website_link
# Remove a link
rm hardlink.txt
Question 16: How do you set up a cron job in Linux?
1. Question:
How do you set up a cron job in Linux?
2. Answer:
Cron is a time-based job scheduler in Linux used to run scripts and commands at specified
intervals.
○ Edit crontab:
■ crontab -e to edit the user's cron jobs
■ crontab -l to list existing cron jobs
■ crontab -r to remove all cron jobs
○ Cron Syntax:
■ * * * * * /path/to/command
■ Format: minute hour day month day_of_week command
○ System-Wide Cron Jobs:
■ Placed in /etc/crontab or /etc/cron.d/
○ Logs:
■ Cron logs can be found in /var/log/syslog or /var/log/cron
3. What Skills Required to Prepare This Question:
○ Understanding of cron syntax and scheduling
○ Familiarity with Linux command-line tools
○ Ability to debug and monitor scheduled tasks
4. How to Study This Question:
○ Practice creating and managing cron jobs
○ Study different cron timing examples
○ Learn to troubleshoot common cron issues
5. Examples for This Question:
Unset
# Edit user's crontab
crontab -e
# Run a script every day at midnight
0 0 * * * /home/user/backup.sh
# List cron jobs
crontab -l
# View cron logs
tail -f /var/log/syslog | grep CRON
Question 17: How do you configure SSH for secure remote access?
1. Question:
How do you configure SSH for secure remote access?
2. Answer:
SSH (Secure Shell) allows secure remote login and command execution.
○ Basic Setup:
■ Install SSH: sudo apt install openssh-server
■ Start service: sudo systemctl start ssh
○ Security Enhancements:
■ Disable root login:
■ Edit /etc/ssh/sshd_config: PermitRootLogin no
■ Use SSH Keys:
■ Generate key: ssh-keygen
■ Copy key to server: ssh-copy-id user@server
■ Change default port:
■ Edit /etc/ssh/sshd_config: Port 2222
○ Restart SSH Service:
■ sudo systemctl restart ssh
3. What Skills Required to Prepare This Question:
○ Understanding of SSH protocol and configuration
○ Knowledge of Linux security best practices
○ Familiarity with key-based authentication
4. How to Study This Question:
○ Practice setting up and securing SSH connections
○ Study SSH configuration options and logs
○ Learn to troubleshoot common SSH issues
5. Examples for This Question:
Unset
# Install SSH server
sudo apt install openssh-server
# Generate SSH key pair
ssh-keygen
# Copy key to remote server
ssh-copy-id user@remote_server
# Edit SSH config to disable root login
sudo nano /etc/ssh/sshd_config
# Set PermitRootLogin no
# Restart SSH service
sudo systemctl restart ssh
Question 18: How do you manage services in Linux using systemd?
1. Question:
How do you manage services in Linux using systemd?
2. Answer:
Systemd is a system and service manager for Linux.
○ Service Management Commands:
■ Start a service: sudo systemctl start service_name
■ Stop a service: sudo systemctl stop service_name
■ Restart a service: sudo systemctl restart service_name
■ Enable service at boot: sudo systemctl enable service_name
■ Disable service: sudo systemctl disable service_name
○ Check Service Status:
■ sudo systemctl status service_name
○ View Logs:
■ Use journalctl: journalctl -u service_name
3. What Skills Required to Prepare This Question:
○ Understanding of systemd and service management
○ Familiarity with Linux boot processes
○ Ability to read and interpret system logs
4. How to Study This Question:
○ Practice managing services with systemd
○ Study unit files and how to create custom services
○ Learn how to debug service startup issues
5. Examples for This Question:
Unset
# Start and enable nginx service
sudo systemctl start nginx
sudo systemctl enable nginx
# Check service status
sudo systemctl status nginx
# View service logs
journalctl -u nginx
# Disable a service
sudo systemctl disable apache2
Question 19: How do you set file permissions in Linux?
1. Question:
How do you set file permissions in Linux?
2. Answer:
Linux uses a permission model with three sets of permissions: user (owner), group, and
others.
○ View Permissions:
■ ls -l filename shows permissions (e.g., -rwxr-xr--)
○ Change Permissions with chmod:
■ Symbolic Mode: chmod u+x script.sh (add execute for user)
■ Numeric Mode: chmod 755 script.sh
■ 7 = read + write + execute (rwx)
■ 5 = read + execute (r-x)
■ 5 = read + execute (r-x)
○ Change Ownership with chown:
■ sudo chown user:group file
○ Change Group with chgrp:
■ sudo chgrp groupname file
3. What Skills Required to Prepare This Question:
○ Understanding of Linux file permission structure
○ Familiarity with chmod, chown, and chgrp commands
○ Knowledge of symbolic and numeric permission modes
4. How to Study This Question:
○ Practice modifying permissions on files and directories
○ Study the implications of different permission sets
○ Learn about special permissions like SUID, SGID, and sticky bits
5. Examples for This Question:
Unset
# View permissions
ls -l file.txt
# Give execute permission to the owner
chmod u+x script.sh
# Set permissions to rwxr-xr--
chmod 754 file.txt
# Change file ownership
sudo chown user1:usergroup file.txt
# Change group ownership
sudo chgrp devteam project/
Question 20: How do you configure NFS (Network File System) in Linux?
1. Question:
How do you configure NFS (Network File System) in Linux?
2. Answer:
NFS allows file sharing between Linux systems over a network.
○ On the NFS Server:
■ Install NFS: sudo apt install nfs-kernel-server
■ Configure exports in /etc/exports:
■ Example: /shared_folder
192.168.1.0/24(rw,sync,no_subtree_check)
■ Apply exports: sudo exportfs -a
■ Start NFS service: sudo systemctl start nfs-kernel-server
○ On the NFS Client:
■ Install NFS: sudo apt install nfs-common
■ Create mount point: sudo mkdir /mnt/nfs_share
■ Mount share: sudo mount server_ip:/shared_folder /mnt/nfs_share
■ Add to /etc/fstab for persistent mount
3. What Skills Required to Prepare This Question:
○ Understanding of network file sharing protocols
○ Familiarity with NFS server/client setup
○ Knowledge of permissions and network security
4. How to Study This Question:
○ Practice setting up NFS on a local network
○ Study export options and security considerations
○ Learn to troubleshoot common NFS issues
5. Examples for This Question:
Unset
# On NFS server - configure exports
echo "/srv/nfs 192.168.1.0/24(rw,sync,no_subtree_check)" | sudo tee -a
/etc/exports
sudo exportfs -a
sudo systemctl restart nfs-kernel-server
# On NFS client - mount the share
sudo mkdir /mnt/nfs_share
sudo mount 192.168.1.10:/srv/nfs /mnt/nfs_share
# Verify mount
df -h | grep nfs
Question 21: How do you manage users and groups in Linux?
1. Question:
How do you manage users and groups in Linux?
2. Answer:
Linux provides several commands to manage users and groups:
○ Create User:
■ sudo useradd -m username (creates user with home directory)
■ Set password: sudo passwd username
○ Modify User:
■ sudo usermod -aG groupname username (add user to a group)
■ sudo usermod -s /bin/bash username (change default shell)
○ Delete User:
■ sudo userdel -r username (removes user and home directory)
○ Manage Groups:
■ Create group: sudo groupadd groupname
■ Delete group: sudo groupdel groupname
■ Change group ownership: sudo chgrp groupname file
3. What Skills Required to Prepare This Question:
○ Understanding of Linux user/group management
○ Familiarity with system permissions and file ownership
○ Knowledge of user security policies
4. How to Study This Question:
○ Practice creating, modifying, and deleting users/groups
○ Study /etc/passwd and /etc/group files
○ Learn to manage user permissions and roles
5. Examples for This Question:
Unset
# Create a new user with a home directory
sudo useradd -m john
# Set user password
sudo passwd john
# Add user to sudo group
sudo usermod -aG sudo john
# Create a new group
sudo groupadd developers
# Add user to the developers group
sudo usermod -aG developers john
# Delete user and their home directory
sudo userdel -r john
Question 22: How do you monitor system performance in Linux?
1. Question:
How do you monitor system performance in Linux?
2. Answer:
Linux provides several tools to monitor system performance:
○ CPU and Memory Usage:
■ top or htop for real-time system monitoring
■ vmstat for system performance statistics
○ Disk Usage and I/O:
■ df -h for disk space usage
■ iostat for disk I/O statistics
■ du -sh /path/to/directory for directory size
○ Network Monitoring:
■ iftop or nload for real-time network traffic
■ netstat or ss for active connections
○ System Logs:
■ View logs in /var/log/ (e.g., syslog, dmesg)
○ Advanced Monitoring:
■ Use tools like sar, glances, or nmon for comprehensive monitoring
3. What Skills Required to Prepare This Question:
○ Familiarity with Linux performance monitoring tools
○ Understanding of system resources (CPU, memory, disk, network)
○ Ability to interpret performance metrics
4. How to Study This Question:
○ Practice using system monitoring commands
○ Study performance bottlenecks and their resolutions
○ Learn to set up alerts and log monitoring
5. Examples for This Question:
Unset
# Monitor CPU and memory
top
# Display disk usage
df -h
# Check disk I/O
iostat
# Monitor network traffic
iftop
# View system logs
tail -f /var/log/syslog
Question 23: How do you configure a firewall in Linux using iptables or firewalld?
1. Question:
How do you configure a firewall in Linux using iptables or firewalld?
2. Answer:
Linux firewalls can be configured using iptables or firewalld.
○ Using firewalld:
■ Start/enable firewalld: sudo systemctl enable --now firewalld
■ Check status: sudo firewall-cmd --state
■ Allow a port: sudo firewall-cmd --permanent --add-port=80/tcp
■ Reload firewall: sudo firewall-cmd --reload
○ Using iptables:
■ Allow traffic on port 22 (SSH): sudo iptables -A INPUT -p tcp --dport
22 -j ACCEPT
■ Drop all other incoming traffic: sudo iptables -P INPUT DROP
■ List rules: sudo iptables -L -v
■ Save rules: sudo iptables-save > /etc/iptables/rules.v4
3. What Skills Required to Prepare This Question:
○ Understanding of network security and firewall principles
○ Familiarity with iptables and firewalld commands
○ Knowledge of ports, protocols, and traffic filtering
4. How to Study This Question:
○ Practice configuring firewalls in a safe environment
○ Study different rule sets and their implications
○ Learn to troubleshoot connectivity issues caused by firewall rules
5. Examples for This Question:
Unset
# Using firewalld - allow HTTP traffic
sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --reload
# Using iptables - allow SSH traffic
sudo iptables -A INPUT -p tcp --dport 22 -j ACCEPT
# Block all incoming traffic except SSH
sudo iptables -P INPUT DROP
sudo iptables -A INPUT -p tcp --dport 22 -j ACCEPT
# View iptables rules
sudo iptables -L -v
Question 24: How do you configure RAID in Linux?
1. Question:
How do you configure RAID in Linux?
2. Answer:
RAID (Redundant Array of Independent Disks) improves performance and redundancy.
○ Install mdadm:
■ sudo apt install mdadm
○ Create RAID Array:
■ Example for RAID 1 (mirroring):
sudo mdadm --create --verbose /dev/md0 --level=1
--raid-devices=2 /dev/sd[b-c]
○ Check RAID Status:
■ cat /proc/mdstat
■ sudo mdadm --detail /dev/md0
○ Create File System and Mount:
■ sudo mkfs.ext4 /dev/md0
■ sudo mount /dev/md0 /mnt/raid
○ Save Configuration:
■ sudo mdadm --detail --scan | sudo tee -a
/etc/mdadm/mdadm.conf
■ Update initramfs: sudo update-initramfs -u
3. What Skills Required to Prepare This Question:
○ Understanding of RAID levels and their use cases
○ Familiarity with mdadm and disk management tools
○ Knowledge of redundancy and performance optimization
4. How to Study This Question:
○ Practice setting up different RAID levels
○ Study the pros and cons of various RAID configurations
○ Learn how to handle disk failures and RAID recovery
5. Examples for This Question:
Unset
# Install mdadm
sudo apt install mdadm
# Create RAID 1 array
sudo mdadm --create --verbose /dev/md0 --level=1 --raid-devices=2
/dev/sdb /dev/sdc
# Check RAID status
cat /proc/mdstat
sudo mdadm --detail /dev/md0
# Format and mount RAID
sudo mkfs.ext4 /dev/md0
sudo mount /dev/md0 /mnt/raid
Question 25: How do you troubleshoot network issues in Linux?
1. Question:
How do you troubleshoot network issues in Linux?
2. Answer:
Linux offers several tools to diagnose and troubleshoot network problems:
○ Check Network Interfaces:
■ ip addr or ifconfig to view IP addresses
■ ip link to view network interface status
○ Test Connectivity:
■ ping google.com to check external connectivity
■ ping 8.8.8.8 to check DNS issues
○ Check Routing and DNS:
■ ip route or route -n to view routing tables
■ cat /etc/resolv.conf to check DNS configuration
○ Analyze Network Traffic:
■ netstat -tuln or ss -tuln to list open ports
■ tcpdump or wireshark for packet analysis
○ Check Firewall Rules:
■ sudo iptables -L -v or sudo firewall-cmd --list-all
3. What Skills Required to Prepare This Question:
○ Understanding of network protocols (TCP/IP, DNS, etc.)
○ Familiarity with Linux networking tools
○ Ability to interpret network diagnostics
4. How to Study This Question:
○ Practice diagnosing real-world network issues
○ Study network troubleshooting flowcharts
○ Learn common causes of network failures in Linux
5. Examples for This Question:
Unset
# Check IP address and network interfaces
ip addr
# Test internet connectivity
ping google.com
# View routing table
ip route
# Check DNS settings
cat /etc/resolv.conf
# List open ports
ss -tuln
# Capture packets on eth0
sudo tcpdump -i eth0
Question 26: How do you create and manage logical volumes using LVM?
1. Question:
How do you create and manage logical volumes using LVM in Linux?
2. Answer:
LVM (Logical Volume Manager) allows flexible disk management.
○ Install LVM Tools:
■ sudo apt install lvm2
○ Create Physical Volumes (PV):
■ sudo pvcreate /dev/sd[b-c]
○ Create Volume Group (VG):
■ sudo vgcreate my_vg /dev/sd[b-c]
○ Create Logical Volume (LV):
■ sudo lvcreate -L 10G -n my_lv my_vg
○ Format and Mount:
■ sudo mkfs.ext4 /dev/my_vg/my_lv
■ sudo mkdir /mnt/my_lv
■ sudo mount /dev/my_vg/my_lv /mnt/my_lv
○ Extend Logical Volume:
■ sudo lvextend -L +5G /dev/my_vg/my_lv
■ sudo resize2fs /dev/my_vg/my_lv
3. What Skills Required to Prepare This Question:
○ Understanding of LVM concepts (PV, VG, LV)
○ Familiarity with disk partitioning and file systems
○ Ability to manage storage dynamically
4. How to Study This Question:
○ Practice creating and modifying LVM setups
○ Study LVM best practices and recovery methods
○ Learn to handle disk failures in LVM
5. Examples for This Question:
Unset
# Create physical volumes
sudo pvcreate /dev/sdb /dev/sdc
# Create volume group
sudo vgcreate data_vg /dev/sdb /dev/sdc
# Create logical volume
sudo lvcreate -L 20G -n data_lv data_vg
# Format and mount
sudo mkfs.ext4 /dev/data_vg/data_lv
sudo mount /dev/data_vg/data_lv /mnt/data
# Extend logical volume
sudo lvextend -L +10G /dev/data_vg/data_lv
sudo resize2fs /dev/data_vg/data_lv
Question 27: How do you secure a Linux server?
1. Question:
How do you secure a Linux server?
2. Answer:
Securing a Linux server involves multiple layers of protection:
○ User and Authentication Security:
■ Disable root SSH login: Edit /etc/ssh/sshd_config → PermitRootLogin
no
■ Enforce strong passwords and use SSH keys
○ Firewall and Network Security:
■ Use iptables or firewalld to restrict traffic
■ Close unnecessary ports and services
○ File and Directory Permissions:
■ Set appropriate permissions using chmod and chown
■ Use umask to define default permissions
○ Updates and Patching:
■ Regularly apply updates: sudo apt update && sudo apt upgrade
■ Automate updates using tools like unattended-upgrades
○ Intrusion Detection and Monitoring:
■ Install tools like fail2ban and tripwire
■ Monitor logs with logwatch or logrotate
3. What Skills Required to Prepare This Question:
○ Knowledge of Linux security best practices
○ Familiarity with authentication and firewall configurations
○ Understanding of intrusion detection and system monitoring
4. How to Study This Question:
○ Practice securing test servers
○ Study security hardening guides for Linux
○ Learn to perform security audits
5. Examples for This Question:
Unset
# Disable root SSH login
sudo sed -i 's/PermitRootLogin yes/PermitRootLogin no/'
/etc/ssh/sshd_config
sudo systemctl restart ssh
# Set up UFW firewall
sudo ufw enable
sudo ufw allow 22/tcp
sudo ufw allow 80/tcp
sudo ufw deny 23/tcp # Block Telnet
# Install and configure fail2ban
sudo apt install fail2ban
sudo systemctl enable fail2ban
Question 28: How do you set up passwordless SSH in Linux?
1. Question:
How do you set up passwordless SSH in Linux?
2. Answer:
Passwordless SSH allows users to authenticate using SSH keys instead of passwords.
○ Generate SSH Key Pair:
■ On the client machine: ssh-keygen -t rsa -b 4096
■ This generates a public (~/.ssh/id_rsa.pub) and private (~/.ssh/id_rsa)
key.
○ Copy Public Key to Remote Server:
■ Use ssh-copy-id: ssh-copy-id user@remote_server
■ Alternatively, manually copy:
Unset
cat ~/.ssh/id_rsa.pub | ssh user@remote_server 'cat >>
~/.ssh/authorized_keys'
○ Set Correct Permissions:
■ On the remote server:
Unset
chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys
○ Test Passwordless SSH:
■ ssh user@remote_server
3. What Skills Required to Prepare This Question:
○ Understanding of SSH protocols and key-based authentication
○ Familiarity with Linux permissions and user configurations
○ Basic networking knowledge
4. How to Study This Question:
○ Practice setting up passwordless SSH between systems
○ Study SSH configurations (/etc/ssh/sshd_config)
○ Learn to troubleshoot SSH connection issues
5. Examples for This Question:
Unset
# Generate SSH key
ssh-keygen -t rsa -b 4096
# Copy public key to server
ssh-copy-id user@192.168.1.100
# Test passwordless login
ssh user@192.168.1.100
Question 29: How do you manage and schedule tasks using cron in Linux?
1. Question:
How do you manage and schedule tasks using cron in Linux?
2. Answer:
Cron is a time-based job scheduler in Unix-like systems.
○ Edit Crontab:
■ crontab -e to edit the user's crontab file.
○ Crontab Syntax:
Unset
* * * * * command_to_execute
| | | | |
| | | | +----- Day of the week (0 - 7) [Sunday=0 or 7]
| | | +------- Month (1 - 12)
| | +--------- Day of the month (1 - 31)
| +----------- Hour (0 - 23)
+------------- Minute (0 - 59)
○ List and Remove Crontab Jobs:
■ crontab -l to list jobs
■ crontab -r to remove crontab
○ Common Cron Directories:
■ /etc/crontab, /etc/cron.d/, /etc/cron.daily/, /etc/cron.hourly/
3. What Skills Required to Prepare This Question:
○ Understanding of cron job scheduling
○ Familiarity with Linux file permissions
○ Basic shell scripting knowledge
4. How to Study This Question:
○ Practice creating and managing cron jobs
○ Study cron logs (/var/log/syslog or /var/log/cron)
○ Learn to debug and handle common cron errors
5. Examples for This Question:
Unset
# Open crontab
crontab -e
# Example jobs:
# Run backup script daily at 2 AM
0 2 * * * /home/user/backup.sh
# Clear temp files every Sunday at midnight
0 0 * * 0 rm -rf /tmp/*
# List current cron jobs
crontab -l
Question 30: How do you recover a Linux system with a forgotten root password?
1. Question:
How do you recover a Linux system with a forgotten root password?
2. Answer:
To reset a forgotten root password:
○ Boot into GRUB:
■ Restart the system and access GRUB menu (usually by pressing Esc or Shift).
○ Edit GRUB Entry:
■ Highlight the boot entry and press e to edit.
■ Find the line starting with linux and append init=/bin/bash.
○ Boot into Single-User Mode:
■ Press Ctrl + X or F10 to boot.
○ Remount Root Filesystem:
■ mount -o remount,rw /
○ Reset Password:
■ passwd root and enter a new password.
○ Reboot System:
■ exec /sbin/init or reboot
3. What Skills Required to Prepare This Question:
○ Understanding of GRUB and Linux boot processes
○ Familiarity with filesystem permissions
○ Knowledge of system recovery techniques
4. How to Study This Question:
○ Practice password recovery on a test system
○ Study Linux boot process and GRUB configurations
○ Learn security implications of this method
5. Examples for This Question:
Unset
# After booting into single-user mode
mount -o remount,rw /
# Reset root password
passwd root
# Reboot the system
reboot
Question 31: How do you configure a static IP address in Linux?
1. Question:
How do you configure a static IP address in Linux?
2. Answer:
Static IP configuration depends on the Linux distribution.
On Debian/Ubuntu-based systems:
○ Edit the network interfaces file:
Unset
sudo nano /etc/network/interfaces
○ Add the following:
Unset
auto eth0
iface eth0 inet static
address 192.168.1.100
netmask 255.255.255.0
gateway 192.168.1.1
dns-nameservers 8.8.8.8 8.8.4.4
○ Restart networking:
Unset
sudo systemctl restart networking
3.
On RHEL/CentOS-based systems:
○ Edit the interface configuration file:
Unset
sudo nano /etc/sysconfig/network-scripts/ifcfg-eth0
○ Update with:
Unset
BOOTPROTO=static
ONBOOT=yes
IPADDR=192.168.1.100
NETMASK=255.255.255.0
GATEWAY=192.168.1.1
DNS1=8.8.8.8
○ Restart network service:
Unset
sudo systemctl restart network
4.
What Skills Required to Prepare This Question:
○ Knowledge of Linux networking
○ Familiarity with network configuration files
○ Understanding of IP addressing and subnetting
5. How to Study This Question:
○ Practice static IP configuration on virtual machines
○ Study network configuration tools like netplan and nmcli
○ Learn basic networking concepts
6. Examples for This Question:
Unset
# Check current IP configuration
ip addr
# Apply new IP settings (Ubuntu)
sudo systemctl restart networking
# Verify static IP
ping google.com
Question 32: How do you monitor system performance in Linux?
1. Question:
How do you monitor system performance in Linux?
2. Answer:
Linux offers several tools to monitor system performance:
○ CPU Usage:
■ top or htop for real-time process monitoring
■ mpstat (from sysstat package) for CPU stats
○ Memory Usage:
■ free -h to view RAM usage
■ vmstat for virtual memory statistics
○ Disk Usage and I/O:
■ df -h to check disk space
■ du -sh /path/to/directory for directory size
■ iotop to monitor disk I/O
○ Network Monitoring:
■ iftop for real-time bandwidth usage
■ nload for network traffic
○ Overall System Health:
■ sar (from sysstat) for historical data
■ glances for an all-in-one system monitor
3. What Skills Required to Prepare This Question:
○ Understanding of Linux system resources
○ Familiarity with system monitoring tools
○ Ability to analyze performance data
4. How to Study This Question:
○ Use the tools regularly on active systems
○ Study performance tuning guides
○ Learn to identify system bottlenecks
5. Examples for This Question:
Unset
# Monitor CPU and memory
top
# Check disk usage
df -h
# View network usage
iftop
# Monitor overall system health
glances
Question 33: How do you configure a firewall using iptables in Linux?
1. Question:
How do you configure a firewall using iptables in Linux?
2. Answer:
iptables is a command-line firewall tool in Linux.
○ View Existing Rules:
Unset
sudo iptables -L -v
○
Basic Commands:
■ Allow SSH (port 22):
Unset
sudo iptables -A INPUT -p tcp --dport 22 -j ACCEPT
■ Allow HTTP (port 80):
Unset
sudo iptables -A INPUT -p tcp --dport 80 -j ACCEPT
■ Block an IP address:
Unset
sudo iptables -A INPUT -s 192.168.1.50 -j DROP
■ Drop all other incoming traffic:
Unset
sudo iptables -P INPUT DROP
○
Save and Persist Rules:
■ On Debian/Ubuntu:
Unset
sudo iptables-save > /etc/iptables/rules.v4
■ On CentOS/RHEL:
Unset
sudo service iptables save
3.
What Skills Required to Prepare This Question:
○ Knowledge of network protocols and ports
○ Familiarity with firewall concepts
○ Understanding of Linux security practices
4. How to Study This Question:
○ Practice configuring iptables on test systems
○ Study iptables rules syntax and chains
○ Learn about common firewall policies
5. Examples for This Question:
Unset
# Allow SSH and HTTP
sudo iptables -A INPUT -p tcp --dport 22 -j ACCEPT
sudo iptables -A INPUT -p tcp --dport 80 -j ACCEPT
# Block an IP
sudo iptables -A INPUT -s 203.0.113.1 -j DROP
# View rules
sudo iptables -L -v
# Save rules (Ubuntu)
sudo iptables-save > /etc/iptables/rules.v4
Question 34: How do you manage services using systemd in Linux?
1. Question:
How do you manage services using systemd in Linux?
2. Answer:
systemd is a system and service manager for Linux, controlling how services run.
○ Start/Stop/Restart a Service:
Unset
sudo systemctl start apache2
sudo systemctl stop apache2
sudo systemctl restart apache2
○
Enable/Disable Service at Boot:
Unset
sudo systemctl enable apache2
sudo systemctl disable apache2
○
Check Service Status:
Unset
sudo systemctl status apache2
○
Reload Systemd and Daemons:
Unset
sudo systemctl daemon-reload
○
List All Services:
Unset
systemctl list-units --type=service
3.
What Skills Required to Prepare This Question:
○ Knowledge of systemd and its components
○ Understanding of Linux service management
○ Familiarity with system boot processes
4. How to Study This Question:
○ Practice managing services on Linux systems
○ Study the structure of systemd unit files (/etc/systemd/system/)
○ Explore advanced options like creating custom services
5. Examples for This Question:
Unset
# Start and enable Nginx
sudo systemctl start nginx
sudo systemctl enable nginx
# Check status
sudo systemctl status nginx
# Reload systemd after changes
sudo systemctl daemon-reload
Question 35: How do you configure NFS (Network File System) in Linux?
1. Question:
How do you configure NFS (Network File System) in Linux?
2. Answer:
NFS allows file sharing between Linux systems over a network.
On NFS Server:
○ Install NFS:
Unset
sudo apt install nfs-kernel-server # Debian/Ubuntu
sudo yum install nfs-utils # RHEL/CentOS
○ Create a Shared Directory:
Unset
sudo mkdir -p /srv/nfs/shared
sudo chown nobody:nogroup /srv/nfs/shared
○ Edit Exports File:
Unset
sudo nano /etc/exports
/srv/nfs/shared 192.168.1.0/24(rw,sync,no_subtree_check)
○ Export Shares and Start NFS:
Unset
sudo exportfs -a
sudo systemctl restart nfs-server
3.
On NFS Client:
○ Install NFS Client:
Unset
sudo apt install nfs-common # Debian/Ubuntu
sudo yum install nfs-utils # RHEL/CentOS
○ Mount the NFS Share:
Unset
sudo mount 192.168.1.100:/srv/nfs/shared /mnt
○ Persist Mount in fstab:
Unset
echo "192.168.1.100:/srv/nfs/shared /mnt nfs defaults 0 0" | sudo tee
-a /etc/fstab
4.
What Skills Required to Prepare This Question:
○ Understanding of NFS protocol
○ Familiarity with network configurations and permissions
○ Knowledge of mounting and sharing file systems
5. How to Study This Question:
○ Practice setting up NFS on test machines
○ Study NFS options and security considerations (e.g., no_root_squash)
○ Learn troubleshooting NFS connectivity and permission issues
6. Examples for This Question:
Unset
# Server-side
sudo exportfs -v
# Client-side
sudo mount 192.168.1.100:/srv/nfs/shared /mnt
# Verify mount
df -h | grep nfs
Question 36: How do you set up RAID in Linux?
1. Question:
How do you set up RAID in Linux?
2. Answer:
RAID (Redundant Array of Independent Disks) enhances storage performance and redundancy.
○ Install mdadm (RAID utility):
Unset
sudo apt install mdadm # Debian/Ubuntu
sudo yum install mdadm # RHEL/CentOS
○
Create RAID Array (e.g., RAID 1):
Unset
sudo mdadm --create --verbose /dev/md0 --level=1 --raid-devices=2
/dev/sd[b-c]
○
Verify RAID Status:
Unset
cat /proc/mdstat
sudo mdadm --detail /dev/md0
○
Create Filesystem and Mount:
Unset
sudo mkfs.ext4 /dev/md0
sudo mkdir /mnt/raid
sudo mount /dev/md0 /mnt/raid
○
Persist RAID Configuration:
Unset
sudo mdadm --detail --scan | sudo tee -a /etc/mdadm/mdadm.conf
sudo update-initramfs -u
3.
What Skills Required to Prepare This Question:
○ Understanding of RAID levels and their use cases
○ Familiarity with disk partitioning and management
○ Knowledge of Linux storage and file systems
4. How to Study This Question:
○ Practice RAID setup using virtual disks
○ Study different RAID levels (0, 1, 5, 6, 10)
○ Learn to troubleshoot RAID failures and rebuild arrays
5. Examples for This Question:
Unset
# Create RAID 5 with 3 disks
sudo mdadm --create --verbose /dev/md0 --level=5 --raid-devices=3
/dev/sd[b-d]
# Check RAID status
cat /proc/mdstat
# Format and mount RAID
sudo mkfs.ext4 /dev/md0
sudo mount /dev/md0 /mnt/raid
Question 37: How do you set file permissions using chmod in Linux?
1. Question:
How do you set file permissions using chmod in Linux?
2. Answer:
The chmod command changes file and directory permissions in Linux.
○ Symbolic Method:
■ Grant read, write, and execute to the owner:
Unset
chmod u+rwx file.txt
■ Remove write permission from the group:
Unset
chmod g-w file.txt
■ Add execute for others:
Unset
chmod o+x script.sh
○
Numeric Method:
Permissions use a three-digit octal representation:
■ r = 4, w = 2, x = 1
■ Example: chmod 755 script.sh sets:
■ Owner: read, write, execute (7)
■ Group: read, execute (5)
■ Others: read, execute (5)
○ Recursive Permission Change:
Unset
chmod -R 755 /var/www/html
3.
What Skills Required to Prepare This Question:
○ Understanding of Linux file permission models
○ Familiarity with symbolic and numeric permission methods
○ Knowledge of security best practices
4. How to Study This Question:
○ Practice modifying permissions on files and directories
○ Study the differences between user, group, and others
○ Learn about potential security risks of incorrect permissions
5. Examples for This Question:
Unset
# Grant read, write to owner, read-only to others
chmod 644 file.txt
# Make a script executable by everyone
chmod 755 script.sh
# Remove all permissions for others
chmod o-rwx confidential.txt
Question 38: How do you manage users and groups in Linux?
1. Question:
How do you manage users and groups in Linux?
2. Answer:
Linux provides several commands for managing users and groups.
○ Add a New User:
Unset
sudo adduser john
○
Delete a User:
Unset
sudo deluser john
○
Modify a User (e.g., change shell):
Unset
sudo usermod -s /bin/bash john
○
Add User to a Group:
Unset
sudo usermod -aG sudo john
○
Create a Group:
Unset
sudo groupadd developers
○
Change File Ownership:
Unset
sudo chown john:developers project.txt
○
List User and Group Info:
Unset
id john
groups john
3.
What Skills Required to Prepare This Question:
○ Understanding of Linux user and group management
○ Familiarity with file permissions and ownership
○ Knowledge of security policies and user roles
4. How to Study This Question:
○ Practice adding, modifying, and deleting users and groups
○ Study the /etc/passwd, /etc/group, and /etc/shadow files
○ Learn about user access controls and privilege escalation
5. Examples for This Question:
Unset
# Add user and grant sudo privileges
sudo adduser alice
sudo usermod -aG sudo alice
# Change ownership of a directory
sudo chown -R alice:developers /home/alice/projects
# List all users
cut -d: -f1 /etc/passwd
Question 39: How do you troubleshoot network issues in Linux?
1. Question:
How do you troubleshoot network issues in Linux?
2. Answer:
Several tools help diagnose and fix network problems in Linux.
○ Check IP Configuration:
Unset
ip addr
ifconfig (older systems)
○
Test Connectivity:
Unset
ping google.com
○
Check Routing Table:
Unset
ip route
○
DNS Resolution Issues:
Unset
dig google.com
nslookup google.com
○
Trace Network Path:
Unset
traceroute google.com
○
Check Open Ports and Connections:
Unset
netstat -tuln
ss -tuln (newer systems)
○
Monitor Network Traffic:
Unset
tcpdump -i eth0
3.
What Skills Required to Prepare This Question:
○ Understanding of networking concepts (IP, DNS, routing)
○ Familiarity with Linux networking tools
○ Analytical and troubleshooting skills
4. How to Study This Question:
○ Simulate network issues in a lab environment
○ Study network layers and protocols (TCP/IP, UDP)
○ Practice using networking tools on live systems
5. Examples for This Question:
Unset
# Check default gateway
ip route | grep default
# Test if a specific port is open
telnet google.com 80
# Capture network packets
sudo tcpdump -i eth0 port 80
Question 40: How do you configure a firewall using UFW in Linux?
1. Question:
How do you configure a firewall using UFW in Linux?
2. Answer:
UFW (Uncomplicated Firewall) simplifies firewall management on Linux.
○ Install UFW (if not installed):
Unset
sudo apt install ufw
○
Enable/Disable UFW:
Unset
sudo ufw enable
sudo ufw disable
○
Allow/Deny Ports:
Unset
sudo ufw allow 22/tcp # Allow SSH
sudo ufw allow 80/tcp # Allow HTTP
sudo ufw deny 23 # Deny Telnet
○
Allow Specific IP:
Unset
sudo ufw allow from 192.168.1.100
○
Delete a Rule:
Unset
sudo ufw delete allow 80/tcp
○
View Firewall Status and Rules:
Unset
sudo ufw status verbose
3.
What Skills Required to Prepare This Question:
○ Understanding of Linux firewalls
○ Familiarity with network protocols and ports
○ Knowledge of UFW and iptables
4. How to Study This Question:
○ Practice configuring UFW on test systems
○ Study networking basics, including TCP/UDP protocols
○ Learn about firewall policies and best practices
5. Examples for This Question:
Unset
# Allow HTTPS traffic
sudo ufw allow 443/tcp
# Allow access to SSH from a specific IP
sudo ufw allow from 203.0.113.10 to any port 22
# Enable UFW with default deny policy
sudo ufw default deny incoming
sudo ufw default allow outgoing
sudo ufw enable
Question 41: How do you configure cron jobs in Linux?
1. Question:
How do you configure cron jobs in Linux?
2. Answer:
Cron is a time-based job scheduler in Unix-like systems.
○ Edit User’s Cron Table:
Unset
crontab -e
○
Cron Syntax:
Unset
* * * * * /path/to/command
| | | | |
| | | | +----- Day of the week (0 - 7) (Sunday=0 or 7)
| | | +------- Month (1 - 12)
| | +--------- Day of the month (1 - 31)
| +----------- Hour (0 - 23)
+------------- Minute (0 - 59)
○
View Scheduled Cron Jobs:
Unset
crontab -l
○
Remove All Cron Jobs for User:
Unset
crontab -r
○
Common Examples:
■ Run backup every day at 2 AM:
Unset
0 2 * * * /home/user/backup.sh
■ Clear logs every Sunday at midnight:
Unset
0 0 * * 0 /usr/bin/logrotate
3.
What Skills Required to Prepare This Question:
○ Understanding of cron syntax and scheduling
○ Familiarity with Linux commands and scripts
○ Basic knowledge of system maintenance tasks
4. How to Study This Question:
○ Practice creating and managing cron jobs
○ Study cron special strings (@daily, @hourly)
○ Learn about logging and troubleshooting cron jobs
5. Examples for This Question:
Unset
# Run a script every 15 minutes
*/15 * * * * /path/to/script.sh
# Update system packages daily at 3 AM
0 3 * * * sudo apt update && sudo apt upgrade -y
# Reboot system every Sunday at 1 AM
0 1 * * 0 /sbin/reboot
Question 42: How do you check system performance in Linux?
1. Question:
How do you check system performance in Linux?
2. Answer:
Linux offers several tools to monitor system performance.
○ CPU and Memory Usage:
Unset
top
htop # Enhanced version of top
○
Disk Usage:
Unset
df -h # Show disk space
du -sh /var # Show size of specific directories
○
I/O Performance:
Unset
iostat
vmstat
○
Network Performance:
Unset
iftop # Real-time network usage
nload # Network bandwidth usage
○
System Load:
Unset
uptime # Shows load average
cat /proc/loadavg
3.
What Skills Required to Prepare This Question:
○ Understanding of Linux performance monitoring
○ Familiarity with system resource management
○ Knowledge of key performance metrics
4. How to Study This Question:
○ Practice using system monitoring tools
○ Study Linux resource management (CPU, RAM, Disk, Network)
○ Learn how to troubleshoot performance bottlenecks
5. Examples for This Question:
Unset
# Check memory usage
free -m
# View top processes sorted by memory
ps aux --sort=-%mem | head
# Monitor disk I/O
iostat -xz 1
# Real-time network monitoring
iftop -i eth0
Question 43: How do you secure SSH access on a Linux server?
1. Question:
How do you secure SSH access on a Linux server?
2. Answer:
Securing SSH is crucial to prevent unauthorized access.
○ Change Default SSH Port:
Edit /etc/ssh/sshd_config:
Unset
Port 2222
○
Then restart SSH:
Unset
sudo systemctl restart sshd
○
Disable Root Login:
In /etc/ssh/sshd_config:
Unset
PermitRootLogin no
○
Use SSH Key Authentication:
Generate SSH key pair on client:
Unset
ssh-keygen
○
Copy public key to server:
Unset
ssh-copy-id user@server_ip
○
Use a Firewall to Limit Access:
Unset
sudo ufw allow 2222/tcp
○
Disable Password Authentication:
In /etc/ssh/sshd_config:
Unset
PasswordAuthentication no
3.
What Skills Required to Prepare This Question:
○ Understanding of SSH configuration
○ Knowledge of Linux security practices
○ Familiarity with networking and firewalls
4. How to Study This Question:
○ Practice configuring SSH settings in a lab environment
○ Study public/private key encryption
○ Learn about firewall rules and network security
5. Examples for This Question:
Unset
# Connect to SSH on a custom port
ssh -p 2222 user@server_ip
# View current SSH connections
sudo ss -tnp | grep ssh
# Restrict SSH access to a specific IP
sudo ufw allow from 192.168.1.100 to any port 2222
Question 44: How do you manage disk partitions in Linux?
1. Question:
How do you manage disk partitions in Linux?
2. Answer:
Disk partitioning can be done using tools like fdisk, parted, and lsblk.
○ List Disks and Partitions:
Unset
lsblk
fdisk -l
○
Create a New Partition Using fdisk:
Unset
sudo fdisk /dev/sdb
■ Press n to create a new partition
■ Press w to write changes
○ Format the New Partition:
Unset
sudo mkfs.ext4 /dev/sdb1
○
Mount the Partition:
Unset
sudo mkdir /mnt/newdisk
sudo mount /dev/sdb1 /mnt/newdisk
○
Make the Mount Permanent:
Add to /etc/fstab:
Unset
/dev/sdb1 /mnt/newdisk ext4 defaults 0 2
3.
What Skills Required to Prepare This Question:
○ Understanding of disk partitioning
○ Familiarity with Linux filesystems
○ Knowledge of mount points and fstab
4. How to Study This Question:
○ Practice partitioning disks on test systems
○ Study file system types (ext4, xfs)
○ Learn about disk management best practices
5. Examples for This Question:
Unset
# Check disk space usage
df -h
# Check partition UUID
blkid
# Resize a partition (example with parted)
sudo parted /dev/sdb resizepart 1 100GB
Question 45: How do you set up NFS (Network File System) on Linux?
1. Question:
How do you set up NFS (Network File System) on Linux?
2. Answer:
NFS allows sharing directories over a network.
○ Install NFS Packages:
Unset
sudo apt install nfs-kernel-server nfs-common
○
Configure NFS Exports:
Edit /etc/exports:
Unset
/srv/nfs/shared 192.168.1.0/24(rw,sync,no_subtree_check)
○
Apply Export Changes:
Unset
sudo exportfs -a
sudo systemctl restart nfs-kernel-server
○
Allow NFS Through Firewall:
Unset
sudo ufw allow from 192.168.1.0/24 to any port nfs
○
Mount NFS Share on Client:
Unset
sudo mount server_ip:/srv/nfs/shared /mnt
○
Make Mount Permanent on Client:
Add to /etc/fstab:
Unset
server_ip:/srv/nfs/shared /mnt nfs defaults 0 0
3.
What Skills Required to Prepare This Question:
○ Understanding of NFS and file sharing
○ Knowledge of Linux networking and firewalls
○ Familiarity with mounting file systems
4. How to Study This Question:
○ Practice setting up NFS in a lab environment
○ Study NFS security settings (e.g., no_root_squash)
○ Learn about NFS performance tuning
5. Examples for This Question:
Unset
# View active NFS shares
showmount -e server_ip
# Unmount an NFS share
sudo umount /mnt
# Check NFS mounts
mount | grep nfs
Question 46: How do you configure RAID in Linux?
1. Question:
How do you configure RAID in Linux?
2. Answer:
RAID (Redundant Array of Independent Disks) can be configured using the mdadm tool.
○ Install mdadm:
Unset
sudo apt install mdadm
○
Create a RAID 1 Array (Mirroring):
Unset
sudo mdadm --create --verbose /dev/md0 --level=1 --raid-devices=2
/dev/sd[b-c]1
○
Verify RAID Status:
Unset
cat /proc/mdstat
sudo mdadm --detail /dev/md0
○
Format the RAID Array:
Unset
sudo mkfs.ext4 /dev/md0
○
Mount the RAID Array:
Unset
sudo mkdir /mnt/raid
sudo mount /dev/md0 /mnt/raid
○
Save RAID Configuration:
Unset
sudo mdadm --detail --scan | sudo tee -a /etc/mdadm/mdadm.conf
sudo update-initramfs -u
3.
What Skills Required to Prepare This Question:
○ Understanding of RAID levels (0, 1, 5, 10)
○ Familiarity with mdadm and disk management
○ Knowledge of redundancy and performance optimization
4. How to Study This Question:
○ Practice setting up different RAID levels
○ Study the pros and cons of each RAID configuration
○ Learn RAID failure recovery and monitoring
5. Examples for This Question:
Unset
# Create RAID 0 (striping)
sudo mdadm --create --verbose /dev/md0 --level=0 --raid-devices=2
/dev/sd[b-c]1
# Monitor RAID array
watch cat /proc/mdstat
# Stop and remove a RAID array
sudo umount /mnt/raid
sudo mdadm --stop /dev/md0
sudo mdadm --remove /dev/md0
Question 47: How do you configure SELinux in Linux?
1. Question:
How do you configure SELinux in Linux?
2. Answer:
SELinux (Security-Enhanced Linux) adds a security layer through mandatory access control.
○ Check SELinux Status:
Unset
sestatus
getenforce
○
Set SELinux Modes:
■ Enforcing: SELinux policies are applied
■ Permissive: SELinux logs actions but doesn’t enforce
■ Disabled: SELinux is turned off
○ Change mode temporarily:
Unset
sudo setenforce 0 # Permissive
sudo setenforce 1 # Enforcing
○
Change mode permanently (edit /etc/selinux/config):
Unset
SELINUX=enforcing
SELINUX=permissive
SELINUX=disabled
○
Manage SELinux Contexts:
Unset
ls -Z /var/www/html
sudo chcon -t httpd_sys_content_t /var/www/html/index.html
○
Manage Policies with semanage:
Unset
sudo semanage port -a -t http_port_t -p tcp 8080
3.
What Skills Required to Prepare This Question:
○ Understanding of SELinux policies and modes
○ Familiarity with Linux security practices
○ Knowledge of labeling and context management
4. How to Study This Question:
○ Practice managing SELinux contexts and policies
○ Study logs (/var/log/audit/audit.log) for troubleshooting
○ Learn SELinux modules and policy writing basics
5. Examples for This Question:
Unset
# Allow Apache to connect to the network
sudo setsebool -P httpd_can_network_connect on
# Restore default SELinux context for a directory
sudo restorecon -Rv /var/www/html
# List SELinux booleans
getsebool -a
Question 48: How do you manage software packages in Linux?
1. Question:
How do you manage software packages in Linux?
2. Answer:
Linux has multiple package managers based on the distribution.
○ Debian/Ubuntu (APT):
■ Update package list:
Unset
sudo apt update
■ Install a package:
Unset
sudo apt install nginx
■ Remove a package:
Unset
sudo apt remove nginx
■ Upgrade all packages:
Unset
sudo apt upgrade
○
RedHat/CentOS (YUM/DNF):
■ Install a package:
Unset
sudo dnf install httpd
■ Remove a package:
Unset
sudo dnf remove httpd
■ List installed packages:
Unset
sudo dnf list installed
○
Universal Package Managers:
■ Snap:
Unset
sudo snap install vlc
■ Flatpak:
Unset
flatpak install flathub org.gimp.GIMP
3.
What Skills Required to Prepare This Question:
○ Familiarity with package managers (APT, YUM, DNF)
○ Understanding of repositories and package sources
○ Knowledge of software dependencies and conflicts
4. How to Study This Question:
○ Practice installing, updating, and removing packages
○ Study repository management and adding PPAs
○ Learn about troubleshooting broken dependencies
5. Examples for This Question:
Unset
# Clean APT cache
sudo apt clean
# List outdated packages
sudo apt list --upgradable
# Search for a package in DNF
sudo dnf search nginx
Question 49: How do you configure a firewall using UFW in Linux?
1. Question:
How do you configure a firewall using UFW in Linux?
2. Answer:
UFW (Uncomplicated Firewall) is a user-friendly interface for managing iptables firewall
rules.
○ Enable UFW:
Unset
sudo ufw enable
○
Check Firewall Status:
Unset
sudo ufw status verbose
○
Allow Specific Ports/Services:
Unset
sudo ufw allow 22/tcp # SSH
sudo ufw allow 80/tcp # HTTP
sudo ufw allow 443/tcp # HTTPS
○
Deny Access:
Unset
sudo ufw deny 23/tcp # Deny Telnet
○
Allow Specific IPs:
Unset
sudo ufw allow from 192.168.1.100 to any port 22
○
Enable Logging:
Unset
sudo ufw logging on
○
Disable UFW:
Unset
sudo ufw disable
3.
What Skills Required to Prepare This Question:
○ Understanding of network ports and protocols
○ Familiarity with Linux firewall tools (UFW, iptables)
○ Basic networking and security principles
4. How to Study This Question:
○ Practice configuring UFW rules in a lab environment
○ Study the effects of different rules and policies
○ Learn how to troubleshoot blocked connections
5. Examples for This Question:
Unset
# Allow a specific subnet
sudo ufw allow from 192.168.1.0/24
# Delete a firewall rule
sudo ufw delete allow 80/tcp
# Set default policies
sudo ufw default deny incoming
sudo ufw default allow outgoing
Question 50: How do you schedule tasks using cron in Linux?
1. Question:
How do you schedule tasks using cron in Linux?
2. Answer:
The cron service is used to schedule repetitive tasks.
○ Edit the Crontab:
Unset
crontab -e
○
Crontab Syntax:
Unset
* * * * * command_to_run
| | | | |
| | | | +---- Day of the week (0 - 6) (Sunday=0)
| | | +------ Month (1 - 12)
| | +-------- Day of the month (1 - 31)
| +---------- Hour (0 - 23)
+------------ Minute (0 - 59)
○
Example Cron Jobs:
■ Run a script every day at midnight:
Unset
0 0 * * * /path/to/script.sh
■ Run a command every 5 minutes:
Unset
*/5 * * * * /path/to/command
○
List Current Cron Jobs:
Unset
crontab -l
○
Remove Cron Jobs:
Unset
crontab -r
3.
What Skills Required to Prepare This Question:
○ Understanding of time-based scheduling in Linux
○ Familiarity with cron syntax and scheduling logic
○ Basic shell scripting
4. How to Study This Question:
○ Practice creating and editing cron jobs
○ Study common cron use cases and pitfalls
○ Learn about cron logs (/var/log/syslog) for troubleshooting
5. Examples for This Question:
Unset
# Run a backup script every Sunday at 2 AM
0 2 * * 0 /path/to/backup.sh
# Clear /tmp directory daily at midnight
0 0 * * * rm -rf /tmp/*
# Redirect cron output to a log file
0 3 * * * /path/to/script.sh >> /var/log/script.log 2>&1
Question 51: How do you check system performance and resource usage in Linux?
1. Question:
How do you check system performance and resource usage in Linux?
2. Answer:
Various commands can monitor system resources and performance.
○ CPU and Memory Usage:
Unset
top
htop # (more user-friendly, if installed)
○
Disk Usage:
Unset
df -h # Show disk space usage
du -sh * # Show directory sizes
○
I/O Performance:
Unset
iostat # Requires sysstat package
○
Network Usage:
Unset
iftop # Real-time bandwidth monitoring
netstat -tulnp
○
System Load:
Unset
uptime
○
Check Running Processes:
Unset
ps aux
3.
What Skills Required to Prepare This Question:
○ Familiarity with Linux performance monitoring tools
○ Understanding of system resource management
○ Knowledge of performance bottlenecks
4. How to Study This Question:
○ Practice using performance monitoring commands
○ Study how to identify high resource usage processes
○ Learn about system tuning for performance
5. Examples for This Question:
Unset
# Find top memory-consuming processes
ps aux --sort=-%mem | head
# Check open network connections
ss -tuln
# Monitor real-time disk I/O
iotop