Linux Commands Practice Questions PDF

Summary

This document is a compilation of Linux command practice questions with corresponding answers. The questions cover a wide range of topics, including file management, shell scripting, and system administration concepts.

Full Transcript

Sure! Here's the complete question and answer sheet with options for all 81 questions. **Question and Answer Sheet** **1. What are the differences between hard disk drives and solid state disks? (Choose two.)** - A. Hard disks can fail due to physical damage, while solid state disks cannot...

Sure! Here's the complete question and answer sheet with options for all 81 questions. **Question and Answer Sheet** **1. What are the differences between hard disk drives and solid state disks? (Choose two.)** - A. Hard disks can fail due to physical damage, while solid state disks cannot fail. - B. Solid state disks can store many times as much data as hard disk drives. - C. /dev/sda is a hard disk device while /dev/ssda is a solid state disk. - D. Solid state disks provide faster access to stored data than hard disks. - E. Hard disks have a motor and moving parts, solid state disks do not. **Correct Answers**: D, E **2. Members of a team already have experience using Red Hat Enterprise Linux. For a small hobby project, which Linux distribution allows them to apply their knowledge?** - A. CentOS - B. Debian GNU/Linux - C. Ubuntu Linux LTS - D. openSUSE - E. Raspbian **Correct Answer**: A **3. How is the name of the IP address 198.51.100.165 stored on a DNS server?** - A. In the A record for 165.100.51.198.ipv4.arpa. - B. In the REV record for arpa.in-addr.198.51.100.165. - C. In the RNAME record for 198-51-100-165.rev.arpa. - D. In the ARPA record for 165.100.51.198.rev. - E. In the PTR record for 165.100.51.198.in-addr.arpa. **Correct Answer**: E **4. Which of the following types of bus can connect hard disk drives with the motherboard?** - A. The RAM bus - B. The NUMA bus - C. The Auto bus - D. The CPU bus - E. The SATA bus **Correct Answer**: E **5. Which of the following commands can be used to resolve a DNS name to an IP address?** - A. dnsname - B. query - C. dns - D. iplookup - E. host **Correct Answer**: E **6. What information can be displayed by top?** - A. User accounts, ordered by the number of files. - B. Running processes, ordered by CPU or RAM consumption. - C. User accounts, ordered by the number of logins. - D. User groups, ordered by the number of members. - E. Existing files, ordered by their size. **Correct Answer**: B **7. Which of the following outputs comes from the command free?** - A. 21:04 up 14 days, 7:43, 3 users, load average: 0.89, 1.00, 0.99 - B. avg-cpu: %user %nice %system %iowait %steal %idle\\n16.36 0.00 2.99 1.06 0.00 79.59 - C. Filesystem Size Used Avail Use% Mounted on \\n/dev/nvme0n1p2 468G 33G 412G 8% / - D. 120K /tmp - E. total used free shared buff/cache available\\nMem: 15Gi 2.3Gi 9Gi 910Mi 3.0Gi 11Gi\\nSwap: 2.0Gi 0B 2.0Gi **Correct Answer**: E **8. What is true about the dmesg command? (Choose two.)** - A. It might not display older information because it was overwritten by newer information. - B. It sends messages to the command lines of all current user sessions. - C. It traces the execution of a command and shows each step the program carries out. - D. It displays the content of the Linux kernel's ring buffer. - E. It immediately outputs all new messages written to the system journal. **Correct Answers**: A, D **9. Which of the following outputs could stem from the command last?** - A. 1 ls\\n 2 cat text.txt\\n 3 logout - B. Password for user last changed at Sat Mar 31 16:38:57 EST 2018 - C. Last login: Fri Mar 23 10:56:39 2018 from server.example.com - D. EXT4-fs(dm7): mounted filesystem with ordered data mode. Opts: (null) - E. root tty2 Wed May 17 21:11 - 21:11 (00:00) **Correct Answer**: E **10. What is true about the owner of a file?** - A. The user owning a file must be a member of the file's group. - B. The owner of a file cannot be changed once it is assigned to an owner. - C. Each file is owned by exactly one user and one group. - D. The owner of a file always has full permissions when accessing the file. - E. When a user is deleted, all files owned by the user disappear. **Correct Answer**: C **11. What is the UID of the user root?** - A. 255 - B. 0 - C. 1 - D. -1 - E. 65536 **Correct Answer**: B **12. Which permissions are set on a regular file once the permissions have been modified with the command chmod 654 file.txt?** - A. d---wxr-x\-- - B. drw-r-xr\-- - C. --rwxrw\-\--x - D. --wxr-x\--x - E. -rw-r-xr\-- **Correct Answer**: E **13. Which of the following tar options handle compression? (Choose two.)** - A. -z - B. -g - C. -z2 - D. -bz - E. -j **Correct Answers**: A, E **14. Which of the following permissions are set on the /tmp/ directory?** - A. rwX - B. rwxrwxrwt - C. r-xr-X\--t - D. rwSrw-rw- - E. rwxrwS\-\-- **Correct Answer**: B **15. What information is stored in /etc/passwd? (Choose three.)** - A. The user's default shell - B. The user's storage space limit - C. The username - D. The numerical user ID - E. The encrypted password **Correct Answers**: A, C, D **16. Which command adds the new user tux and creates the user's home directory with default configuration files?** - A. useradd --m tux - B. defaultuser tux - C. useradd --o default tux - D. passwd --a tux - E. usercreate tux **Correct Answer**: A **17. Which of the following commands creates an archive file work.tar from the contents of the directory./work/?** - A. tar work \> work.tar - B. tar work.tar \<./work/ - C. tar \--new work.tar./work/ - D. tar --cf work.tar./work/ - E. tar --create work.tgz --content./work/ **Correct Answer**: D **18. The current directory contains the following file: -rwxr-xr-x 1 root root 859688 Feb 7 08:15 test.sh. How can this script be executed? (Choose two.)** - A. bash test.sh - B. \${test.sh} - C. cmd./test.sh - D../test.sh - E. run test.sh **Correct Answers**: A, D **19. Which of the following keys can be pressed to exit less?** - A. l - B. e - C. q - D. ! - E. x **Correct Answer**: C **20. What keyword is used in a shell script to begin a loop? (Specify one keyword only.)** - A. for - B. forloop **Correct Answer**: A **21. Which of the following commands will search for the file foo.txt under the directory /home?** - A. find /home --file foo.txt - B. find /home --name foo.txt - C. find /home foo.txt - D. search /home --file foo.txt - E. search /home foo.txt **Correct Answer**: B **22. A directory contains the following files: a.txt and b.txt. What would be the output of the following shell script? for file in \*.txt** - A. a b - B. \*.txt - C. c.cav - D. a.txt - E. a.txt b.txt **Correct Answer**: E **23. The current directory contains the following file: -rw-r\--r\-- 1 root exec 24551 Apr 2 12:36 test.sh. The file contains a valid shell script, but executing this file using./test.sh leads to this error: bash:./test.sh: Permission denied. What should be done to successfully execute the script?** - A. The file's extension should be changed from.sh to.bin. - B. The script should be run using \#!./test.sh instead of./test.sh. - C. The execute bit should be set in the file's permissions. - D. The user executing the script should be added to the exec group. - E. The SetUID bit should be set in the file's permissions. **Correct Answer**: C **24. Which of the following commands sorts the output of the command export-logs?** - A. export-logs \< sort - B. export-logs & sort - C. export-logs \ sort - D. export-logs \| sort - E. export-logs \> sort **Correct Answer**: D **25. What is a Linux distribution?** - A. A set of changes to Linux which enable Linux to run on another processor architecture. - B. An operating system based on Linux but incompatible with the regular Linux kernel. - C. The Linux file system as seen from the root account after mounting all file systems. - D. The set of rules which governs the distribution of Linux kernel source code. - E. A bundling of the Linux kernel, system utilities, and other software. **Correct Answer**: E **26. Where is the operating system of a Raspberry Pi stored?** - A. On a removable SD card which is put into the Raspberry Pi. - B. On rewritable flash storage which is built into the Raspberry Pi. - C. On a read-only partition on the Raspberry Pi's firmware, next to the BIOS. - D. On the master device attached to the Raspberry Pi's IDE bus. - E. On a Linux extension module connected to the Raspberry Pi's GPIO pins. **Correct Answer**: A **27. Which of the following programs is a graphical editor for vector graphics?** - A. NGINX - B. Python - C. MySQL - D. Samba - E. Inkscape **Correct Answer**: E **28. Which package management tool is used in Red Hat-based Linux Systems?** - A. rpm - B. apt-get - C. dpkg - D. packagectl - E. portage **Correct Answer**: A **29. Which of the following characters in a shell prompt indicates the shell is running with root privileges?** - A. \* - B. & - C. \$ - D. \# - E. ! **Correct Answer**: D **30. Which of the following are typical services offered by public cloud providers? (Choose three.)** - A. Internet as a Service (IaaS) - B. Graphics as a Service (GaaS) - C. Platform as a Service (PaaS) - D. Infrastructure as a Service (IaaS) - E. Software as a Service (SaaS) **Correct Answers**: D, C, E **31. What is defined by a Free Software license?** - A. Conditions for modifying and distributing the licensed software. - B. Details of the technical documentation each contributor has to provide. - C. A complete list of libraries required to compile the licensed software. - D. The programming languages which may be used to extend the licensed program. - E. Limits on the purposes for which the licensed software may be used. **Correct Answer**: A **32. Why are web browser cookies considered dangerous?** - A. Cookies store critical data which is lost when a cookie is deleted. - B. Cookies are always public and accessible to anyone on the internet. - C. Cookies support identification and tracking of users. - D. Cookies can contain and execute viruses and malware. - E. Cookies consume significant amounts of storage and can exhaust disk space. **Correct Answer**: C **33. Running the command rm Downloads leads to the error: rm: cannot remove 'Downloads/': Is a directory. Which commands can be used instead to remove Downloads, assuming Downloads is empty? (Choose two.)** - A. rmdir Downloads - B. rm --r Downloads - C. rem Downloads - D. dir --r Downloads - E. undir Downloads **Correct Answers**: A, B **34. What is true about a recursive directory listing?** - A. It includes ownership information for the files. - B. It includes details of file system internals, such as inodes. - C. It includes a preview of content for each file in the directory. - D. It includes the content of sub-directories. - E. It includes the permissions of the directory listed. **Correct Answer**: D **35. Which of the following commands are used to get information on the proper use of ls? (Choose two.)** - A. option ls - B. info ls - C. usage ls - D. manual ls - E. man ls **Correct Answers**: E, B **36. Which of the following directories contains information, documentation, and example configuration files for installed software packages?** - A. /usr/share/doc/ - B. /etc/defaults/ - C. /var/info/ - D. /usr/examples/ - E. /doc/ **Correct Answer**: A **37. A user is currently in the directory /home/user/Downloads/ and runs the command ls../Documents/. Which directory's content is displayed?** - A. /home/user/Documents/Downloads/ - B. /home/user/Documents/ - C. /home/user/Downloads/Documents/ - D. /Documents/ - E. /home/Documents **Correct Answer**: B **38. Which of the following commands adds the directory /new/dir/ to the PATH environment variable?** - A. export PATH=/new/dir: PATH - B. PATH=/new/dir: PATH - C. export PATH=/new/dir:PATH=/new/dir: PATH=/new/dir:PATH - D. PATH=/new/dir:PATH=/new/dir: PATH=/new/dir:PATH - E. export PATH=/new/dir: \$PATH **Correct Answer**: E **39. A directory contains the following three files: texts 1.txt, texts 2.txt, texts 3.csv. Which command copies the two files ending in.txt to the /tmp/ directory?** - A. cp. \\.txt /tmp/ - B. cp \*.txt /tmp/ - C. cp ?.txt /tmp/ - D. cp ??.txt /tmp/ - E. cp \$?.txt /tmp/ **Correct Answer**: B **40. FILL BLANK: When typing a long command line at the shell, what single character can be used to split a command across multiple lines?** - A. / - B. \\ **Correct Answer**: B **41. Which of the following DNS record types hold an IP address? (Choose two.)** - A. NS - B. AAAA - C. MX - D. A - E. CNAME **Correct Answers**: B, D **42. Which of the following values could be a process ID on Linux?** - A. /bin/bash - B. 60b503cd-019e-4300-a7be-922f074ef5ce - C. /sys/pid/9a14 - D. fff3 - E. 21398 **Correct Answer**: E **43. Which of the following is a protocol used for automatic IP address configuration?** - A. NFS - B. LDAP - C. SMTP - D. DNS - E. DHCP **Correct Answer**: E **44. Which of the following devices represents a hard disk partition?** - A. /dev/ttyS0 - B. /dev/sata0 - C. /dev/part0 - D. /dev/sda2 - E. /dev/sda/p2 **Correct Answer**: D **45. Which of the following statements regarding Linux hardware drivers is correct?** - A. Drivers are regular Linux programs which have to be run by the user who wants to use a device. - B. Drivers are not used by Linux because the BIOS handles all access to hardware on behalf of Linux. - C. Drivers are stored on their devices and are copied by the Linux kernel when a new device is attached. - D. Drivers are downloaded from the vendor\'s driver repository when a new device is attached. - E. Drivers are either compiled into the Linux kernel or are loaded as kernel modules. **Correct Answer**: E **46. What can be found in the /proc/ directory?** - A. One directory per installed program. - B. One file per existing user account. - C. One directory per running process. - D. One log file per running service. **Correct Answer**: C **47. A new server needs to be installed to host services for a period of several years. Which of the following Linux distributions meet these requirements? (Choose two.)** - A. Ubuntu Linux LTS - B. Fedora Linux - C. Debian GNU/Linux Unstable - D. Ubuntu Linux non-LTS - E. Red Hat Enterprise Linux\ **Correct Answers:** A, E **48. Which of the following directories must be mounted with read and write access if it resides on its own dedicated file system?** - A. /opt - B. /lib - C. /etc - D. /var - E. /usr\ **Correct Answer:** D **49. The ownership of the file doku.odt should be changed. Which command accomplishes this change?** - A. chmod u=tux doku.odt - B. newuser doku.odt tux - C. chown tux doku.odt - D. transfer tux: doku.odt - E. passwd doku.odt:tux\ **Correct Answer:** C **50. What happens to a file residing outside the home directory when the file owner\'s account is deleted? (Choose two.)** - A. During a file system check, the file is moved to /lost+found. - B. The file is removed from the file system. - C. The UID of the former owner is shown when listing the file\'s details. - D. The user root is set as the new owner of the file. - E. Ownership and permissions of the file remain unchanged.\ **Correct Answers:** C, E **51. Which statements about the directory /etc/skel are correct? (Choose two.)** - A. The personal user settings of root are stored in this directory. - B. The files from the directory are copied to the home directory of the new user when starting the system. - C. The files from the directory are copied to the home directory of a new user when the account is created. - D. The directory contains a default set of configuration files used by the useradd command. - E. The directory contains the global settings for the Linux system.\ **Correct Answers:** C, D **52. What is true about links in a Linux file system?** - A. A symbolic link can only point to a file and not to a directory. - B. A hard link can only point to a directory and never to a file. - C. When the target of the symbolic link is moved, the link is automatically updated. - D. A symbolic link can point to a file on another file system. - E. Only the root user can create hard links.\ **Correct Answer:** D **53. Which files are the source of the information in the following output? (Choose two.)** - uid=1000 (bob) gid=1000 (bob) groups=1000 (bob), 10 (wheel), 150 (wireshark), 989 (docker), 1001 (libvirt) - A. /etc/id - B. /etc/passwd - C. /etc/group - D. /home/index - E. /var/db/users\ **Correct Answers:** B, C **54. Which of the following tasks can the command passwd accomplish? (Choose two.)** - A. Change a user\'s username. - B. Change a user\'s password. - C. Create a new user account. - D. Create a new user group. - E. Lock a user account.\ **Correct Answers:** B, E **55. What is true about the su command?** - A. It is the default shell of the root account. - B. It can only be used by the user root. - C. It runs a shell or command as another user. - D. It changes the name of the main administrator account. - E. It locks the root account in specific time frames.\ **Correct Answer:** C **56. What parameter of ls prints a recursive listing of a directory\'s content?** - **Answer:** -R **57. Most commands on Linux can display information on their usage. How can this information typically be displayed?** - A. By running the command with the option /? or /??. - B. By running the command with the option ?! or ?=!. - C. By running the command with the option /doc or /documentation. - D. By running the command with the option -h or \--help. - E. By running the command with the option -m or \--manpage.\ **Correct Answer:** D **58. Which of the following commands shows the absolute path to the current working directory?** - A. who - B. cd.. - C. pwd - D. ls -l - E. cd \~/home\ **Correct Answer:** C **59. Which of the following commands output the content of the file Texts 2.txt? (Choose two.)** - A. cat \'Texts 2.txt\' - B. cat \-- Texts 2.txt - C. cat \|Texts 2.txt\| - D. cat \'Texts\\ 2.txt\' - E. cat Texts\\ 2.txt\ **Correct Answers:** A, E **60. Which command displays file names only and no additional information?** - A. ls -a - B. ls -lh - C. ls -l - D. ls -alh - E. ls -nl\ **Correct Answer:** A **61. What is the purpose of the PATH environment variable?** - A. It allows the execution of commands without the need to know the location of the executable. - B. It increases security by preventing commands from running in certain locations. - C. It specifies the location of a user\'s home directory. - D. It indicates the location of the default shell to be used when a user logs in. - E. It contains the absolute path to the current directory.\ **Correct Answer:** A **62. Which of the following commands sets the variable USERNAME to the value bob?** - A. set USERNAME bob - B. \$USERNAME==bob - C. var USERNAME=bob - D. USERNAME\ echo \$file - B. for \*.txt ( echo \$i ) - C. for file in \*.txt do echo \$i done - D. for ls \*.txt exec {} \\; - E. foreach @{file} { echo \$i }\ **Correct Answer:** C **67. Which operator in a regular expression matches the preceding character either zero or one time?** - A. ? - B. \* - C. + - D. % - E. \$\ **Correct Answer:** A **68. The file script.sh in the current directory contains the following content:** \#!/bin/bash echo \$MYVAR The following commands are used to execute this script: MYVAR=value -./script.sh The result is an empty line instead of the content of the variable MYVAR. How should MYVAR be set in order to make script.sh display the content of MYVAR? - A. !MYVAR=value - B. env MYVAR=value - C. MYVAR=value - D. \$MYVAR=value - E. export MYVAR=value\ **Correct Answer:** E **69. What is the return value of a shell script after successful execution?** - A. 1 - B. 0 - C. -1 - D. -255 - E. 255\ **Correct Answer:** B **70. Which of the following commands creates the ZIP archive poems.zip containing all files in the current directory whose names end in.txt?** - A. zip \*.txt \> poems.zip - B. zcat \*.txt poems.zip - C. zip poems.zip \*.txt - D. zip cfz poems.zip \*.txt - E. cat \*.txt \| zip poems.zip\ **Correct Answer:** C **71. Which of the following statements are true regarding a typical shell script? (Choose two.)** - A. It has the executable permission bit set. - B. It starts with the two character sequence \#!. - C. It is located in /usr/local/scripts/. - D. It is located in /etc/bash/scripts/. - E. It is compiled into a binary file compatible with the current machine architecture.\ **Correct Answers:** A, B **72. Which of the following commands extracts the contents of the compressed archive file1.tar.gz?** - A. tar -czf file1.tar.gz - B. ztar file1.tar.gz - C. tar -xzf file1.tar.gz - D. tar \--extract file1.tar.gz - E. detar file1.tar.gz\ **Correct Answer:** C **73. Which of the following commands finds all lines in the file operating-systems.txt which contain the term linux, regardless of the case?** - A. igrep linux operating-systems.txt - B. less -i linux operating-systems.txt - C. grep -i linux operating-systems.txt - D. cut linux operating-systems.txt - E. cut \[Ll\] \[Ii\] \[Nn\] \[Uu\] \[Xx\] operating-systems.txt\ **Correct Answer:** C **74. Which one of the following statements concerning Linux passwords is true?** - A. All passwords can be decrypted using the system administrator\'s master password. - B. Passwords may never start with a non-letter. - C. Users cannot change their password once it has been set. - D. Passwords are only stored in hashed form. - E. Passwords may be at most six characters long.\ **Correct Answer:** D **75. Which of the following programs are web servers? (Choose two.)** - A. Apache - B. Postfix - C. Curl - D. Dovecot - E. NGINX\ **Correct Answers:** A, E **76. Which of the following Linux Distributions is derived from Red Hat Enterprise Linux?** - A. Raspbian - B. openSUSE - C. Debian - D. Ubuntu - E. CentOS\ **Correct Answer:** E **77. Which of the following statements is true about Free Software?** - A. It is developed by volunteers only. - B. It may be modified by anyone using it. - C. It must always be available free of charge. - D. It only runs on Linux. - E. It is only distributed as a compiled binary.\ **Correct Answer:** B **78. How is a new Linux computing instance provisioned in an IaaS cloud?** - A. The standard Linux installer has to be run through a remote console. - B. After buying a Linux distribution, its vendor delivers it to a cloud instance. - C. The installation has to be prepared in a local virtual machine which is then copied to the cloud. - D. The cloud hosting organization provides a set of pre-prepared images of popular Linux distributions. - E. A provider-specific configuration file describing the desired installation is uploaded to the cloud provider.\ **Correct Answer:** D **79. What are the differences between a private web browser window and a regular web browser window? (Choose three.)** - A. Private web browser windows do not allow printing or storing websites. - B. Private web browser windows do not store cookies persistently. - C. Private web browser windows do not support logins into websites. - D. Private web browser windows do not keep records in the browser history. - E. Private web browser windows do not send regular stored cookies.\ **Correct Answers:** B, D, E **80. What is the preferred source for the installation of new applications in a Linux-based operating system?** - A. The vendor\'s version management system - B. A CD-ROM disk - C. The distribution\'s package repository - D. The vendor\'s website - E. A retail store\ **Correct Answer:** C **81. What information is stored in /etc/passwd? (Choose three correct answers.)** - A. The user\'s storage space limit - B. The numerical user ID - C. The username - D. The encrypted password - E. The user\'s default shell\ **Correct Answers:** B, C, E Feel free to ask if you need any more modifications or additions!

Use Quizgecko on...
Browser
Browser