1.
The number of users logged in is in a variable called USERS. How would you test to see if 5 users are logged in?
Correct Answer
E. Test $USERS –eq 5
Explanation
The correct answer is "test $USERS –eq 5". This is the correct way to test if the value of the variable USERS is equal to 5. The "-eq" operator is used to check for equality in shell scripting. Therefore, this command will evaluate to true if the value of USERS is indeed 5, and false otherwise.
2.
Given the following script:
while [ ! –f /tmp/foo ]; do
echo –n “.”
process_data > /tmp/foo
done
Which of the following are true?
(choose two)
Correct Answer(s)
D. If a file called /tmp/foo exists, process_data won’t be run
E. Process_data will be called at most once
Explanation
The screen will fill with dots because the script contains a while loop that will continue executing the echo command until the file /tmp/foo exists. The echo command is used to print a dot on the screen.
If a file called /tmp/foo exists, process_data won't be run because the condition in the while loop checks for the existence of the file /tmp/foo using the -f flag. If the file exists, the loop will exit and process_data will not be executed.
process_data will be called at most once because once the file /tmp/foo is created by the process_data command, the condition in the while loop will evaluate to false and the loop will exit. Therefore, process_data will only be called once.
/tmp/foo will be removed if it exists is not true because there is no command or statement in the given script that removes the file /tmp/foo.
Therefore, the correct answers are: If a file called /tmp/foo exists, process_data won’t be run and process_data will be called at most once.
3.
A conditional that lets you make multiple comparisons with a pattern is called:
Correct Answer
D. Case
Explanation
A conditional that lets you make multiple comparisons with a pattern is called a "case". This is because a case statement allows you to evaluate multiple conditions and execute different blocks of code depending on the value of the variable being evaluated. It is commonly used when there are multiple possible outcomes or conditions that need to be checked against a single variable.
4.
What is the meaning of $(( $i + 1)) ?
Correct Answer
C. 1 will be added to the i variable
Explanation
The correct answer is "1 will be added to the i variable." This is because the expression $(( $i + 1)) is an arithmetic expansion in bash, where the value of i is incremented by 1. The double parentheses $(( )) are used to perform arithmetic operations in bash, and in this case, it adds 1 to the value of i.
5.
How would you write a test that says “if /tmp/foo is a directory or USERS is greater than 5”?
Correct Answer
D. Test –d /tmp/foo –o $USERS –gt 5
Explanation
The correct answer is "test –d /tmp/foo –o $USERS –gt 5". This answer uses the "test" command with the "-d" flag to check if "/tmp/foo" is a directory. It also uses the "-o" flag to combine this condition with the condition that "$USERS" is greater than 5. This test will return true if either condition is met.
6.
A division of a hard drive may be referred to as a _______ .
Correct Answer(s)
A. Partition
C. Slice
Explanation
A division of a hard drive is commonly referred to as a partition or a slice. This is because a hard drive can be divided into separate sections or partitions, each of which can be used to store data independently. These partitions or slices allow for better organization and management of data on the hard drive.
7.
Which of the following are valid partitioning types?
(choose two)
Correct Answer(s)
A. MBR
C. GPT
Explanation
MBR (Master Boot Record) and GPT (GUID Partition Table) are valid partitioning types. MBR is a traditional partitioning scheme used on BIOS-based systems, while GPT is a newer partitioning scheme commonly used on UEFI-based systems. Both MBR and GPT allow for the division of a storage device into multiple partitions, each with its own file system. PC and BIOS, on the other hand, are not valid partitioning types and do not refer to any specific partitioning schemes.
8.
The fdisk command is a tool used for working with the MBR partitioned disks.
True or False?
Correct Answer
A. True
Explanation
The fdisk command is indeed a tool used for working with the MBR partitioned disks. It allows users to create, delete, and manage partitions on a disk. This command is commonly used in Linux and Unix systems to manage disk partitions. Therefore, the given answer "True" is correct.
9.
Which of the following is the valid device file name for the first IDE hard drive on the system?
Correct Answer
C. /dev/hda
Explanation
The correct answer is /dev/hda. In Linux systems, device files are used to access hardware devices. The /dev/hda file represents the first IDE hard drive on the system. The "hda" naming convention is commonly used for IDE hard drives, with "hd" indicating a hard drive and "a" representing the first drive. Therefore, /dev/hda is the valid device file name for the first IDE hard drive on the system.
10.
Which of the following are valid video cable connector types?
(choose two)
Correct Answer(s)
B. DVI
C. VGA
Explanation
DVI (Digital Visual Interface) and VGA (Video Graphics Array) are both valid video cable connector types. DVI is a digital video connector commonly used to connect a computer to a monitor or projector. It supports high-quality video signals and can transmit both digital and analog signals. VGA, on the other hand, is an older analog video connector that is still widely used. It is commonly found on older computers and displays and can support lower resolutions compared to DVI. Both DVI and VGA connectors are commonly used in the video industry and are compatible with various devices.
11.
A command that will continuously update statistics about running processes:
Correct Answer
A. Top
Explanation
The correct answer is "top" because the "top" command in Linux continuously updates and displays real-time information about running processes, including CPU and memory usage, process IDs, and more. It provides a dynamic view of the system's performance and allows users to monitor and manage processes effectively.
12.
The following are valid Linux option styles:
(choose three)
Correct Answer(s)
A. Traditional Unix with a single dash (-)
B. BSD Unix without a dash
D. GNU long options with two dashes (–)
Explanation
The question is asking for the valid Linux option styles. The correct answer is Traditional Unix with a single dash (-), BSD Unix without a dash, and GNU long options with two dashes (–). These are the commonly used option styles in Linux. The Traditional Unix style uses a single dash before the option, BSD Unix style does not use a dash, and GNU long options style uses two dashes before the option. DOS slash style is not a valid Linux option style.
13.
Which file contains the information passed to the kernel at boot time?
Correct Answer
D. /proc/cmdline
Explanation
The /proc/cmdline file contains the information passed to the kernel at boot time. This file provides the command line arguments that were used to boot the kernel, including options such as the kernel version, root device, and other parameters. It is a virtual file that can be accessed to view or modify the command line arguments used during the boot process.
14.
To make changes permanent for kernel parameter files found under /proc/sys, the following file can have entries added to it:
Correct Answer
A. /etc/sysctl.conf
Explanation
The correct answer is /etc/sysctl.conf. This file is used to configure kernel parameters and allows entries to be added to make changes permanent for kernel parameter files found under /proc/sys. By adding entries to /etc/sysctl.conf, the changes will persist even after a system reboot.
15.
To get a list of all packages installed on a system using RPM Package Management you can execute:
Correct Answer
A. Rpm -qa
Explanation
The command "rpm -qa" is used to get a list of all packages installed on a system using RPM Package Management. This command queries the RPM database and returns a list of all installed packages.
16.
Which of the following would be considered a host?
Correct Answer
D. A printer attached to the network via an IP address
Explanation
A host refers to a device or a computer system that is connected to a network and is capable of sending or receiving data. In this context, a printer attached to the network via an IP address can be considered a host as it is connected to the network and can receive print jobs from other devices on the network. The computer's hard drive, network cable, and CDROM are not considered hosts as they do not have the capability to send or receive data on a network.
17.
What option to the netstat command has information shown as numbers rather than names?
Correct Answer
B. -n
Explanation
The option "-n" in the netstat command displays information as numbers rather than names. This means that instead of showing the names of the network connections, it will display the corresponding numerical IP addresses and port numbers. This can be useful for troubleshooting network issues or for obtaining a more detailed understanding of the network connections.
18.
Which of the following commands will allow you to log into the machine server1 with the account name nick?
Correct Answer
A. Ssh nick@server1
Explanation
The correct answer is "ssh nick@server1". This command uses the SSH protocol to log into the machine named "server1" with the account name "nick". The "@" symbol is used to separate the account name from the server name in SSH commands.
19.
The RSA key fingerprint allows the dig command to connect to remote systems.
True or False?
Correct Answer
B. False
Explanation
The RSA key fingerprint does not allow the dig command to connect to remote systems. The dig command is primarily used for DNS queries and does not require or use RSA key fingerprints for its functionality. Therefore, the statement is false.
20.
Which files contain user account information?
(choose two)
Correct Answer(s)
A. /etc/shadow
C. /etc/passwd
Explanation
The files /etc/shadow and /etc/passwd contain user account information. The /etc/shadow file stores encrypted passwords for user accounts, while the /etc/passwd file contains basic user account information such as usernames and user IDs. These files are commonly used in Unix-like operating systems to manage user accounts and authentication.
21.
Sudo privileges can be used to specify which user can use the sudo command to execute commands as other users.
True or False?
Correct Answer
A. True
Explanation
Sudo privileges allow for the specification of which user can use the sudo command to execute commands as other users. This means that certain users can be granted the ability to temporarily elevate their privileges and perform tasks that are typically restricted to other users or the root user. Therefore, the statement that sudo privileges can be used to specify which user can use the sudo command to execute commands as other users is true.
22.
In distributions that do not allow the root user to login directly or via the su command, the installation process automatically configures one user account to be able to use the sudo command to execute commands as if they were executed by the root user.
True or False?
Correct Answer
A. True
Explanation
In distributions that do not allow the root user to login directly or via the su command, the installation process automatically configures one user account to be able to use the sudo command to execute commands as if they were executed by the root user. This means that the user account has the necessary privileges to perform administrative tasks without actually logging in as the root user. Therefore, the statement is true.
23.
Which of the following commands will display how long the system has been running since the last boot?
(choose two)
Correct Answer(s)
B. W
D. Uptime
Explanation
The commands "w" and "uptime" can be used to display how long the system has been running since the last boot. The "w" command shows the current system time and the duration since the last boot, while the "uptime" command specifically provides information about the system uptime. Both commands are commonly used in Linux and Unix systems to check the system's uptime.
24.
The /etc/shadow file contains plain-text passwords.
True or False?
Correct Answer
B. False
Explanation
The given statement is false. The /etc/shadow file does not contain plain-text passwords. It is a system file on Unix-like operating systems that stores encrypted user passwords. The passwords are hashed and salted, providing an extra layer of security compared to storing them in plain text. This helps protect the passwords from being easily compromised in the event of a security breach.
25.
Which command can be used to view the /etc/passwd file entries?
Correct Answer
A. Getent
Explanation
The command "getent" can be used to view the /etc/passwd file entries. This command is used to retrieve entries from databases configured in /etc/nsswitch.conf, including the passwd database which contains user account information. By running "getent passwd", the user can view the list of users and their corresponding details stored in the /etc/passwd file.
26.
Which command can be used to determine a user’s most recent log in?
Correct Answer
B. Last
Explanation
The command "last" can be used to determine a user's most recent log in. This command displays a list of the most recent logins, including the date, time, and duration of each session. It provides information about the user's activities and can be helpful for monitoring user access and detecting any unauthorized logins.
27.
Which of the following files contains encrypted user password information?
Correct Answer
B. /etc/shadow
Explanation
The correct answer is /etc/shadow because this file is commonly used in Unix-based systems to store encrypted user password information. It is accessible only by the root user, providing an extra layer of security. The /etc/passwd file, on the other hand, contains user account information but does not store encrypted passwords. The /etc/usr and /etc/group files are unrelated to password information.
28.
Which of the following files contains user IDs?
Correct Answer
A. /etc/passwd
Explanation
The file "/etc/passwd" contains user IDs. This file is a system file in Unix-like operating systems that stores essential information about each user account on the system, including the user ID. It is used by various system utilities and processes to identify and authenticate users. The "/etc/group" file, on the other hand, contains information about user groups, while the "/etc/shadow" file stores encrypted passwords. The "/etc/usr" file mentioned in the options does not exist and is likely a typo or incorrect option.
29.
Which of the following files does the groupadd command use to determine the new GID when a GID isn’t specified?
Correct Answer
D. /etc/group
Explanation
The groupadd command uses the /etc/group file to determine the new GID when a GID isn't specified. This file contains information about groups on the system, including their names, GIDs, and the users who are members of each group. By checking this file, the groupadd command can assign a unique GID to a new group that is being created.
30.
Which of the following commands, run as root, will prevent the user bob from logging in?
Correct Answer
A. Usermod -L bob
Explanation
The correct answer is "usermod -L bob". The "-L" option in the usermod command locks the user account, preventing the user from logging in.
31.
The chmod command can be used on a file by:
Correct Answer
A. The file owner and root
Explanation
The chmod command allows the file owner and root to modify the permissions of a file. The file owner has the authority to change the permissions of their own files, while root, being the superuser, has the highest level of privilege and can modify the permissions of any file on the system. Other users who belong to the file's current group can also use the chmod command to modify the file's permissions. However, only root has complete control over all files and can modify any file's permissions.
32.
Which option for the chown command can be used to change the owner of a directory and all the files and directories below it?
Correct Answer
B. -R
Explanation
The option "-R" for the chown command can be used to change the owner of a directory and all the files and directories below it. This option stands for "recursive" and allows the change of ownership to be applied to all subdirectories and files within the specified directory. By using this option, the ownership of the entire directory tree can be modified in one command.
33.
The chown command will only accept one file at a time as an argument.
True or False?
Correct Answer
B. False
Explanation
The chown command can accept multiple files as arguments, not just one file at a time. This allows the user to change the ownership of multiple files simultaneously, saving time and effort.
34.
The “execute” permission is never set on files by default.
True or False?
Correct Answer
A. True
Explanation
By default, when a file is created, the "execute" permission is not set. This means that the file cannot be executed as a program or script directly. This is a security measure to prevent accidental execution of potentially harmful files. The user must explicitly set the "execute" permission if they want the file to be executable. Therefore, the statement "The 'execute' permission is never set on files by default" is true.
35.
The user owner of a file will always have the same or higher permissions as “other”.
True or False?
Correct Answer
B. False
Explanation
The statement is false because the user owner of a file can have lower permissions than "other". The user owner can have specific permissions set for themselves, while "other" refers to all other users who are not the owner. Therefore, it is possible for the user owner to have more restrictive permissions than "other".
36.
A source and a hard link must be part of the same filesystem.
True or False?
Correct Answer
A. True
Explanation
A source and a hard link must be part of the same filesystem because a hard link is a direct reference to the same inode (data structure that stores information about a file) as the source file. In other words, a hard link creates a new file entry in the filesystem that points to the same data blocks as the source file. Therefore, both the source file and the hard link must be located within the same filesystem.
37.
Deleting a source file will break an associated symbolic link.
True or False?
Correct Answer
A. True
Explanation
When a source file is deleted, any symbolic links pointing to it will become invalid or broken. Symbolic links are essentially shortcuts or references to the original file, and if the original file is deleted, the link will no longer be able to access it. Therefore, deleting a source file will break any associated symbolic links.
38.
A source file and a symbolic link must be part of the same file system.
True or False?
Correct Answer
B. False
Explanation
A source file and a symbolic link do not have to be part of the same file system. Symbolic links can be used to refer to files or directories in different file systems, allowing for flexibility and organization in file management. Therefore, the correct answer is False.
39.
Which of the following commands would create a hard link, link to file?
Correct Answer
C. Ln file link
Explanation
The correct answer is "ln file link" because the "ln" command is used to create links between files, and the syntax "ln file link" creates a hard link named "link" that points to the file named "file".
40.
Which of the following commands would create a symbolic link, link to file?
Correct Answer
B. Ln -s file link
Explanation
The correct answer is "ln -s file link" because the "-s" option is used to create a symbolic link. The "file" is the original file that we want to link, and "link" is the name of the symbolic link that will be created.