Linux MCQs (101-200)
Linux 200 MCQs | Linux Commands For Exam | P-2
The first program that runs when a Linux system boots is:
A) init
B) kernel
C) grub
D) bios
Answer: DThe Linux bootloader is typically:
A) GRUB
B) LILO
C) Syslinux
D) All of the above
Answer: DThe
/bootdirectory contains:
A) Kernel and boot loader files
B) Configuration files
C) User data
D) Temporary files
Answer: AThe
initprocess ID (PID) is always:
A) 1
B) 0
C) 100
D) 10
Answer: ATo switch runlevels in traditional init system:
A) telinit [runlevel]
B) changerun [level]
C) initrun [level]
D) runlevel [set]
Answer: AThe default target in
systemdreplaces:
A) Runlevels
B) Sessions
C) Processes
D) Mount points
Answer: ACommand to list all systemd services:
A) systemctl list-units –type=service
B) service –list
C) systemctl show
D) initctl list
Answer: ACommand to start a service:
A) systemctl start servicename
B) start servicename
C) run servicename
D) servicectl start
Answer: ATo enable a service at boot:
A) systemctl enable servicename
B) systemctl add servicename
C) service autostart servicename
D) enable service
Answer: ATo 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
Command to check CPU info:
A) cat /proc/cpuinfo
B) lscpu
C) top
D) All of the above
Answer: DCommand to list block devices:
A) lsblk
B) blkid
C) fdisk -l
D) All of the above
Answer: DTo display kernel messages:
A) dmesg
B) syslog
C) showmsg
D) kernlog
Answer: ATo view PCI devices:
A) lspci
B) lsusb
C) lsdev
D) hwinfo
Answer: ATo view USB devices:
A) lsusb
B) usbinfo
C) usbview
D) showusb
Answer: ATo list loaded kernel modules:
A) lsmod
B) modlist
C) modshow
D) showmod
Answer: ATo load a kernel module:
A) modprobe modulename
B) insmod modulename
C) loadmod modulename
D) kmod modulename
Answer: ATo remove a kernel module:
A) rmmod modulename
B) modprobe -r modulename
C) Both A and B
D) unload modulename
Answer: CThe directory containing device files:
A) /dev
B) /sys
C) /proc
D) /etc
Answer: AVirtual files representing system info are found in:
A) /proc
B) /sys
C) /var
D) /root
Answer: A)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
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: DCommand to show routing information:
A) route -n
B) ip route show
C) netstat -r
D) All of the above
Answer: DTo test port connectivity:
A) telnet host port
B) nc host port
C) nmap host
D) All of the above
Answer: DTo view active network interfaces:
A) ip link show
B) ifconfig -a
C) nmcli dev status
D) All of the above
Answer: DTo 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: DTo bring down an interface:
A) ifdown eth0
B) ip link set eth0 down
C) nmcli dev disconnect eth0
D) All of the above
Answer: DTo display hostname and domain:
A) hostnamectl
B) hostname
C) domainname
D) All of the above
Answer: DTo view open ports:
A) netstat -tuln
B) ss -tuln
C) lsof -i
D) All of the above
Answer: DTo configure a static IP permanently:
A) Edit/etc/network/interfacesor/etc/sysconfig/network-scripts/
B) Use nmcli
C) Use nmtui
D) All of the above
Answer: D
The superuser account in Linux is:
A) root
B) admin
C) super
D) sys
Answer: AFile ownership can be changed recursively using:
A) chown -R
B) chgrp -R
C) chmod -R
D) All of the above
Answer: AThe
sudocommand is configured via:
A) /etc/sudoers
B) /etc/passwd
C) /root/sudo
D) /etc/shadow
Answer: ATo edit sudo configuration safely:
A) visudo
B) edit /etc/sudoers
C) nano sudoers
D) sudoedit
Answer: ASELinux stands for:
A) Security-Enhanced Linux
B) System Enforced Linux
C) Secure Environment Linux
D) Security Environment Layer
Answer: ATo check SELinux status:
A) sestatus
B) getenforce
C) Both A and B
D) checkselinux
Answer: CTo temporarily disable SELinux:
A) setenforce 0
B) selinuxoff
C) disable selinux
D) stop selinux
Answer: ASELinux configuration file is located at:
A) /etc/selinux/config
B) /var/selinux/config
C) /usr/config/selinux
D) /root/selinux.cfg
Answer: ATo generate SSH keys:
A) ssh-keygen
B) ssh-add
C) genkey
D) sshconfig
Answer: ADefault SSH configuration file:
A) /etc/ssh/sshd_config
B) /root/ssh.conf
C) /etc/ssh/config
D) /var/ssh/settings
Answer: A
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: DTo test directory existence:
A) [ -d directory ]
B) test -d directory
C) [[ -d directory ]]
D) All of the above
Answer: DTo compare strings:
A) [ “$a” = “$b” ]
B) test $a == $b
C) [[ “$a” == “$b” ]]
D) All of the above
Answer: DTo perform arithmetic in shell:
A) $((a+b))
B) expr a + b
C) let c=a+b
D) All of the above
Answer: DIn shell scripting,
#!/bin/bashis called:
A) Shebang
B) Header
C) Directive
D) Prefix
Answer: ATo exit a script with success:
A) exit 0
B) exit 1
C) quit
D) return 0
Answer: ATo define a function:
A) function name { commands }
B) name() { commands }
C) Both A and B
D) define function name
Answer: CTo execute commands conditionally:
A) if [ condition ]; then … fi
B) while [ condition ]; do … done
C) case $var in …) esac
D) All of the above
Answer: DTo loop through a list:
A) for item in list; do … done
B) loop item list
C) foreach item list
D) until list done
Answer: AThe
$#variable gives:
A) Number of arguments passed to script
B) Script name
C) Return code
D) Command count
Answer: A
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: ATo extract a tar archive:
A) tar -xvf file.tar
B) unzip file.tar
C) untar file.tar
D) open file.tar
Answer: ATo 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: ATo extract a
.tar.gzfile:
A) tar -xzvf file.tar.gz
B) unzip file.tar.gz
C) gunzip file.tar.gz
D) extract file.tar.gz
Answer: ATo compress files using
bzip2:
A) bzip2 filename
B) gzip filename
C) tar filename
D) zip filename
Answer: ATo decompress
.bz2file:
A) bunzip2 filename
B) unzip filename
C) extract filename
D) tar -x filename
Answer: ATo create a zip file:
A) zip file.zip files
B) compress file.zip files
C) gzip -z file.zip
D) archive file.zip
Answer: ATo extract a zip file:
A) unzip file.zip
B) extract file.zip
C) zip -x file.zip
D) gunzip file.zip
Answer: ATo view contents of tar file:
A) tar -tvf file.tar
B) tar -v file.tar
C) cat file.tar
D) list file.tar
Answer: ATo 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
Default shell prompt for root user:
A) #
B) $
C) >
D) &
Answer: ADefault shell prompt for normal user:
A) $
B) #
C) @
D) %
Answer: ACommand to change system date:
A) date -s “YYYY-MM-DD”
B) setdate
C) settime
D) changetime
Answer: ATo check uptime and logged-in users:
A) w
B) who
C) uptime
D) All of the above
Answer: DTo list recently used commands:
A) history
B) lastcmd
C) cmdlog
D) cmdhis
Answer: ATo re-execute the previous command:
A) !!
B) history -r
C) exec prev
D) run last
Answer: ACommand to clear terminal screen:
A) clear
B) cls
C) reset
D) Both A and C
Answer: DTo find the path of a command:
A) which command
B) whereis command
C) type command
D) All of the above
Answer: DTo schedule a one-time task:
A) at
B) cron
C) schedule
D) once
Answer: ATo remove an at job:
A) atrm jobid
B) remove jobid
C) atdel jobid
D) job -r jobid
Answer: AThe command used to locate binary, source, and man page files:
A) whereis
B) locate
C) find
D) which
Answer: ACommand to find files by name:
A) find / -name filename
B) locate filename
C) Both A and B
D) grep filename
Answer: CTo find files modified within the last 24 hours:
A) find / -mtime -1
B) ls -lt
C) locate recent
D) search new
Answer: ATo find large files:
A) find / -size +100M
B) du -sh
C) locate big
D) search large
Answer: ATo check file type:
A) file filename
B) type filename
C) ls -t
D) show filename
Answer: ACommand to display environment variables:
A) env
B) printenv
C) set
D) All of the above
Answer: DTo view the PATH variable:
A) echo $PATH
B) showpath
C) getenv PATH
D) listpath
Answer: ATo 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: ATo view default runlevel or target:
A) systemctl get-default
B) runlevel
C) both A and B
D) showlevel
Answer: CTo change default runlevel or target:
A) systemctl set-default targetname
B) changetarget targetname
C) setlevel targetname
D) init targetname
Answer: A
The
mancommand is used for:
A) Displaying manual pages
B) Managing users
C) Mounting devices
D) Viewing logs
Answer: ATo search inside man pages:
A) man -k keyword
B) man -s keyword
C) searchman keyword
D) grepman keyword
Answer: ATo create a symbolic link:
A) ln -s target linkname
B) link target linkname
C) symlink target linkname
D) mklink target linkname
Answer: ATo create a hard link:
A) ln target linkname
B) link target linkname
C) mklink -h target linkname
D) cp target linkname
Answer: AThe maximum number of hard links to a file is limited by:
A) File system
B) Kernel version
C) Disk type
D) Permissions
Answer: ACommand to compare two files:
A) diff file1 file2
B) cmp file1 file2
C) comm file1 file2
D) All of the above
Answer: DTo merge file differences:
A) patch
B) merge
C) diffmerge
D) join
Answer: ACommand to join two files by common field:
A) join
B) merge
C) cat
D) paste
Answer: ACommand to display specific columns:
A) cut -f
B) awk ‘{print $1}’
C) Both A and B
D) grep
Answer: CTo replace text patterns:
A) sed ‘s/old/new/g’
B) awk ‘sub(“old”,”new”)’
C) Both A and B
D) grep -r
Answer: CTo sort lines in a file:
A) sort filename
B) order filename
C) seq filename
D) arrange filename
Answer: ATo remove duplicate lines:
A) uniq filename
B) sort -u filename
C) Both A and B
D) rmdup filename
Answer: CCommand to display disk usage of each directory:
A) du -h –max-depth=1
B) df -h
C) ls -lh
D) showdisk
Answer: ATo display active users and their processes:
A) w
B) who
C) ps -u
D) users
Answer: ATo reboot immediately:
A) reboot
B) shutdown -r now
C) systemctl reboot
D) All of the above
Answer: DTo power off the system:
A) poweroff
B) shutdown -h now
C) halt
D) All of the above
Answer: DDefault text editor in many Linux distributions is:
A) vi or vim
B) nano
C) gedit
D) emacs
Answer: ATo open a file in
vieditor in command mode:
A) vi filename
B) open filename
C) edit filename
D) vim -e filename
Answer: ACommand to save and exit in
vieditor:
A) :wq
B) 😡
C) ZZ
D) All of the above
Answer: DTo quit
viwithout saving changes:
A) :q!
B) :q
C) :exit
D) :quit
Answer: A