Linux Certification Practice Quiz

Reviewed by Editorial Team
The ProProfs editorial team is comprised of experienced subject matter experts. They've collectively created over 10,000 quizzes and lessons, serving over 100 million users. Our team includes in-house content moderators and subject matter experts, as well as a global network of rigorously trained contributors. All adhere to our comprehensive editorial guidelines, ensuring the delivery of high-quality content.
Learn about Our Editorial Process
| By Lakshmoji
L
Lakshmoji
Community Contributor
Quizzes Created: 1 | Total Attempts: 813
| Attempts: 813 | Questions: 79
Please wait...
Question 1 / 79
0 %
0/100
Score 0/100
1. Identify the Linux command that renames a file named oldfile  to  newfile  in current working directory.

Explanation

The correct answer is "mv oldfile newfile". The "mv" command in Linux is used to move or rename files and directories. In this case, the command renames the file "oldfile" to "newfile" in the current working directory.

Submit
Please wait...
About This Quiz
Linux Certification Practice Quiz - Quiz

This Linux Certification Practice quiz assesses key skills in file management, directory navigation, and command-line usage. It is designed for learners preparing for Linux certification, enhancing both fundamental and advanced Linux command knowledge.

Tell us your name to personalize your report, certificate & get on the leaderboard!
2. What command can you use to remove a directory with files in it in Linux.

Explanation

The correct answer is "rm -r" because the "rm" command is used to remove files and directories in Linux, and the "-r" option is used to remove directories and their contents recursively. Therefore, "rm -r" is the command that can be used to remove a directory with files in it in Linux.

Submit
3. Which of the following are all valid basic file permissions under Linux?

Explanation

The correct answer is "Read, Write, Execute". These are the three basic file permissions in Linux. The "Read" permission allows a user to view the contents of a file, the "Write" permission allows a user to modify the file, and the "Execute" permission allows a user to run the file as a program.

Submit
4. Given the following -rwxr-x-w- 2  paul students    127 Oct 5 13:37 filetwo Who is the owner of filetwo?

Explanation

The owner of filetwo is "paul" because in the given file permission string "-rwxr-x-w-", the first character indicates the file type (in this case, it is a regular file), the next three characters "rwx" represent the permissions for the owner (paul), the next three characters "r-x" represent the permissions for the group (students), and the last three characters "-w-" represent the permissions for others.

Submit
5. The command that displays the name of current shell is ____________________.

Explanation

The correct answer is "echo $SHELL" because the "echo" command is used to display the value of a variable, and "$SHELL" is a special variable that holds the name of the current shell being used. By executing this command, the name of the current shell will be printed on the console.

Submit
6. You use the ______ symbol to mark the beginning of a comment in a script.

Explanation

The correct answer is "#". In scripting, the "#" symbol is used to mark the beginning of a comment. Comments are lines of code that are not executed by the computer and are used to provide explanations or notes for the human reader.

Submit
7. Which of the following uses the bash shell for the command interpreter in a script?

Explanation

The correct answer is "#!/bin/bash". This is because the "#!" symbol, also known as the shebang, is used to specify the interpreter for the script. In this case, "/bin/bash" is specified as the interpreter, indicating that the bash shell should be used to interpret the commands in the script.

Submit
8. The command find . -name practice would search from?

Explanation

The command "find . -name practice" is used to search for files or directories with the name "practice" within the current directory. The "." represents the current directory, so the search will start from the current directory and search recursively through all subdirectories. Therefore, the correct answer is the current directory.

Submit
9. Identify the command that is used to delete an existing group in Linux

Explanation

The correct answer is "groupdel". In Linux, the "groupdel" command is used to delete an existing group. This command removes the specified group from the system, along with any associated files or directories owned by that group. The other options listed, such as "gpasswd", "groupmod", and "userdel", are not specifically used for deleting groups in Linux.

Submit
10. The Linux command that allows for deleting a directory, but only if it is empty_____________.

Explanation

The Linux command "rmdir" is used to delete a directory, but it can only delete a directory if it is empty. If the directory contains any files or subdirectories, the "rmdir" command will not work and will display an error message. Therefore, "rmdir" is the correct answer for this question.

Submit
11. __________ is the operator that is used when you want one command to execute only if another command executes successfully.

Explanation

The correct answer is &&. The && operator is used in programming when you want one command to execute only if another command executes successfully. It is also known as the logical AND operator.

Submit
12. Identify the linux command used to display the inode number of /etc/fstab

Explanation

The correct answer is "ls -i /etc/fstab". The "-i" option is used with the "ls" command to display the inode number of a file or directory. In this case, it is used to display the inode number of the file "/etc/fstab".

Submit
13. What are the permissions in octal mode of the file fileone, given the file listing below: -rwxr-x-w- 2 steven studends   12 Feb 6 10:37 fileone

Explanation

The file listing shows that the file fileone has the permissions -rwxr-x-w-. In octal mode, each permission is represented by a digit. The first digit represents the owner's permissions, the second digit represents the group's permissions, and the third digit represents the permissions for others. The permissions are assigned values as follows: read (4), write (2), and execute (1).

For the owner, the permissions are rwx, which translates to 4+2+1=7 in octal mode.
For the group, the permissions are r-x, which translates to 4+0+1=5 in octal mode.
For others, the permissions are -w-, which translates to 0+2+0=2 in octal mode.

Therefore, the octal mode permissions for the file fileone are 752.

Submit
14. Based on /etc/fstab: /dev/sda1                     /                        ext3                defaults                              1    1 /dev/sda2                     swap                swap              defaults                              0    0 /dev/sda3                    /mnt/new          ext3                noauto                                2    2 /dev/fd0                      /mnt/floppy       ext2                auto, users                         0    0 /dev/cdrom                /mnt/cdrom       iso9660          auto, nouser                       0    0 To successfully mount /dev/cdrom , you should log on as _______.

Explanation

To successfully mount /dev/cdrom, you should log on as root.

Submit
15. What is the file that stores encrypted user passwords?

Explanation

The file that stores encrypted user passwords is /etc/shadow. This file is commonly found in Unix-like operating systems and contains information about user accounts, including their hashed passwords. The passwords are stored in an encrypted format to enhance security and protect against unauthorized access. Access to this file is restricted to privileged users only, ensuring that sensitive password information remains confidential.

Submit
16. What is the command used to quit without saving in vim?

Explanation

The correct answer is ":q!" because it is the command used to quit vim without saving any changes made to the file. The exclamation mark (!) is added to force the quit operation, discarding any unsaved modifications. The other options mentioned, such as ":wq" (write and quit), ":w" (write), ":q" (quit), and "none of the above" do not fulfill the requirement of quitting without saving.

Submit
17. Answer based on the output of fdisk -l /dev/sda: Disk /dev/sda: 16/1 GB, 16106127360 bytes 255 heads, 63 sectors/track, 1958 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device                     Boot                   Start                    End                 Blocks                Id                 System /dev/sda1                   *                         1                       1657                 13309821           83                  Linux /dev/sda2                                           1658                   1912                  2048284+          82                  Linux swap/Solaris /dev/sda3                                           1913                   1929                  56227+              5                    Extended /dev/sda5                                           1913                   1914                  16033+             82                   Linux swap/Solaris /dev/sda6                                           1915                   1916                  16033+             83                   Linux /dev/sda7                                           1917                   1919                  24066               83                   Linux The extended partition is __________?

Explanation

Based on the output of the fdisk -l command, the extended partition is /dev/sda3. This can be determined by looking at the "System" column, which shows that /dev/sda3 has a system ID of 5, indicating that it is an extended partition.

Submit
18. What special variable is used to determine the exit status of a previously executed command?

Explanation

The special variable "$?" is used to determine the exit status of a previously executed command. It holds the value of the exit status, which is a number indicating whether the command was successful (usually 0) or if there was an error (usually a non-zero value). This variable is commonly used in shell scripting to check the success or failure of a command and make decisions based on it.

Submit
19. ____________ is the symbol used to separate commands in a list, which are executed sequentially.

Explanation

The symbol ";" is used to separate commands in a list, which are executed sequentially.

Submit
20. What must you type in order for child shells to be able to use functions created in the parent shell?

Explanation

To make functions created in the parent shell accessible to child shells, the "export -f" command must be typed. This command exports the function to the environment, allowing child shells to use it. The "env" command is used to display the current environment variables. The "set" command is used to set shell options and positional parameters. Typing the name of the function alone will not make it accessible to child shells.

Submit
21. Which command is used to change the ownership of a file in Linux?

Explanation

In Linux, the chown command is used to change the ownership of a file or directory. It allows you to assign a different owner and/or group to the file. The chmod command changes file permissions, while chgrp changes the group ownership. The ls command is used to list files and directories but does not modify ownership or permissions.

Submit
22. What happens when you type the following command line at the given command prompt: user1@localhost : ~$ cd .

Explanation

When you type the command "cd ." in the given command prompt, it means you are trying to change the directory to the current directory itself. Since you are already in the current directory, there is no need to change it, so you remain in the current directory.

Submit
23. What is the output of the following? echo "$(pwd)"

Explanation

The given command "echo "$(pwd)"" will print the current directory path. The "$(pwd)" is a command substitution which will be replaced by the output of the "pwd" command, which stands for "print working directory". Therefore, the output of the command will be the current directory path.

Submit
24. What is the result? for animal in cat dog bear do echo $animal done

Explanation

The given code is a simple loop that iterates over the words "cat", "dog", and "bear" one by one. The echo command is used to display each word on a separate line. Therefore, the output will be "cat", "dog", and "bear" displayed on separate lines.

Submit
25. What do you type to pause your script for two seconds?

Explanation

The correct answer is "sleep 2". In programming, the "sleep" command is used to pause the execution of a script for a specified amount of time. In this case, "sleep 2" indicates that the script should pause for 2 seconds before continuing. The other options ("wait 2", "pause 2", and "none of the above") are not valid commands for pausing a script.

Submit
26. Which of the following commands can be used to verify if user has been created in the file system?

Explanation

The correct answer is "cat /etc/passwd|grep user1". This command allows us to view the contents of the /etc/passwd file, which contains information about all the users on the system. By using the grep command with the specific username "user1", we can search for that user's information in the file. If the user exists, their details will be displayed.

Submit
27. Select all the ways you can cd into test1 , a sub-directory of user1's home directory, /home/user1, given the command promt listed below (SELECT ALL THAT APPLY) user1@localhost: /bin$

Explanation

The correct answer is selecting "cd ~/test1" because the "~" character is a shorthand representation for the user's home directory. So, "cd ~/test1" will take the user to the test1 sub-directory of user1's home directory.

Submit
28. Identify the root user accounts home directory in Linux

Explanation

The correct answer is /root. In Linux, the root user is the superuser with administrative privileges. The root user's home directory is typically located at /root. This directory serves as the root user's default working directory and contains their personal configuration files and data.

Submit
29. Based on /etc/fstab: /dev/sda1               /                    ext3                   defaults         1 1 /dev/sda2             swap              swap                 defaults          0 0 /dev/sda3             /mnt/new       ext3                   noauto            2 2 /dev/fd0               /mnt/floppy    ext2                   auto, users     0 0 /dev/cdrom         /mnt/cdrom    iso9660             auto, nouser   0 0 Which device/partition is not mounted automatically during startup? 

Explanation

The device/partition that is not mounted automatically during startup is /dev/sda3. This is indicated by the "noauto" option in the /etc/fstab file, which means that it will not be mounted automatically at boot time.

Submit
30. Which of the following statements is used to display the length of the data value of the second element in an array named tests.

Explanation

The correct answer is "echo ${#tests[1]}". In Bash, the "#" symbol is used to get the length of a variable or array element. In this case, ${#tests[1]} will display the length of the data value of the second element in the array named "tests".

Submit
31. Identify the environment variable that defines primary prompt.

Explanation

The correct answer is PS1. PS1 is an environment variable that defines the primary prompt in Unix-like operating systems. It allows users to customize the appearance of their command prompt by setting various parameters such as colors, display of username, hostname, current working directory, and more. By modifying the value of PS1, users can create personalized and informative prompts that suit their preferences and needs.

Submit
32. Log in as root, and run the following commands: mkdir ~/test1 cd ~/test1 mkdir -p parent/child touch f1 f2 f3 cp f3 f4 mv f1 f2 f3 ./parent/child cp f4 ./parent/child/f5 cd parent cd ../../ pwd rmdir ~/test1/parent/child rm -r ~/test1/parent How many directories have been successfully removed?

Explanation

Two directories have been successfully removed. The command "rmdir ~/test1/parent/child" removes the "child" directory, and the command "rm -r ~/test1/parent" removes the "parent" directory.

Submit
33. You use the _______ statement to display all the elements in an array named labs.

Explanation

The correct answer is "echo ${labs[*]}". This is because the "${labs[*]}" syntax is used to display all the elements in an array named "labs". The "${labs}" syntax without the [*] will only display the first element in the array. The "${labs[0]}" syntax will also only display the first element in the array. The "${labs[#]}" syntax is not a valid syntax for displaying elements in an array.

Submit
34. Login as joot, to change to login shell to /bin/csh  for user1, you type ____________.

Explanation

To change the login shell to /bin/csh for user1, the correct command is "usermod -s /bin/csh user1". This command modifies the user account settings and sets the login shell to /bin/csh for the user named user1.

Submit
35. To immediately shutdown and halt a Linux machien from command line, you should:

Explanation

The correct answer is to log in as root and type "shutdown -h now". This command is used to shut down the Linux machine immediately. The "-h" option stands for halt, which means to power off the system after shutting down all processes. The "now" parameter indicates that the shutdown should happen immediately. By logging in as root, the user has the necessary permissions to execute this command.

Submit
36. Answer based on the output of fdisk -l /dev/sda: Disk /dev/sda: 16/1 GB, 16106127360 bytes 255 heads, 63 sectors/track, 1958 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device               Boot                Start               End                   Blocks                Id               System /dev/sda1            *                        1                 1657                   13309821           83                Linux /dev/sda2                                   1658             1912                    2048284+          82                Linux swap/Solaris /dev/sda3                                   1913             1929                    56227+              5                  Extended /dev/sda5                                   1913             1914                   16033+               82                Linux swap/Solaris /dev/sda6                                   1915             1916                   16033+              83                 Linux /dev/sda7                                   1917             1919                   24066                83                 Linux How many logical drives have been created?

Explanation

Based on the output of fdisk -l /dev/sda, there are three logical drives that have been created. These drives are represented by /dev/sda1, /dev/sda2, and /dev/sda7. Each drive has a different start and end cylinder, as well as a different system type (Linux or Linux swap/Solaris). Therefore, the correct answer is 3.

Submit
37. The command that displays all mounted devices ________________.

Explanation

The command "mount" is used to display all mounted devices.

Submit
38. Is the following the correct way of having a loop exit if 'Q' or 'q' was entered? while [  #CHOICE = 'Q' ] || [ $CHOICE = 'q' ]

Explanation

The given code is not the correct way of having a loop exit if 'Q' or 'q' was entered. The correct way would be to use a conditional statement within the loop, such as an if statement, to check if the input is equal to 'Q' or 'q'. If it is, then the loop can be exited using a break statement.

Submit
39. Which of the following would not place you in your home directory?

Explanation

The command "cd ~/username" would not place you in your home directory. The "~" symbol represents the home directory, so "cd ~" would take you to your home directory. However, appending "/username" to it would take you to a subdirectory named "username" within your home directory, not the home directory itself. Therefore, this command would not place you in your home directory.

Submit
40. Which of the following commands deletes user1 from /etc/passwd and removes user1's home directory and any files stored in it?

Explanation

The correct answer is "userdel -r user1". This command is used to delete a user account along with their home directory and any files stored in it. The "-r" option stands for "remove" and ensures that the user's home directory and its contents are deleted as well. The other options and commands mentioned do not include the "-r" option, so they would not remove the user's home directory and files.

Submit
41. Which linux command line copies directories dir1, dir2,  to dir3 (dir1,dir2 and dir3 are all located in the current working directory)?

Explanation

The correct answer is "cp -r dir1 dir2 dir3". The "-r" option is used to copy directories recursively, meaning it copies all files and subdirectories within the specified directories. Therefore, this command will copy dir1, dir2, and their contents into dir3.

Submit
42. Log in as root, and run the following commands: mkdir ~/test1 cd ~/test1 mkdir -p parent/child touch f1 f2 f3 cp f3 f4 mv f1 f2 f3 ./parent/child cp f4 ./parent/child/f5 cd parent cd ../../ pwd rmdir ~/test1/parent/child rm -r ~/test1/parent How many directories have been created (included deleted directories)?

Explanation

The command "mkdir ~/test1" creates the directory "test1". The command "mkdir -p parent/child" creates the directories "parent" and "child" inside "test1". So, two directories have been created. The command "rmdir ~/test1/parent/child" deletes the directory "child". The command "rm -r ~/test1/parent" deletes the directory "parent". So, two directories have been deleted. Therefore, the total number of directories created (including deleted directories) is 2 + 2 = 4.

Submit
43. What is the order of execution to prepare a partition for data storage in Linux?

Explanation

The correct order of execution to prepare a partition for data storage in Linux is fdisk, mkfs, fsck, mount. First, fdisk is used to create a partition on the disk. Then, mkfs is used to create a file system on the partition. After that, fsck is used to check the file system for any errors. Finally, the partition is mounted to make it accessible for use.

Submit
44. Answer based on the output of fdisk -l /dev/sda: Disk /dev/sda: 16/1 GB, 16106127360 bytes 255 heads, 63 sectors/track, 1958 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device        Boot          Start        End           Blocks                     Id          System /dev/sda1     *                 1            1657           13309821                83           Linux /dev/sda2                      1658        1912           2048284+               82           Linux swap/Solaris /dev/sda3                      1913        1929           56227+                   5             Extended /dev/sda5                      1913         1914          16033+                   82            Linux swap/Solaris /dev/sda6                      1915         1916          16033+                   83           Linux /dev/sda7                      1917        1919           24066                     83           Linux Identify whether new partitions or logical drives can be created without deleting an existing partition or adding a new hard drive.

Explanation

Based on the output of the fdisk command, it can be observed that there is one primary partition (/dev/sda1) and an extended partition (/dev/sda3) which contains logical drives (/dev/sda5, /dev/sda6, /dev/sda7). Therefore, the correct answer is that one primary partition and more than one logical drives can be created without deleting an existing partition or adding a new hard drive.

Submit
45. You can keep your preferred settings by creating a ________ file in vim.

Explanation

You can keep your preferred settings by creating a "vimrc" file in vim. The vimrc file is a configuration file for Vim that allows users to customize their preferred settings and key mappings. By creating and editing the vimrc file, users can personalize their Vim experience and make it more efficient and tailored to their needs.

Submit
46. Identify the command used to activate a swap partition

Explanation

The command "swapon" is used to activate a swap partition. This command is used in Linux systems to enable the swapping of data between the RAM and the swap space on the hard disk. By activating the swap partition with the "swapon" command, the system can utilize additional virtual memory when the physical memory (RAM) is running low.

Submit
47. What is the result of the following statements? ((g=5)) until [ $g -lt 1 ] do           echo $g          ((g--)) done

Explanation

The given code initializes the variable "g" with a value of 5. Then, it enters a loop that continues until the value of "g" is less than 1. Inside the loop, it prints the value of "g" and then decreases it by 1. This process continues until "g" becomes 0. Therefore, the output will be 5, 4, 3, 2, 1 displayed on separate lines.

Submit
48. Which of the following Linux commands  prevents you from accidentally overwriting a file when you redirect output to a file?

Explanation

The correct answer is "set -noclobber". This command prevents you from accidentally overwriting a file when you redirect output to a file. By using this command, if the file already exists, it will not be overwritten and an error message will be displayed instead.

Submit
49. The Linux command that prints the current working directory in absolute path.

Explanation

The Linux command "pwd" is used to print the current working directory in absolute path. This command displays the full path of the directory you are currently in, starting from the root directory. It is helpful to know the absolute path when navigating through the file system or when referencing specific directories in commands or scripts.

Submit
50. To redirect standard output and error of script1 to a file named outerr.txt, use the ___________ command.

Explanation

The correct answer is "script1 &> outerr.txt". This command redirects both the standard output and error of script1 to a file named outerr.txt. The "&>" symbol is used to redirect both outputs simultaneously.

Submit
51. The command that will set an option so a search of substitute ignores cases in vim:

Explanation

The correct answer is ":set ic". In Vim, the "ic" option stands for "ignorecase". When this option is set, the search and substitute commands will ignore the case sensitivity, meaning that uppercase and lowercase letters will be treated as the same. This can be useful when you want to perform searches or substitutions without being concerned about the case of the text.

Submit
52. To set default directory permission to rwx-wx-wx, you should set umask to _______.

Explanation

To set the default directory permission to rwx-wx-wx, you should set the umask to 044. Umask is a value that is subtracted from the default permissions to determine the actual permissions for newly created files and directories. In this case, the umask of 044 means that the read, write, and execute permissions are allowed for the owner of the file, while the group and others have only the write and execute permissions.

Submit
53. Login as root and run the following commands: groupadd group1 groupadd group2 useradd user1 useradd -G group1, group2 user3 useradd -G group2, user2 user3 useradd -g group2 user4 gpasswd -a user1 group1 gpasswd -d user2 group2 groups user4 What is the output produced by command: groups user4

Explanation

The output of the command "groups user4" is "group2". This is because the "groups" command lists the groups that a user is a member of, and in this case, user4 is only a member of the "group2" group.

Submit
54. Login as root to create a user account based on the following: username: user1 home directory: /home/userone What command should be used?

Explanation

The correct command to create a user account with the given username and home directory is "useradd -d /home/userone -m user1". The "-d" option is used to specify the home directory, and the "-m" option is used to create the home directory if it does not already exist. Therefore, this command will create a user account with the username "user1" and the home directory "/home/userone".

Submit
55. Log in as root, and run the following commands: mkdir ~/test1 cd ~/test1 mkdir -p parent/child touch f1 f2 f3 cp f3 f4 mv f1 f2 f3 ./parent/child cp f4 ./parent/child/f5 cd parent cd ../../ pwd rmdir ~/test1/parent/child rm -r ~/test1/parent What is the output of pwd  command?

Explanation

The output of the "pwd" command is "/root". This is because the "cd ../.." command moves two directories up from the current directory, which is "/root/test1/parent". Therefore, the current working directory becomes "/root".

Submit
56. Given the file permission  rw-r--r-- for a file names script1 , identify the chmod command that adds executable permissions for owner and group and removes read permission from others:

Explanation

The given file permission "rw-r--r--" means that the owner has read and write permissions, the group has only read permission, and others have only read permission as well. To add executable permission for the owner and group, we need to use the "7" in the chmod command, which represents read, write, and execute permissions. The "5" in "750" represents read and execute permissions for others. Therefore, the correct answer is "chmod 750 script1."

Submit
57. Would the following code in a script file print the contents of the variable $name? echo 'this is my $name'

Explanation

The code in the script file will not print the contents of the variable $name. The reason is that when using single quotes in the echo statement, variables are not expanded and are treated as literal strings. Therefore, the output will be "this is my $name" instead of the actual value of the variable $name.

Submit
58. Answer based on the output of fdisk -l /dev/sda: Disk /dev/sda: 16/1 GB, 16106127360 bytes 255 heads, 63 sectors/track, 1958 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device                Boot        Start              End            Blocks            Id                        System /dev/sda1             *               1                 1657            13309821       83                        Linux /dev/sda2                           1658             1912             2048284+      82                        Linux swap/Solaris /dev/sda3                           1913             1929             56227+          5                          Extended /dev/sda5                           1913             1914             16033+          82                        Linux swap/Solaris /dev/sda6                           1915             1916             16033+          83                        Linux /dev/sda7                           1917             1919             24066            83                        Linux List all primary partitions

Explanation

The correct answer is /dev/sda1, /dev/sda2. This is because in the output of fdisk -l /dev/sda, /dev/sda1 and /dev/sda2 are listed as primary partitions. The "Id" column for /dev/sda1 is 83, which indicates a Linux system, and the "Id" column for /dev/sda2 is 82, which indicates a Linux swap/Solaris system. Therefore, /dev/sda1 and /dev/sda2 are the primary partitions on the disk.

Submit
59. The command used to delete all characters from the cursor position to the end of the line in vim is ________

Explanation

The command "d$" is used to delete all characters from the cursor position to the end of the line in vim. The "d" stands for delete, and the "$" represents the end of the line. By combining these two commands, all characters from the current cursor position until the end of the line will be deleted.

Submit
60. What is the result when the following script is executed? array1={a b c d e} echo ${array1 [1+3] }

Explanation

The script initializes an array named array1 with the values "a", "b", "c", "d", and "e". The echo statement then attempts to display the value at index [1+3], which simplifies to index [4]. Since arrays in Bash start indexing from 0, the value at index 4 is "e". Therefore, when the script is executed, "e" is displayed.

Submit
61. What environment variable is used to store the file name used to store command history in bash shell?

Explanation

The environment variable used to store the file name used to store command history in the bash shell is HISTFILE. This variable allows users to specify the location and name of the file where the command history will be stored. By default, the command history is saved in the file specified by the value of HISTFILE.

Submit
62. Given the following: -rwxr-x-w- 2 students 127 Oct 5 13:37 filetwo which of the following is the right command to change filetwo's owner to jack?

Explanation

The correct command to change filetwo's owner to jack is "chown filetwo jack". This command changes the owner of the file "filetwo" to "jack".

Submit
63. To search a string "test2" in the BACKWARD direction in vim,  you type __________

Explanation

In vim, to search a string in the backward direction, you can use the command "?test2". This command will search for the string "test2" in the text, starting from the current cursor position and moving backwards.

Submit
64. Which of the following statments is used to display the length of an array named lectures.

Explanation

The correct answer is "echo ${#lectures[*]}". In Bash, the syntax ${#array_name[*]} is used to display the length of an array. In this case, it will display the length of the array named "lectures".

Submit
65. Which of the following options for useradd command is used to prevent Linux from creating a group with the same name as username?

Explanation

The option "-N" is used with the useradd command to prevent Linux from creating a group with the same name as the username. This option ensures that a separate group is not created automatically when a new user is added.

Submit
66. Which of the following commands is used to list the contents of a directory in Linux?

Explanation

In Linux, the ls command is your primary tool for navigating the file system. It displays the contents of a directory, including files and subdirectories. You can customize its output with various options, such as -l for a detailed list, -a to show hidden files, or -h for human-readable file sizes.

Submit
67. Based on /etc/fstab: /dev/sda1           /                    ext3                  defaults              1     1 /dev/sda2         swap              swap                defaults               0     0 /dev/sda3         /mnt/new       ext3                  noauto                 2     2 /dev/fd0           /mnt/floppy    ext2                  auto, users          0     0 /dev/cdrom     /mnt/cdrom    iso9660            auto, nouser        0     0 Identify the correct command line that is used to mount /dev/sda3  ___________ (SELECT ALL THAT APPLY)

Explanation

The correct command line that is used to mount /dev/sda3 is "mount /dev/sda3" or "mount /mnt/new".

Submit
68. To make user4 the administrator of group1, login as root and type ___________

Explanation

To make user4 the administrator of group1, the correct command to use is "gpasswd -A user4 group1". This command adds user4 to the administrators list of group1, giving them administrative privileges within the group.

Submit
69. What a umask of 066, which will be the default file permission?

Explanation

A umask of 066 means that the permissions that are masked or removed from the default permissions are read, write, and execute for the group and others. Therefore, the default file permission would be rw-------, which means that the owner has read and write permissions, while the group and others have no permissions.

Submit
70. What is the command that is used to create a swap filesystem.

Explanation

The correct answer is "mkfs". This command is used to create a filesystem on a disk partition or a storage device. It is commonly used to format a partition with a specific filesystem type, such as ext4 or NTFS. However, in the context of the question, it is specifically used to create a swap filesystem. Swap space is a designated area on a disk that is used as virtual memory by the operating system when the physical memory (RAM) is full. Creating a swap filesystem using mkfs allows the system to use disk space as additional memory when needed.

Submit
71. Log in as root, and run the following commands: mkdir ~/test1 cd ~/test1 mkdir -p parent/child touch f1 f2 f3 cp f3 f4 mv f1 f2 f3 ./parent/child cp f4 ./parent/child/f5 cd parent cd ../../ pwd rmdir ~/test1/parent/child rm -r ~/test1/parent How many regular files are left in ~/test1 after executing the above commands??

Explanation

After executing the above commands, only one regular file, "f2", is left in the directory ~/test1. The other regular files "f1", "f3", "f4", and "f5" have been either moved or copied to the directory ~/test1/parent/child, or deleted using the "rm" command. Therefore, the correct answer is 1.

Submit
72. If user1 is a valid account and the home directory for user1 is /home/user1, the command usermod -d /home/user1_home user1 will _________________________.

Explanation

The command "usermod -d /home/user1_home user1" will only change the home directory of user1 in the file /etc/passwd. It will not create a new directory or delete any previous directories. The command updates the user's home directory information in the system's user database, allowing the user to access their files and settings from the new directory specified.

Submit
73. Which of the following statements about minimum permissions needed to delete a file in Linux is true?

Explanation

To delete a file in Linux, the user needs to have write permissions on the directory where the file is located. This allows the user to modify the contents of the directory, including deleting files. However, no specific permissions are required for the file itself. Therefore, the correct answer is "for the directory: write(w) and execute, for the file: none."

Submit
74. Login as root, identify the Linux command used to give everyone full access permission to directory /public (select all that apply)

Explanation

The Linux command "chmod" is used to change the permissions of a file or directory. The numbers 777 represent full access permission for the owner, group, and others, respectively. The command "chmod 777 /public" gives everyone full access permission to the directory /public. Similarly, the commands "chmod ugo=rwx /public", "chmod a+rwx /public", "chmod ugo+rwx /public", and "chmod a+rwx /public" also give everyone full access permission to the directory /public.

Submit
75. Which of the following is true about hard link in Linux (SELECT ALL THAT APPLY)

Explanation

Multiple hard links can be created to the same file, meaning that multiple names can be associated with the same inode number. Therefore, all hard links have the same inode number as the original file. If the original file is removed, all hard links become meaningless or orphan links. However, the physical file will not be removed from the disk until all hard links are deleted. Therefore, the correct answer is that you may create multiple hard links to the same file, all hard links have the same inode number as the original files, and the physical file will not be removed from the disk until all hard links are deleted.

Submit
76. Login as root and run the following commands: groupadd group1 groupadd group2 useradd user1 useradd -G group1, group2 user3 useradd -G group2, user2 user3 useradd -g group2 user4 gpasswd -a user1 group1 gpasswd -d user2 group2 groups user4 Who is a member of group1? (SELECT ALL THAT APPLY)

Explanation

Based on the given commands, user1 is added to group1 using the command "gpasswd -a user1 group1". However, user2 is removed from group2 using the command "gpasswd -d user2 group2". Therefore, the members of group1 are user1 and user2.

Submit
77. Login as root and run the following commands: groupadd group1 groupadd group2 useradd user1 useradd -G group1, group2 user3 useradd -G group2, user2 user3 useradd -g group2 user4 gpasswd -a user1 group1 gpasswd -d user2 group2 groups user4 Who is a member of group2? (SELECT ALL THAT APPLY)

Explanation

The command "useradd -G group1, group2 user3" adds user3 to both group1 and group2.
The command "useradd -G group2, user2 user3" adds user3 to group2 and user2 to user3.
The command "useradd -g group2 user4" adds user4 to group2.
The command "gpasswd -a user1 group1" adds user1 to group1.
The command "gpasswd -d user2 group2" removes user2 from group2.
Finally, the command "groups user4" checks the groups that user4 is a member of.
Therefore, the correct answer is user3 and user4.

Submit
78. Login as root and run the following commands: groupadd group1 groupadd group2 useradd user1 useradd -G group1, group2 user3 useradd -G group2, user2 user3 useradd -g group2 user4 gpasswd -a user1 group1 gpasswd -d user2 group2 groups user4 Who is a member of user 2? (SELECT ALL THAT APPLY)

Explanation

Based on the given commands, user2 and user3 are both members of group2. Therefore, both user2 and user3 are members of each other.

Submit
79. Given the following: -rwxr-x-w- 2 students 127 Oct 5 13:37 filetwo to change the group students  to  faculty, you type _________________(SELECT ALL THAT APPLY)

Explanation

To change the group of the file "filetwo" to "faculty", the correct commands are "chgrp faculty filetwo". The command "chmod jack.faculty filetwo" is incorrect because it is not a valid command.

Submit
View My Results

Quiz Review Timeline (Updated): Nov 25, 2024 +

Our quizzes are rigorously reviewed, monitored and continuously updated by our expert board to maintain accuracy, relevance, and timeliness.

  • Current Version
  • Nov 25, 2024
    Quiz Edited by
    ProProfs Editorial Team
  • Jan 07, 2019
    Quiz Created by
    Lakshmoji
Cancel
  • All
    All (79)
  • Unanswered
    Unanswered ()
  • Answered
    Answered ()
Identify the Linux command that renames a file named oldfile ...
What command can you use to remove a directory with files in it in...
Which of the following are all valid basic file permissions under...
Given the following...
The command that displays the name of current shell is...
You use the ______ symbol to mark the beginning of a comment in a...
Which of the following uses the bash shell for the command interpreter...
The command find . -name practice would search from?
Identify the command that is used to delete an existing group in Linux
The Linux command that allows for deleting a directory, but only if it...
__________ is the operator that is used when you want one command to...
Identify the linux command used to display the inode number of...
What are the permissions in octal mode of the file fileone, given the...
Based on /etc/fstab:...
What is the file that stores encrypted user passwords?
What is the command used to quit without saving in vim?
Answer based on the output of fdisk -l /dev/sda:...
What special variable is used to determine the exit status of a...
____________ is the symbol used to separate commands in a list, which...
What must you type in order for child shells to be able to use...
Which command is used to change the ownership of a file in Linux?
What happens when you type the following command line at the given...
What is the output of the following? echo "$(pwd)"
What is the result?...
What do you type to pause your script for two seconds?
Which of the following commands can be used to verify if user has been...
Select all the ways you can cd into test1 , a sub-directory of...
Identify the root user accounts home directory in Linux
Based on /etc/fstab:...
Which of the following statements is used to display the length of the...
Identify the environment variable that defines primary prompt.
Log in as root, and run the following commands:...
You use the _______ statement to display all the elements in an array...
Login as joot, to change to login shell to /bin/csh  for user1,...
To immediately shutdown and halt a Linux machien from command line,...
Answer based on the output of fdisk -l /dev/sda:...
The command that displays all mounted devices ________________.
Is the following the correct way of having a loop exit if 'Q'...
Which of the following would not place you in your home directory?
Which of the following commands deletes user1 from /etc/passwd...
Which linux command line copies directories dir1, dir2,  to dir3...
Log in as root, and run the following commands:...
What is the order of execution to prepare a partition for data storage...
Answer based on the output of fdisk -l /dev/sda:...
You can keep your preferred settings by creating a ________ file in...
Identify the command used to activate a swap partition
What is the result of the following statements?...
Which of the following Linux commands  prevents you from...
The Linux command that prints the current working directory in...
To redirect standard output and error of script1 to a file named...
The command that will set an option so a search of substitute ignores...
To set default directory permission to rwx-wx-wx, you should set umask...
Login as root and run the following commands:...
Login as root to create a user account based on the following:...
Log in as root, and run the following commands:...
Given the file permission  rw-r--r-- for a file names script1 ,...
Would the following code in a script file print the contents of the...
Answer based on the output of fdisk -l /dev/sda:...
The command used to delete all characters from the cursor position to...
What is the result when the following script is executed?...
What environment variable is used to store the file name used to store...
Given the following:...
To search a string "test2" in the BACKWARD direction in...
Which of the following statments is used to display the length of an...
Which of the following options for useradd command is used to prevent...
Which of the following commands is used to list the contents of a...
Based on /etc/fstab:...
To make user4 the administrator of group1, login as root and type...
What a umask of 066, which will be the default file permission?
What is the command that is used to create a swap filesystem.
Log in as root, and run the following commands:...
If user1 is a valid account and the home directory for user1 is...
Which of the following statements about minimum permissions needed to...
Login as root, identify the Linux command used to give everyone full...
Which of the following is true about hard link in Linux (SELECT ALL...
Login as root and run the following commands:...
Login as root and run the following commands:...
Login as root and run the following commands:...
Given the following:...
Alert!

Advertisement