Linux MCQs (101-200)

Linux 200 MCQs | Linux Commands For Exam | P-2

  1. The first program that runs when a Linux system boots is:
    A) init
    B) kernel
    C) grub
    D) bios
    Answer: D

  2. The Linux bootloader is typically:
    A) GRUB
    B) LILO
    C) Syslinux
    D) All of the above
    Answer: D

  3. The /boot directory contains:
    A) Kernel and boot loader files
    B) Configuration files
    C) User data
    D) Temporary files
    Answer: A

  4. The init process ID (PID) is always:
    A) 1
    B) 0
    C) 100
    D) 10
    Answer: A

  5. To switch runlevels in traditional init system:
    A) telinit [runlevel]
    B) changerun [level]
    C) initrun [level]
    D) runlevel [set]
    Answer: A

  6. The default target in systemd replaces:
    A) Runlevels
    B) Sessions
    C) Processes
    D) Mount points
    Answer: A

  7. Command to list all systemd services:
    A) systemctl list-units –type=service
    B) service –list
    C) systemctl show
    D) initctl list
    Answer: A

  8. Command to start a service:
    A) systemctl start servicename
    B) start servicename
    C) run servicename
    D) servicectl start
    Answer: A

  9. To enable a service at boot:
    A) systemctl enable servicename
    B) systemctl add servicename
    C) service autostart servicename
    D) enable service
    Answer: A

  10. To stop and disable a service permanently:
    A) systemctl stop servicename && systemctl disable servicename
    B) service remove servicename
    C) stop service
    D) systemctl erase servicename
    Answer: A

  1. Command to check CPU info:
    A) cat /proc/cpuinfo
    B) lscpu
    C) top
    D) All of the above
    Answer: D

  2. Command to list block devices:
    A) lsblk
    B) blkid
    C) fdisk -l
    D) All of the above
    Answer: D

  3. To display kernel messages:
    A) dmesg
    B) syslog
    C) showmsg
    D) kernlog
    Answer: A

  4. To view PCI devices:
    A) lspci
    B) lsusb
    C) lsdev
    D) hwinfo
    Answer: A

  5. To view USB devices:
    A) lsusb
    B) usbinfo
    C) usbview
    D) showusb
    Answer: A

  6. To list loaded kernel modules:
    A) lsmod
    B) modlist
    C) modshow
    D) showmod
    Answer: A

  7. To load a kernel module:
    A) modprobe modulename
    B) insmod modulename
    C) loadmod modulename
    D) kmod modulename
    Answer: A

  8. To remove a kernel module:
    A) rmmod modulename
    B) modprobe -r modulename
    C) Both A and B
    D) unload modulename
    Answer: C

  9. The directory containing device files:
    A) /dev
    B) /sys
    C) /proc
    D) /etc
    Answer: A

  10. Virtual files representing system info are found in:
    A) /proc
    B) /sys
    C) /var
    D) /root
    Answer: A)

  11. Command to restart the network service:
    A) systemctl restart network
    B) service network restart
    C) systemctl restart NetworkManager
    D) Any of the above
    Answer: D

  1. To assign an IP address manually:
    A) ifconfig eth0 192.168.1.10
    B) ip addr add 192.168.1.10 dev eth0
    C) nmcli dev modify eth0 ip4 192.168.1.10
    D) All of the above
    Answer: D

  2. Command to show routing information:
    A) route -n
    B) ip route show
    C) netstat -r
    D) All of the above
    Answer: D

  3. To test port connectivity:
    A) telnet host port
    B) nc host port
    C) nmap host
    D) All of the above
    Answer: D

  4. To view active network interfaces:
    A) ip link show
    B) ifconfig -a
    C) nmcli dev status
    D) All of the above
    Answer: D

  5. To bring up a network interface:
    A) ifup eth0
    B) ip link set eth0 up
    C) nmcli dev connect eth0
    D) All of the above
    Answer: D

  6. To bring down an interface:
    A) ifdown eth0
    B) ip link set eth0 down
    C) nmcli dev disconnect eth0
    D) All of the above
    Answer: D

  7. To display hostname and domain:
    A) hostnamectl
    B) hostname
    C) domainname
    D) All of the above
    Answer: D

  8. To view open ports:
    A) netstat -tuln
    B) ss -tuln
    C) lsof -i
    D) All of the above
    Answer: D

  9. To configure a static IP permanently:
    A) Edit /etc/network/interfaces or /etc/sysconfig/network-scripts/
    B) Use nmcli
    C) Use nmtui
    D) All of the above
    Answer: D

  1. The superuser account in Linux is:
    A) root
    B) admin
    C) super
    D) sys
    Answer: A

  2. File ownership can be changed recursively using:
    A) chown -R
    B) chgrp -R
    C) chmod -R
    D) All of the above
    Answer: A

  3. The sudo command is configured via:
    A) /etc/sudoers
    B) /etc/passwd
    C) /root/sudo
    D) /etc/shadow
    Answer: A

  4. To edit sudo configuration safely:
    A) visudo
    B) edit /etc/sudoers
    C) nano sudoers
    D) sudoedit
    Answer: A

  5. SELinux stands for:
    A) Security-Enhanced Linux
    B) System Enforced Linux
    C) Secure Environment Linux
    D) Security Environment Layer
    Answer: A

  6. To check SELinux status:
    A) sestatus
    B) getenforce
    C) Both A and B
    D) checkselinux
    Answer: C

  7. To temporarily disable SELinux:
    A) setenforce 0
    B) selinuxoff
    C) disable selinux
    D) stop selinux
    Answer: A

  8. SELinux configuration file is located at:
    A) /etc/selinux/config
    B) /var/selinux/config
    C) /usr/config/selinux
    D) /root/selinux.cfg
    Answer: A

  9. To generate SSH keys:
    A) ssh-keygen
    B) ssh-add
    C) genkey
    D) sshconfig
    Answer: A

  10. Default SSH configuration file:
    A) /etc/ssh/sshd_config
    B) /root/ssh.conf
    C) /etc/ssh/config
    D) /var/ssh/settings
    Answer: A

  1. To test if a file exists in a shell script:
    A) [ -f filename ]
    B) test -f filename
    C) [[ -f filename ]]
    D) All of the above
    Answer: D

  2. To test directory existence:
    A) [ -d directory ]
    B) test -d directory
    C) [[ -d directory ]]
    D) All of the above
    Answer: D

  3. To compare strings:
    A) [ “$a” = “$b” ]
    B) test $a == $b
    C) [[ “$a” == “$b” ]]
    D) All of the above
    Answer: D

  4. To perform arithmetic in shell:
    A) $((a+b))
    B) expr a + b
    C) let c=a+b
    D) All of the above
    Answer: D

  5. In shell scripting, #!/bin/bash is called:
    A) Shebang
    B) Header
    C) Directive
    D) Prefix
    Answer: A

  6. To exit a script with success:
    A) exit 0
    B) exit 1
    C) quit
    D) return 0
    Answer: A

  7. To define a function:
    A) function name { commands }
    B) name() { commands }
    C) Both A and B
    D) define function name
    Answer: C

  8. To execute commands conditionally:
    A) if [ condition ]; then … fi
    B) while [ condition ]; do … done
    C) case $var in …) esac
    D) All of the above
    Answer: D

  9. To loop through a list:
    A) for item in list; do … done
    B) loop item list
    C) foreach item list
    D) until list done
    Answer: A

  10. The $# variable gives:
    A) Number of arguments passed to script
    B) Script name
    C) Return code
    D) Command count
    Answer: A

  1. Command to create a tar archive:
    A) tar -cvf file.tar files
    B) zip file.tar files
    C) arch file.tar files
    D) tar -c file.tar
    Answer: A

  2. To extract a tar archive:
    A) tar -xvf file.tar
    B) unzip file.tar
    C) untar file.tar
    D) open file.tar
    Answer: A

  3. To compress a tar file with gzip:
    A) tar -czvf file.tar.gz files
    B) tar -z file.tar files
    C) gzip file.tar
    D) zip file.tar
    Answer: A

  4. To extract a .tar.gz file:
    A) tar -xzvf file.tar.gz
    B) unzip file.tar.gz
    C) gunzip file.tar.gz
    D) extract file.tar.gz
    Answer: A

  5. To compress files using bzip2:
    A) bzip2 filename
    B) gzip filename
    C) tar filename
    D) zip filename
    Answer: A

  6. To decompress .bz2 file:
    A) bunzip2 filename
    B) unzip filename
    C) extract filename
    D) tar -x filename
    Answer: A

  7. To create a zip file:
    A) zip file.zip files
    B) compress file.zip files
    C) gzip -z file.zip
    D) archive file.zip
    Answer: A

  8. To extract a zip file:
    A) unzip file.zip
    B) extract file.zip
    C) zip -x file.zip
    D) gunzip file.zip
    Answer: A

  9. To view contents of tar file:
    A) tar -tvf file.tar
    B) tar -v file.tar
    C) cat file.tar
    D) list file.tar
    Answer: A

  10. To compress a directory recursively:
    A) tar -czvf dir.tar.gz dir
    B) zip -r dir.zip dir
    C) Both A and B
    D) gzip dir
    Answer: C

  1. Default shell prompt for root user:
    A) #
    B) $
    C) >
    D) &
    Answer: A

  2. Default shell prompt for normal user:
    A) $
    B) #
    C) @
    D) %
    Answer: A

  3. Command to change system date:
    A) date -s “YYYY-MM-DD”
    B) setdate
    C) settime
    D) changetime
    Answer: A

  4. To check uptime and logged-in users:
    A) w
    B) who
    C) uptime
    D) All of the above
    Answer: D

  5. To list recently used commands:
    A) history
    B) lastcmd
    C) cmdlog
    D) cmdhis
    Answer: A

  6. To re-execute the previous command:
    A) !!
    B) history -r
    C) exec prev
    D) run last
    Answer: A

  7. Command to clear terminal screen:
    A) clear
    B) cls
    C) reset
    D) Both A and C
    Answer: D

  8. To find the path of a command:
    A) which command
    B) whereis command
    C) type command
    D) All of the above
    Answer: D

  9. To schedule a one-time task:
    A) at
    B) cron
    C) schedule
    D) once
    Answer: A

  10. To remove an at job:
    A) atrm jobid
    B) remove jobid
    C) atdel jobid
    D) job -r jobid
    Answer: A

  11. The command used to locate binary, source, and man page files:
    A) whereis
    B) locate
    C) find
    D) which
    Answer: A

  12. Command to find files by name:
    A) find / -name filename
    B) locate filename
    C) Both A and B
    D) grep filename
    Answer: C

  13. To find files modified within the last 24 hours:
    A) find / -mtime -1
    B) ls -lt
    C) locate recent
    D) search new
    Answer: A

  14. To find large files:
    A) find / -size +100M
    B) du -sh
    C) locate big
    D) search large
    Answer: A

  15. To check file type:
    A) file filename
    B) type filename
    C) ls -t
    D) show filename
    Answer: A

  16. Command to display environment variables:
    A) env
    B) printenv
    C) set
    D) All of the above
    Answer: D

  17. To view the PATH variable:
    A) echo $PATH
    B) showpath
    C) getenv PATH
    D) listpath
    Answer: A

  18. To append a directory to PATH:
    A) export PATH=$PATH:/new/dir
    B) set PATH=/new/dir
    C) addpath /new/dir
    D) path + /new/dir
    Answer: A

  19. To view default runlevel or target:
    A) systemctl get-default
    B) runlevel
    C) both A and B
    D) showlevel
    Answer: C

  20. To change default runlevel or target:
    A) systemctl set-default targetname
    B) changetarget targetname
    C) setlevel targetname
    D) init targetname
    Answer: A

  1. The man command is used for:
    A) Displaying manual pages
    B) Managing users
    C) Mounting devices
    D) Viewing logs
    Answer: A

  2. To search inside man pages:
    A) man -k keyword
    B) man -s keyword
    C) searchman keyword
    D) grepman keyword
    Answer: A

  3. To create a symbolic link:
    A) ln -s target linkname
    B) link target linkname
    C) symlink target linkname
    D) mklink target linkname
    Answer: A

  4. To create a hard link:
    A) ln target linkname
    B) link target linkname
    C) mklink -h target linkname
    D) cp target linkname
    Answer: A

  5. The maximum number of hard links to a file is limited by:
    A) File system
    B) Kernel version
    C) Disk type
    D) Permissions
    Answer: A

  6. Command to compare two files:
    A) diff file1 file2
    B) cmp file1 file2
    C) comm file1 file2
    D) All of the above
    Answer: D

  7. To merge file differences:
    A) patch
    B) merge
    C) diffmerge
    D) join
    Answer: A

  8. Command to join two files by common field:
    A) join
    B) merge
    C) cat
    D) paste
    Answer: A

  9. Command to display specific columns:
    A) cut -f
    B) awk ‘{print $1}’
    C) Both A and B
    D) grep
    Answer: C

  10. To replace text patterns:
    A) sed ‘s/old/new/g’
    B) awk ‘sub(“old”,”new”)’
    C) Both A and B
    D) grep -r
    Answer: C

  11. To sort lines in a file:
    A) sort filename
    B) order filename
    C) seq filename
    D) arrange filename
    Answer: A

  12. To remove duplicate lines:
    A) uniq filename
    B) sort -u filename
    C) Both A and B
    D) rmdup filename
    Answer: C

  13. Command to display disk usage of each directory:
    A) du -h –max-depth=1
    B) df -h
    C) ls -lh
    D) showdisk
    Answer: A

  14. To display active users and their processes:
    A) w
    B) who
    C) ps -u
    D) users
    Answer: A

  15. To reboot immediately:
    A) reboot
    B) shutdown -r now
    C) systemctl reboot
    D) All of the above
    Answer: D

  16. To power off the system:
    A) poweroff
    B) shutdown -h now
    C) halt
    D) All of the above
    Answer: D

    1. Default text editor in many Linux distributions is:
      A) vi or vim
      B) nano
      C) gedit
      D) emacs
      Answer: A

    2. To open a file in vi editor in command mode:
      A) vi filename
      B) open filename
      C) edit filename
      D) vim -e filename
      Answer: A

    3. Command to save and exit in vi editor:
      A) :wq
      B) 😡
      C) ZZ
      D) All of the above
      Answer: D

    4. To quit vi without saving changes:
      A) :q!
      B) :q
      C) :exit
      D) :quit
      Answer: A

LINUX PART 1 CLICK HERE

Leave a Comment

Your email address will not be published. Required fields are marked *

You cannot copy content of this page

Scroll to Top