Common Linux Interview Questions Quiz Quiz

Challenge your understanding of key Linux concepts with this focused quiz designed for job interviews. Improve your grasp of vital Linux commands, system management, and troubleshooting techniques commonly explored in technical assessments.

  1. Understanding Permissions

    Which command would you use to change the permissions of a file named 'report.txt' to allow the owner to read and write, but only allow others to read it?

    1. chmod rwx report.txt
    2. chmod 644 report.txt
    3. chown 644 report.txt
    4. perm 644 report.txt

    Explanation: The correct command is 'chmod 644 report.txt', which sets read and write permissions for the owner, and read-only permissions for group and others. 'chown 644 report.txt' is incorrect because 'chown' changes file ownership, not permissions. 'perm 644 report.txt' is not a valid command in Linux. 'chmod rwx report.txt' attempts to set all permissions for the owner, but fails to specify permissions for group or others and does not use the numeric notation.

  2. Process Management

    What is the effect of the 'kill -9' command when used with a process ID, such as 'kill -9 1234'?

    1. It restarts the process automatically.
    2. It gracefully requests the process to exit.
    3. It pauses the process until resumed.
    4. It forces the process to terminate immediately.

    Explanation: Using 'kill -9' sends the SIGKILL signal, which immediately terminates the target process without allowing cleanup. Option A describes SIGTERM, which allows for a graceful shutdown. Option C is a misconception, as 'kill -9' does not restart processes. Option D describes the effect of SIGSTOP, not SIGKILL.

  3. Text Searching

    Suppose you need to find all lines containing the word 'error' (case-insensitive) in a log file called 'system.log'. Which command is most appropriate?

    1. grep -i error system.log
    2. search error system.log
    3. find -i error system.log
    4. grep error -c system.log

    Explanation: 'grep -i error system.log' is the correct command, as the '-i' flag makes the search case-insensitive. 'find -i error system.log' is incorrect because 'find' is used for locating files, not searching inside them. 'search error system.log' is not a valid command. 'grep error -c system.log' returns a count of matching lines but does not display the lines themselves, and the position of '-c' is incorrect.

  4. Disk Space Check

    Which command provides a human-readable summary of current disk space usage on all mounted filesystems?

    1. du -k
    2. ls -lh
    3. df -h
    4. fdisk -h

    Explanation: 'df -h' summarizes disk usage for all mounted filesystems in a human-readable format, displaying sizes in kilobytes, megabytes, etc. 'du -k' shows space used by files and directories, not overall filesystem usage. 'ls -lh' lists files with sizes in human-readable format but doesn't summarize disk space. 'fdisk -h' is not a valid command, and 'fdisk' is used for partitioning disks.

  5. System Startup

    If you want to run a script automatically each time the system boots, which file should you generally add the script to on a traditional Linux system using the SysVinit process?

    1. /etc/bashrc
    2. /home/user/.bash_profile
    3. /root/scripts/startup.sh
    4. /etc/rc.local

    Explanation: /etc/rc.local is typically used on SysVinit systems for scripts that need to run at the end of the boot process. /etc/bashrc is executed when a new shell session starts, not at system boot. /home/user/.bash_profile is for user logins and doesn't apply to system-wide boots. /root/scripts/startup.sh is just a location and not automatically executed unless referenced by a proper startup script.