Linux MCQs (01-100)
Linux is an example of a:
A) Operating System
B) Kernel
C) Application
D) Programming Language
Answer: BThe Linux kernel is written mostly in:
A) C
B) C++
C) Java
D) Python
Answer: AThe first version of Linux was developed by:
A) Linus Torvalds
B) Richard Stallman
C) Dennis Ritchie
D) Ken Thompson
Answer: ALinux is based on which operating system?
A) UNIX
B) DOS
C) Windows
D) MacOS
Answer: AThe command to display the current working directory is:
A) pwd
B) cd
C) ls
D) dir
Answer: AThe command used to list files in a directory is:
A) ls
B) list
C) show
D) view
Answer: AWhich command is used to change directories?
A) cd
B) chdir
C) mv
D) dir
Answer: AThe root directory is represented by:
A) /
B) \
C) ~
D) .
Answer: AThe home directory of the root user is:
A) /root
B) /home
C) /usr
D) /etc
Answer: ATo display hidden files, use:
A) ls -a
B) ls -h
C) show hidden
D) ls -s
Answer: AThe command to create a new empty file:
A) touch filename
B) new file
C) create filename
D) echo > filename
Answer: ATo remove a file:
A) rm filename
B) del filename
C) erase filename
D) clear filename
Answer: ATo remove a directory and its contents:
A) rm -r dirname
B) rmdir dirname
C) delete dirname
D) rm dirname
Answer: ACommand to copy files:
A) cp source destination
B) copy source destination
C) mv source destination
D) clone source destination
Answer: ACommand to move or rename a file:
A) mv
B) move
C) rn
D) transfer
Answer: ATo display file contents:
A) cat filename
B) open filename
C) show filename
D) display filename
Answer: ATo show first 10 lines of a file:
A) head filename
B) top filename
C) start filename
D) less filename
Answer: ATo show last 10 lines of a file:
A) tail filename
B) end filename
C) show filename
D) last filename
Answer: ATo count lines, words, and characters in a file:
A) wc filename
B) count filename
C) cat -n filename
D) info filename
Answer: ATo search for a string inside a file:
A) grep “text” filename
B) find “text” filename
C) search “text” filename
D) locate “text” filename
Answer: A
File Permissions
Command to change file permissions:
A) chmod
B) chown
C) chperm
D) setperm
Answer: ATo change file ownership:
A) chown
B) chmod
C) ownfile
D) permset
Answer: ATo change the group of a file:
A) chgrp
B) chown -g
C) groupmod
D) setgrp
Answer: AIn Linux, permissions are represented as:
A) rwx
B) xyz
C) abc
D) lpr
Answer: ANumeric value of read, write, execute respectively:
A) 4, 2, 1
B) 1, 2, 3
C) 7, 6, 5
D) 0, 1, 2
Answer: AThe default permission assigned to new files is determined by:
A) umask
B) chmod
C) chown
D) setperm
Answer: ATo see file permissions, use:
A) ls -l
B) ls -p
C) showperm
D) listperm
Answer: ATo give execute permission to everyone:
A) chmod a+x filename
B) chmod 777 filename
C) chperm x filename
D) exec filename
Answer: AThe command
chmod 755 filegives:
A) rwxr-xr-x
B) rwxrw-r–
C) rw-r–r–
D) rwxrw-rw-
Answer: ATo remove write permission from group:
A) chmod g-w filename
B) chmod g+x filename
C) chmod o-w filename
D) chmod u-w filename
Answer: ATo view all running processes:
A) ps -ef
B) lsproc
C) top
D) runlist
Answer: ACommand to display real-time processes:
A) top
B) ps
C) showproc
D) jobs
Answer: ATo terminate a process:
A) kill PID
B) end PID
C) stop PID
D) exit PID
Answer: ATo terminate all processes by name:
A) killall name
B) stop name
C) endall name
D) close name
Answer: ATo suspend a process:
A) Ctrl + Z
B) Ctrl + C
C) Ctrl + D
D) Ctrl + P
Answer: ATo resume a suspended job in background:
A) bg
B) fg
C) cont
D) jobs
Answer: ATo bring a background job to foreground:
A) fg
B) bring
C) front
D) resume
Answer: ATo view job list:
A) jobs
B) ps
C) show
D) list
Answer: ATo display system uptime and load:
A) uptime
B) sysinfo
C) loadstat
D) top
Answer: ATo check memory usage:
A) free -m
B) memstat
C) ps -m
D) lsram
Answer: A
To display IP address:
A) ifconfig
B) ipconfig
C) ipstat
D) netconfig
Answer: ATo check network connectivity:
A) ping
B) netstat
C) testnet
D) checkip
Answer: ATo display routing table:
A) netstat -r
B) route show
C) ifroute
D) ping -r
Answer: ATo show active network connections:
A) netstat -a
B) connect -s
C) showip
D) traceroute
Answer: ACommand to trace the route of packets:
A) traceroute
B) tracepath
C) routepath
D) ping -t
Answer: ATo test DNS resolution:
A) nslookup
B) dnsquery
C) pingdns
D) host -d
Answer: ATo display hostname:
A) hostname
B) showhost
C) namehost
D) gethost
Answer: ACommand to display kernel version:
A) uname -r
B) version
C) sysinfo
D) kernel -v
Answer: ATo check system architecture:
A) uname -m
B) archinfo
C) sysarch
D) info -a
Answer: ACommand to shut down the system immediately:
A) shutdown -h now
B) halt
C) poweroff
D) All of the above
Answer: D
Command to add a new user:
A) useradd
B) adduser
C) createuser
D) mkuser
Answer: ACommand to set or change a user password:
A) passwd username
B) chpass username
C) usermod -p username
D) password username
Answer: ACommand to delete a user:
A) userdel username
B) deluser username
C) removeuser username
D) rmuser username
Answer: ATo create a new group:
A) groupadd
B) newgroup
C) mkgroup
D) addgrp
Answer: ATo change a user’s primary group:
A) usermod -g groupname username
B) chgrp -p groupname username
C) groupmod username
D) newgrp username
Answer: ATo add an existing user to a group:
A) usermod -aG groupname username
B) groupadd -u username groupname
C) chgroup username groupname
D) adduser -g groupname username
Answer: ATo see all logged-in users:
A) who
B) users
C) w
D) All of the above
Answer: DTo see login history:
A) last
B) history
C) who -a
D) logshow
Answer: ATo switch to another user:
A) su username
B) switch username
C) login username
D) sudo username
Answer: ATo execute a command as root:
A) sudo command
B) runas root command
C) exec root command
D) superuser command
Answer: A
The default shell in most Linux distributions is:
A) bash
B) sh
C) csh
D) zsh
Answer: ATo check the current shell:
A) echo $SHELL
B) show shell
C) get shell
D) ps shell
Answer: ATo make a script executable:
A) chmod +x script.sh
B) exec script.sh
C) run script.sh
D) make script.sh
Answer: ATo run a shell script:
A) ./script.sh
B) run script.sh
C) bash -x script.sh
D) All of the above
Answer: DA shell variable is created by:
A) var=value
B) set var=value
C) define var value
D) var := value
Answer: ATo display a variable:
A) echo $var
B) print $var
C) show var
D) cat var
Answer: ATo make a variable available to subshells:
A) export var
B) share var
C) global var
D) declare var
Answer: ATo take user input in shell:
A) read variable
B) input variable
C) scanf variable
D) echo variable
Answer: AIn shell scripting,
$0represents:
A) Script name
B) First argument
C) Last argument
D) Return value
Answer: ATo check the exit status of the last command:
A) echo $?
B) status
C) lastcmd
D) ret
Answer: A
Debian-based systems use which package manager?
A) apt
B) yum
C) dnf
D) zypper
Answer: ARed Hat-based systems use:
A) yum
B) apt
C) dpkg
D) snap
Answer: ACommand to install a package in Ubuntu:
A) sudo apt install pkgname
B) sudo yum install pkgname
C) install pkgname
D) dpkg pkgname
Answer: ATo remove a package in Ubuntu:
A) sudo apt remove pkgname
B) yum remove pkgname
C) dpkg -d pkgname
D) apt uninstall pkgname
Answer: ACommand to update all packages:
A) sudo apt upgrade
B) sudo apt update
C) sudo yum update
D) apt-get refresh
Answer: ATo list all installed packages:
A) dpkg -l
B) apt list
C) yum list installed
D) All of the above
Answer: DCommand to install a
.rpmpackage:
A) rpm -ivh file.rpm
B) dpkg -i file.rpm
C) apt install file.rpm
D) pkgadd file.rpm
Answer: ATo remove a
.rpmpackage:
A) rpm -e pkgname
B) yum remove pkgname
C) dpkg -r pkgname
D) apt delete pkgname
Answer: ATo check dependencies of an rpm package:
A) rpm -qpR file.rpm
B) rpm -d file.rpm
C) yum info file.rpm
D) depcheck file.rpm
Answer: ATo check a package version:
A) rpm -q pkgname
B) apt info pkgname
C) dpkg -s pkgname
D) All of the above
Answer: D
Command to check disk space usage:
A) df -h
B) du -h
C) lsblk
D) fdisk -l
Answer: ACommand to check directory size:
A) du -sh directory
B) df -d directory
C) ls -s directory
D) size directory
Answer: ATo list partitions:
A) fdisk -l
B) lsblk
C) blkid
D) All of the above
Answer: DTo mount a device:
A) mount /dev/sdX /mnt
B) attach /dev/sdX
C) plug /dev/sdX
D) start /dev/sdX
Answer: ATo unmount a device:
A) umount /mnt
B) unmount /mnt
C) remove /mnt
D) eject /mnt
Answer: ATo format a partition as ext4:
A) mkfs.ext4 /dev/sdX
B) format ext4 /dev/sdX
C) mke2fs /dev/sdX
D) partformat /dev/sdX
Answer: ATo display file system type:
A) df -T
B) fsinfo
C) listfs
D) showfs
Answer: ATo repair a Linux file system:
A) fsck /dev/sdX
B) repair /dev/sdX
C) fixfs /dev/sdX
D) chkfs /dev/sdX
Answer: AThe swap space is used for:
A) Virtual memory
B) Disk caching
C) Boot files
D) Temporary logs
Answer: ATo check swap usage:
A) swapon -s
B) swapinfo
C) showmem
D) swapstat
Answer: A
System log files are stored in:
A) /var/log
B) /usr/logs
C) /log
D) /etc/logs
Answer: ATo view system logs:
A) tail -f /var/log/syslog
B) view /var/log/messages
C) cat /var/log/kern.log
D) All of the above
Answer: DCommand to check CPU usage:
A) top
B) htop
C) mpstat
D) All of the above
Answer: DTo display disk I/O statistics:
A) iostat
B) vmstat
C) top -d
D) netstat -i
Answer: ATo check current date and time:
A) date
B) time
C) showtime
D) datetime
Answer: ATo display calendar:
A) cal
B) calendar
C) showcal
D) date -c
Answer: ACommand to schedule tasks:
A) cron
B) at
C) systemd timers
D) All of the above
Answer: DCron jobs are stored in:
A) /etc/crontab
B) /var/cron
C) /usr/schedule
D) /root/cron
Answer: ATo list user’s cron jobs:
A) crontab -l
B) cron -show
C) showcron
D) listcron
Answer: ATo edit cron jobs:
A) crontab -e
B) cron -edit
C) vi /etc/cron
D) editcron
Answer: A