Unix 200 MCQs | Unix Commands For Exam | Unix MCQs
Command to check network connectivity:
A) ping
B) netstat
C) ifconfig
D) traceroute
Answer: ACommand to display IP configuration:
A) ifconfig
B) ipconfig
C) netcfg
D) showip
Answer: ACommand to display active network connections:
A) netstat
B) ping
C) connect
D) iplist
Answer: ATo trace route of packets:
A) traceroute
B) route
C) netstat
D) tracepath
Answer: ATo display routing table:
A) netstat -r
B) route
C) ip route
D) All of the above
Answer: DTo test DNS resolution:
A) nslookup
B) dig
C) host
D) All of the above
Answer: DTo view or modify firewall rules:
A) iptables
B) firewall-cmd
C) ufw
D) All of the above
Answer: DCommand to transfer files securely:
A) scp
B) ftp
C) sftp
D) Both A and C
Answer: DCommand to log into another machine remotely:
A) ssh
B) telnet
C) rlogin
D) All of the above
Answer: DTo display hostname:
A) hostname
B) uname -n
C) both
D) netname
Answer: C
Shell scripts are written using:
A) Plain text editors
B) Binary editors
C) Word processors
D) Compilers
Answer: AFile extension for shell scripts:
A) .sh
B) .bash
C) .scr
D) .txt
Answer: AFirst line of a shell script starts with:
A) #!/bin/sh
B) @!/bin/sh
C) //bin/sh
D) start sh
Answer: ACommand to execute a shell script:
A) sh script.sh
B) ./script.sh
C) bash script.sh
D) All of the above
Answer: DTo make a script executable:
A) chmod +x script.sh
B) run script.sh
C) exec script.sh
D) enable script.sh
Answer: AVariable assignment in shell:
A) name=value
B) name = value
C) set name value
D) assign name value
Answer: ATo read user input:
A) read var
B) input var
C) get var
D) ask var
Answer: ATo print text in shell:
A) echo “text”
B) print “text”
C) printf “text”
D) Both A and C
Answer: DTo check command success:
A) $?
B) $$
C) $!
D) $@
Answer: ACommand to get process ID of last background job:
A) $!
B) $$
C) $?
D) pid
Answer: A
Conditional statement syntax:
A) if [ condition ]; then … fi
B) if condition { }
C) if (condition)
D) if { then }
Answer: ALoop to iterate over items:
A) for var in list; do … done
B) foreach var
C) while var in list
D) loop var
Answer: AWhile loop syntax:
A) while [ condition ]; do … done
B) while (condition)
C) do while (condition)
D) until (condition)
Answer: ATo exit from a loop:
A) break
B) exit
C) stop
D) return
Answer: ATo skip current iteration:
A) continue
B) skip
C) next
D) pass
Answer: ATo perform arithmetic:
A) expr 2 + 3
B) let a=2+3
C) $((2+3))
D) All of the above
Answer: DLogical AND operator in shell:
A) &&
B) ||
C) -a
D) Both A and C
Answer: DLogical OR operator in shell:
A) ||
B) -o
C) Both A and B
D) and
Answer: CString comparison equality operator:
A) =
B) ==
C) eq
D) is
Answer: ANumeric comparison equality operator:
A) -eq
B) ==
C) =
D) equal
Answer: A
To switch user:
A) su
B) sudo
C) login
D) All of the above
Answer: DTo execute a command as root:
A) sudo
B) runas
C) admin
D) su root
Answer: ATo add a new user:
A) useradd
B) adduser
C) mkuser
D) Both A and B
Answer: DTo delete a user:
A) userdel
B) deluser
C) removeuser
D) Both A and B
Answer: DTo change user password:
A) passwd
B) chpasswd
C) password
D) editpass
Answer: ATo change group of a user:
A) usermod -g
B) chgrp
C) setgroup
D) groupmod
Answer: ATo show all users:
A) cat /etc/passwd
B) users
C) who
D) All of the above
Answer: DTo show groups:
A) cat /etc/group
B) groups
C) id
D) All of the above
Answer: DTo display memory usage:
A) free -m
B) top
C) vmstat
D) All of the above
Answer: DTo display CPU usage:
A) top
B) mpstat
C) uptime
D) All of the above
Answer: D
Command to show system uptime:
A) uptime
B) who -b
C) w
D) top
Answer: ATo display currently logged users:
A) who
B) users
C) w
D) All of the above
Answer: DTo show running processes dynamically:
A) top
B) ps
C) jobs
D) stat
Answer: ATo display system messages:
A) dmesg
B) syslog
C) cat /var/log/messages
D) All of the above
Answer: DTo show kernel version:
A) uname -r
B) cat /proc/version
C) Both A and B
D) kernel -v
Answer: CTo reboot the system:
A) reboot
B) shutdown -r now
C) init 6
D) All of the above
Answer: DTo shut down system immediately:
A) shutdown -h now
B) halt
C) poweroff
D) All of the above
Answer: DTo change runlevel:
A) init
B) telinit
C) systemctl isolate
D) All of the above
Answer: DTo check system runlevel:
A) runlevel
B) who -r
C) Both A and B
D) status
Answer: CTo start a service:
A) service name start
B) systemctl start name
C) Both A and B
D) run name
Answer: CTo compress a file:
A) gzip
B) compress
C) zip
D) All of the above
Answer: D
To uncompress a
.gzfile:
A) gunzip
B) unzip
C) zcat
D) Both A and C
Answer: DTo archive files:
A) tar
B) zip
C) ar
D) All of the above
Answer: DTo create a tar file:
A) tar -cvf file.tar dir/
B) tar -xvf file.tar
C) tar -tvf file.tar
D) tar -rvf file.tar
Answer: ATo extract a tar file:
A) tar -xvf file.tar
B) untar file.tar
C) unzip file.tar
D) open file.tar
Answer: ATo view contents of tar file:
A) tar -tvf file.tar
B) tar -cvf
C) tar -xvf
D) ls file.tar
Answer: ATo combine multiple archives:
A) cat file1.tar file2.tar > total.tar
B) tar -cvf total.tar file1 file2
C) Both A and B
D) None
Answer: CTo extract
.tar.gzfile:
A) tar -xvzf file.tar.gz
B) gunzip file.tar.gz
C) unzip file.tar.gz
D) uncompress file.tar.gz
Answer: ATo list compressed file without extracting:
A) zcat file.gz
B) gzip -l file.gz
C) Both A and B
D) ls file.gz
Answer: CTo compare compressed files:
A) zcmp
B) cmp
C) diff
D) zdiff
Answer: D
System call to create a new process:
A) fork()
B) exec()
C) spawn()
D) start()
Answer: ASystem call to replace process image:
A) exec()
B) fork()
C) exit()
D) wait()
Answer: ASystem call to terminate process:
A) exit()
B) kill()
C) stop()
D) end()
Answer: ASystem call to wait for a process:
A) wait()
B) join()
C) pause()
D) block()
Answer: AProcess ID 1 is:
A) init
B) systemd
C) Both A and B (depending on system)
D) kernel
Answer: CTo get process ID:
A) getpid()
B) pid()
C) procid()
D) idproc()
Answer: ATo create a file:
A) creat()
B) open()
C) fopen()
D) Both A and B
Answer: DTo close a file descriptor:
A) close()
B) fclose()
C) end()
D) exit()
Answer: ATo read from a file descriptor:
A) read()
B) fread()
C) get()
D) input()
Answer: ATo write to a file descriptor:
A) write()
B) fwrite()
C) put()
D) send()
Answer: A
Symbolic link command:
A) ln -s
B) link
C) mklink
D) attach
Answer: ATo create a hard link:
A) ln file1 file2
B) link file1 file2
C) Both A and B
D) attach file1 file2
Answer: CTo find a file:
A) find / -name filename
B) locate filename
C) Both A and B
D) search filename
Answer: CTo update locate database:
A) updatedb
B) refreshdb
C) locate -u
D) finddb
Answer: ATo display system date in specific format:
A) date +%d-%m-%Y
B) date -f
C) showdate -f
D) printdate
Answer: ACommand to find file type:
A) file filename
B) stat filename
C) ls -l filename
D) type filename
Answer: ATo display inode number:
A) ls -i
B) stat
C) find -inum
D) All of the above
Answer: DTo display file size:
A) ls -lh
B) du -h
C) stat
D) All of the above
Answer: DTo find recently modified files:
A) find / -mtime -1
B) find / -atime -1
C) find / -ctime -1
D) All of the above
Answer: ATo display hidden files:
A) ls -a
B) ls -A
C) Both A and B
D) ls -h
Answer: C
To check disk usage by directory:
A) du -sh *
B) df -h
C) ls -s
D) diskusage
Answer: ATo monitor live logs:
A) tail -f /var/log/syslog
B) cat /var/log/syslog
C) less /var/log/syslog
D) dmesg
Answer: ATo count number of running processes:
A) ps -e | wc -l
B) jobs | wc -l
C) top | wc -l
D) proc -count
Answer: ATo find which program uses a file:
A) lsof
B) fuser
C) Both A and B
D) ps
Answer: CTo lock a user account:
A) passwd -l
B) usermod -L
C) Both A and B
D) disable user
Answer: CTo unlock a user account:
A) passwd -u
B) usermod -U
C) Both A and B
D) enable user
Answer: CTo check disk quota:
A) quota
B) repquota
C) edquota
D) All of the above
Answer: DTo print last logged in users:
A) last
B) who
C) users
D) log
Answer: ATo display boot logs:
A) dmesg
B) journalctl -b
C) cat /var/log/boot.log
D) All of the above
Answer: DTo show system hardware info:
A) lshw
B) dmidecode
C) lscpu
D) All of the above
Answer: D
Which command shows manual pages?
A) man
B) help
C) info
D) doc
Answer: ATo display a brief command summary:
A) whatis
B) help
C) man -k
D) All of the above
Answer: DDefault shell variable for process ID:
A) $$
B) $!
C) $?
D) $0
Answer: ATo execute previous command:
A) !!
B) !-1
C) !history
D) !prev
Answer: ATo recall a specific command from history:
A) !n
B) history n
C) !cmd
D) run n
Answer: ACommand to show command history:
A) history
B) his
C) lastcmd
D) listcmd
Answer: ACommand to change shell prompt:
A) PS1
B) PROMPT
C) setprompt
D) changePS
Answer: ATo check total number of users logged in:
A) who | wc -l
B) users | wc -l
C) w | wc -l
D) All of the above
Answer: DCommand to show system information:
A) uname -a
B) sysinfo
C) info
D) hostinfo
Answer: AUNIX file that stores user info:
A) /etc/passwd
B) /etc/shadow
C) /etc/group
D) /etc/profile
Answer: A