Unix 200 MCQs | Unix Commands For Exam | Unix MCQs

  1. Command to check network connectivity:
    A) ping
    B) netstat
    C) ifconfig
    D) traceroute
    Answer: A

  2. Command to display IP configuration:
    A) ifconfig
    B) ipconfig
    C) netcfg
    D) showip
    Answer: A

  3. Command to display active network connections:
    A) netstat
    B) ping
    C) connect
    D) iplist
    Answer: A

  4. To trace route of packets:
    A) traceroute
    B) route
    C) netstat
    D) tracepath
    Answer: A

  5. To display routing table:
    A) netstat -r
    B) route
    C) ip route
    D) All of the above
    Answer: D

  6. To test DNS resolution:
    A) nslookup
    B) dig
    C) host
    D) All of the above
    Answer: D

  7. To view or modify firewall rules:
    A) iptables
    B) firewall-cmd
    C) ufw
    D) All of the above
    Answer: D

  8. Command to transfer files securely:
    A) scp
    B) ftp
    C) sftp
    D) Both A and C
    Answer: D

  9. Command to log into another machine remotely:
    A) ssh
    B) telnet
    C) rlogin
    D) All of the above
    Answer: D

  10. To display hostname:
    A) hostname
    B) uname -n
    C) both
    D) netname
    Answer: C

  1. Shell scripts are written using:
    A) Plain text editors
    B) Binary editors
    C) Word processors
    D) Compilers
    Answer: A

  2. File extension for shell scripts:
    A) .sh
    B) .bash
    C) .scr
    D) .txt
    Answer: A

  3. First line of a shell script starts with:
    A) #!/bin/sh
    B) @!/bin/sh
    C) //bin/sh
    D) start sh
    Answer: A

  4. Command to execute a shell script:
    A) sh script.sh
    B) ./script.sh
    C) bash script.sh
    D) All of the above
    Answer: D

  5. To make a script executable:
    A) chmod +x script.sh
    B) run script.sh
    C) exec script.sh
    D) enable script.sh
    Answer: A

  6. Variable assignment in shell:
    A) name=value
    B) name = value
    C) set name value
    D) assign name value
    Answer: A

  7. To read user input:
    A) read var
    B) input var
    C) get var
    D) ask var
    Answer: A

  8. To print text in shell:
    A) echo “text”
    B) print “text”
    C) printf “text”
    D) Both A and C
    Answer: D

  9. To check command success:
    A) $?
    B) $$
    C) $!
    D) $@
    Answer: A

  10. Command to get process ID of last background job:
    A) $!
    B) $$
    C) $?
    D) pid
    Answer: A

  1. Conditional statement syntax:
    A) if [ condition ]; then … fi
    B) if condition { }
    C) if (condition)
    D) if { then }
    Answer: A

  2. Loop to iterate over items:
    A) for var in list; do … done
    B) foreach var
    C) while var in list
    D) loop var
    Answer: A

  3. While loop syntax:
    A) while [ condition ]; do … done
    B) while (condition)
    C) do while (condition)
    D) until (condition)
    Answer: A

  4. To exit from a loop:
    A) break
    B) exit
    C) stop
    D) return
    Answer: A

  5. To skip current iteration:
    A) continue
    B) skip
    C) next
    D) pass
    Answer: A

  6. To perform arithmetic:
    A) expr 2 + 3
    B) let a=2+3
    C) $((2+3))
    D) All of the above
    Answer: D

  7. Logical AND operator in shell:
    A) &&
    B) ||
    C) -a
    D) Both A and C
    Answer: D

  8. Logical OR operator in shell:
    A) ||
    B) -o
    C) Both A and B
    D) and
    Answer: C

  9. String comparison equality operator:
    A) =
    B) ==
    C) eq
    D) is
    Answer: A

  10. Numeric comparison equality operator:
    A) -eq
    B) ==
    C) =
    D) equal
    Answer: A

  1. To switch user:
    A) su
    B) sudo
    C) login
    D) All of the above
    Answer: D

  2. To execute a command as root:
    A) sudo
    B) runas
    C) admin
    D) su root
    Answer: A

  3. To add a new user:
    A) useradd
    B) adduser
    C) mkuser
    D) Both A and B
    Answer: D

  4. To delete a user:
    A) userdel
    B) deluser
    C) removeuser
    D) Both A and B
    Answer: D

  5. To change user password:
    A) passwd
    B) chpasswd
    C) password
    D) editpass
    Answer: A

  6. To change group of a user:
    A) usermod -g
    B) chgrp
    C) setgroup
    D) groupmod
    Answer: A

  7. To show all users:
    A) cat /etc/passwd
    B) users
    C) who
    D) All of the above
    Answer: D

  8. To show groups:
    A) cat /etc/group
    B) groups
    C) id
    D) All of the above
    Answer: D

  9. To display memory usage:
    A) free -m
    B) top
    C) vmstat
    D) All of the above
    Answer: D

  10. To display CPU usage:
    A) top
    B) mpstat
    C) uptime
    D) All of the above
    Answer: D

  1. Command to show system uptime:
    A) uptime
    B) who -b
    C) w
    D) top
    Answer: A

  2. To display currently logged users:
    A) who
    B) users
    C) w
    D) All of the above
    Answer: D

  3. To show running processes dynamically:
    A) top
    B) ps
    C) jobs
    D) stat
    Answer: A

  4. To display system messages:
    A) dmesg
    B) syslog
    C) cat /var/log/messages
    D) All of the above
    Answer: D

  5. To show kernel version:
    A) uname -r
    B) cat /proc/version
    C) Both A and B
    D) kernel -v
    Answer: C

  6. To reboot the system:
    A) reboot
    B) shutdown -r now
    C) init 6
    D) All of the above
    Answer: D

  7. To shut down system immediately:
    A) shutdown -h now
    B) halt
    C) poweroff
    D) All of the above
    Answer: D

  8. To change runlevel:
    A) init
    B) telinit
    C) systemctl isolate
    D) All of the above
    Answer: D

  9. To check system runlevel:
    A) runlevel
    B) who -r
    C) Both A and B
    D) status
    Answer: C

  10. To start a service:
    A) service name start
    B) systemctl start name
    C) Both A and B
    D) run name
    Answer: C

  11. To compress a file:
    A) gzip
    B) compress
    C) zip
    D) All of the above
    Answer: D

  1. To uncompress a .gz file:
    A) gunzip
    B) unzip
    C) zcat
    D) Both A and C
    Answer: D

  2. To archive files:
    A) tar
    B) zip
    C) ar
    D) All of the above
    Answer: D

  3. To 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: A

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

  5. To view contents of tar file:
    A) tar -tvf file.tar
    B) tar -cvf
    C) tar -xvf
    D) ls file.tar
    Answer: A

  6. To 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: C

  7. To extract .tar.gz file:
    A) tar -xvzf file.tar.gz
    B) gunzip file.tar.gz
    C) unzip file.tar.gz
    D) uncompress file.tar.gz
    Answer: A

  8. To list compressed file without extracting:
    A) zcat file.gz
    B) gzip -l file.gz
    C) Both A and B
    D) ls file.gz
    Answer: C

  9. To compare compressed files:
    A) zcmp
    B) cmp
    C) diff
    D) zdiff
    Answer: D

  1. System call to create a new process:
    A) fork()
    B) exec()
    C) spawn()
    D) start()
    Answer: A

  2. System call to replace process image:
    A) exec()
    B) fork()
    C) exit()
    D) wait()
    Answer: A

  3. System call to terminate process:
    A) exit()
    B) kill()
    C) stop()
    D) end()
    Answer: A

  4. System call to wait for a process:
    A) wait()
    B) join()
    C) pause()
    D) block()
    Answer: A

  5. Process ID 1 is:
    A) init
    B) systemd
    C) Both A and B (depending on system)
    D) kernel
    Answer: C

  6. To get process ID:
    A) getpid()
    B) pid()
    C) procid()
    D) idproc()
    Answer: A

  7. To create a file:
    A) creat()
    B) open()
    C) fopen()
    D) Both A and B
    Answer: D

  8. To close a file descriptor:
    A) close()
    B) fclose()
    C) end()
    D) exit()
    Answer: A

  9. To read from a file descriptor:
    A) read()
    B) fread()
    C) get()
    D) input()
    Answer: A

  10. To write to a file descriptor:
    A) write()
    B) fwrite()
    C) put()
    D) send()
    Answer: A

  1. Symbolic link command:
    A) ln -s
    B) link
    C) mklink
    D) attach
    Answer: A

  2. To create a hard link:
    A) ln file1 file2
    B) link file1 file2
    C) Both A and B
    D) attach file1 file2
    Answer: C

  3. To find a file:
    A) find / -name filename
    B) locate filename
    C) Both A and B
    D) search filename
    Answer: C

  4. To update locate database:
    A) updatedb
    B) refreshdb
    C) locate -u
    D) finddb
    Answer: A

  5. To display system date in specific format:
    A) date +%d-%m-%Y
    B) date -f
    C) showdate -f
    D) printdate
    Answer: A

  6. Command to find file type:
    A) file filename
    B) stat filename
    C) ls -l filename
    D) type filename
    Answer: A

  7. To display inode number:
    A) ls -i
    B) stat
    C) find -inum
    D) All of the above
    Answer: D

  8. To display file size:
    A) ls -lh
    B) du -h
    C) stat
    D) All of the above
    Answer: D

  9. To find recently modified files:
    A) find / -mtime -1
    B) find / -atime -1
    C) find / -ctime -1
    D) All of the above
    Answer: A

  10. To display hidden files:
    A) ls -a
    B) ls -A
    C) Both A and B
    D) ls -h
    Answer: C

  1. To check disk usage by directory:
    A) du -sh *
    B) df -h
    C) ls -s
    D) diskusage
    Answer: A

  2. To monitor live logs:
    A) tail -f /var/log/syslog
    B) cat /var/log/syslog
    C) less /var/log/syslog
    D) dmesg
    Answer: A

  3. To count number of running processes:
    A) ps -e | wc -l
    B) jobs | wc -l
    C) top | wc -l
    D) proc -count
    Answer: A

  4. To find which program uses a file:
    A) lsof
    B) fuser
    C) Both A and B
    D) ps
    Answer: C

  5. To lock a user account:
    A) passwd -l
    B) usermod -L
    C) Both A and B
    D) disable user
    Answer: C

  6. To unlock a user account:
    A) passwd -u
    B) usermod -U
    C) Both A and B
    D) enable user
    Answer: C

  7. To check disk quota:
    A) quota
    B) repquota
    C) edquota
    D) All of the above
    Answer: D

  8. To print last logged in users:
    A) last
    B) who
    C) users
    D) log
    Answer: A

  9. To display boot logs:
    A) dmesg
    B) journalctl -b
    C) cat /var/log/boot.log
    D) All of the above
    Answer: D

  10. To show system hardware info:
    A) lshw
    B) dmidecode
    C) lscpu
    D) All of the above
    Answer: D

  1. Which command shows manual pages?
    A) man
    B) help
    C) info
    D) doc
    Answer: A

  2. To display a brief command summary:
    A) whatis
    B) help
    C) man -k
    D) All of the above
    Answer: D

  3. Default shell variable for process ID:
    A) $$
    B) $!
    C) $?
    D) $0
    Answer: A

  4. To execute previous command:
    A) !!
    B) !-1
    C) !history
    D) !prev
    Answer: A

  5. To recall a specific command from history:
    A) !n
    B) history n
    C) !cmd
    D) run n
    Answer: A

  6. Command to show command history:
    A) history
    B) his
    C) lastcmd
    D) listcmd
    Answer: A

  7. Command to change shell prompt:
    A) PS1
    B) PROMPT
    C) setprompt
    D) changePS
    Answer: A

  8. To 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: D

  9. Command to show system information:
    A) uname -a
    B) sysinfo
    C) info
    D) hostinfo
    Answer: A

  10. UNIX file that stores user info:
    A) /etc/passwd
    B) /etc/shadow
    C) /etc/group
    D) /etc/profile
    Answer: A

Leave a Comment

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

You cannot copy content of this page

Scroll to Top