1.
A directory is a type of file.
Correct Answer
A. True
Explanation
In computer systems, a directory is indeed a type of file that serves as a container for other files and directories. It's a structured file that organizes and manages a collection of file names and metadata, enabling users to navigate and organize their data. Directories, often referred to as "folders," help manage file systems by allowing files to be grouped, categorized, and accessed in a logical hierarchy. Though directories differ from traditional files (which contain data or executable code), they function as specialized files for organizing and structuring other files within an operating system. This makes the statement that a directory is a type of file true.
2.
Which command would a user type on the command
line to find out what directory in the directory tree he is currently in?
Correct Answer
D. Pwd
Explanation
The command pwd (print working directory) is used to find out which directory a user is currently in within the command line or terminal environment. It displays the full path of the current directory, helping users understand their location in the directory tree. This command is especially useful in navigating complex file structures or confirming the directory before executing further commands. By using pwd, users can ensure they're in the correct directory before performing operations like file manipulations or script executions.
3.
Which of the following is an absolute pathname?
Correct Answer
B. C:\myfolder\resume
Explanation
An absolute pathname provides the complete location of a file or directory in a file system, starting from the root directory. In the provided options, C:\myfolder\resume is the absolute pathname because it begins from the root directory of the drive "C:\", and then specifies the exact location of the "resume" file within the "myfolder" directory.
This pathname is specific to the Windows operating system, where drive letters like "C:" are used to denote different storage drives, and backslashes "\" are used as directory separators to indicate the hierarchical structure of folders and files. By providing the root directory and the full sequence of directories leading to the file, absolute pathnames enable users to access files or directories without ambiguity, regardless of their current working directory.
4.
A special device file is used to ___________.
Correct Answer
B. Represent hardware devices such as hard disk drives and ports
Explanation
Special device files, also known as device nodes, represent hardware devices in a Linux or UNIX-like operating system. These files are used to interact with hardware components like hard disk drives, ports, terminals, and other devices. They serve as interfaces between the operating system and hardware, allowing software to communicate with devices in a standardized manner. Device files are typically located in the /dev directory and can be categorized into two types: block devices and character devices. Block devices represent hardware that reads and writes data in blocks, like hard drives, while character devices handle data one character at a time, like serial ports. Using special device files, Linux allows software applications to interact with hardware in a way that abstracts the complexities of hardware management, simplifying system design and enhancing compatibility.
5.
If a user’s current directory is /home/mary/project1, which command could she use to move to the etc directory directly under the root?
Correct Answer
D. Cd /etc
Explanation
The question specifies that the user wants to move to the "etc" directory directly under the root. In Unix-like operating systems, directories that start with a forward slash (/) indicate an absolute path from the root directory. Therefore, the command cd /etc instructs the shell to change the current directory to "etc" which is directly under the root directory (/). This command is independent of the user's current location in the file system hierarchy.
6.
After typing the ls
–a command, you notice that
there is a file whose filename begins with a dot ( . ). What does this mean?
Correct Answer
D. It is a hidden file.
Explanation
The command cd /etc is used to move to the etc directory located directly under the root directory in Linux and other UNIX-like operating systems. The forward slash (/) at the beginning of the path specifies that it's an absolute path, indicating a directory that starts from the root. Given the current directory /home/mary/project1, the cd /etc command immediately navigates to the root-level etc directory, bypassing any relative navigation or other subdirectories. This direct approach is useful for quickly reaching specific directories within the filesystem, particularly when the exact path is known.
7.
After typing the ls
–F command,
you notice a filename that ends with an * asterisk character. What does
this mean?
Correct Answer
D. It is an executable file.
8.
The vi editor can function in which two of the
following modes? (Choose both that apply.)
Correct Answer(s)
B. Command
E. Insert
Explanation
The vi editor can function in two modes: command mode and insert mode. In command mode, users can navigate through the text, delete or copy lines, search for specific words, and perform other editing commands. In insert mode, users can directly type and insert new text into the document. These two modes allow users to efficiently edit and manipulate text in vi editor.
9.
The less command offers less functionality than the more command. True or False?
Correct Answer
B. False
Explanation
The statement is false. The less command actually offers more functionality than the more command. While both commands are used to view the contents of a file, the less command allows for backward scrolling, searching, and navigation within the file, while the more command only allows for forward scrolling. Therefore, the less command provides additional features and functionality compared to the more command.
10.
Which command searches for and displays any text
contents of a binary file?
Correct Answer
B. Strings
Explanation
The strings command in UNIX-like operating systems is used to search for and display readable text contents from a binary file. It extracts sequences of printable characters from the binary data, allowing users to examine text-based information embedded in compiled programs, object files, or other binary formats. This command is helpful for analyzing compiled software or data files where human-readable text may be embedded among non-readable binary content. The strings command is particularly useful for debugging, reverse engineering, or exploring the contents of unknown binary files, providing insights into internal structures, strings, or hidden data that may not be immediately apparent. By extracting and displaying these readable sequences, it can be a valuable tool in various scenarios where text within binary data is of interest.
11.
How can a user switch from insert mode to command
mode when using the vi editor?
Correct Answer
D. Press the Esc key.
Explanation
In the vi (or vim) text editor, pressing the Esc (Escape) key is the standard method to switch from insert mode to command mode. In insert mode, you can add or edit text, while command mode allows you to navigate, delete, and manipulate text, among other functions. The transition between these modes is crucial for efficient text editing in vi. To enter command mode from insert mode, pressing the Esc key is all that's required. This action stops text insertion and allows you to type commands like :w to save, :q to quit, or other vi-specific navigation and editing commands. This key is integral to vi's modal editing approach, where different modes enable various functionalities within the editor.
12.
If resume is the name of a file in the home directory off the root of the filesystem and your present working directory is home, what is the relative name for the file named resume?
Correct Answer
C. Resume
Explanation
In UNIX-like operating systems, relative paths describe the location of a file or directory in relation to the current working directory.
If you're in the "home" directory and the "resume" file is in the home directory under the root of the filesystem, the relative path to reach "resume" would be "../resume". This notation indicates that you need to move up one level from the current directory and then into the desired file, "resume". The "../" refers to going up one level in the directory tree, and "resume" is the file in the parent directory.
Thus, using "../resume" from the "home" directory leads you to the file named "resume" in the "home" directory under the root.
13.
What will the following
wildcard regular expression return:
file[a-c]?
Correct Answer
C. Filea, fileb, filec
Explanation
The given wildcard regular expression "file[a-c]?" will return "filea, fileb, filec" as the output. This is because the expression matches any string that starts with "file" followed by a single character that can be any letter between "a" and "c", and may or may not have an additional character at the end. Therefore, it will match "filea", "fileb", and "filec".
14.
What will typing q! at the : prompt in command mode do when using the vi editor?
Correct Answer
D. Quit without saving any changes
Explanation
In the vi editor, which is a modal text editor for Unix and Unix-like operating systems, typing :q! at the command mode prompt forces the editor to quit and exit the current editing session, discarding any unsaved changes made to the document. This command is particularly useful when you need to exit the editor quickly without the intention to save the modifications made during that session. The ! symbol here overrides any prompts that would normally warn the user about unsaved changes, ensuring an immediate exit.
15.
A user types in the command head /poems/mary. What will be displayed to the terminal screen?
Correct Answer
E. The first 10 lines of the file mary
Explanation
The head command in Unix-like operating systems is used to display the beginning of a text file or piped data. By default, without any additional parameters, the head command displays the first 10 lines of the specified file. In this case, typing head /poems/mary will output the first 10 lines of the file located at /poems/mary. This command is useful for quickly viewing the beginning portions of large files without needing to open them entirely in a text editor.
16.
The tac command _________________.
Correct Answer
D. Displays the contents of a file in reverse order last line first and first line last
Explanation
The tac command is a Unix-like system command that stands for "concatenate and print files in reverse". It essentially works as the reverse of the cat command. While cat displays the contents of a file from the first line to the last, tac reads the file from end to start, thereby displaying the lines in reverse order, from the last line to the first. This command is particularly useful for viewing log files where the most recent entries are at the end of the file.
17.
How can you specify a text pattern that must be
at the beginning of a line of text using a regular expression?
Correct Answer
D. Precede the string with a ^.
Explanation
To specify a text pattern that must be at the beginning of a line of text using a regular expression, you need to precede the string with a ^. The caret symbol (^) is a special character in regular expressions that represents the start of a line. By placing it before the string, you are indicating that the pattern should match only if it appears at the beginning of a line.
18.
Linux has only one root directory per directory
tree. True or False?
Correct Answer
A. True
Explanation
Linux does indeed have only one root directory per directory tree. This means that there is a single top-level directory from which all other directories and files branch out. This root directory is denoted by a forward slash ("/") in Linux systems. Having only one root directory helps to maintain a hierarchical structure and organization within the file system.
19.
Using wildcard metacharacters, how can you indicate
a character that is NOT an a or b or c or d?
Correct Answer
C. [!a-d]
Explanation
The correct answer is [!a-d]. This is because the caret (^) symbol inside the square brackets indicates negation, meaning that any character that is not an a, b, c, or d will match. The other options, [a-d], [^abcd], and !a-d, do not correctly represent the desired condition of not matching any of the specified characters.
20.
A user typed in the command pwd and saw the output: /home/jim/sales/pending. How
could that user navigate to the /home/jim directory?
Correct Answer
C. Cd ../..
Explanation
The user can navigate to the /home/jim directory by using the command "cd ..". This command moves the user up one level in the directory structure, so by using it twice, the user will be in the /home/jim directory. The other options provided in the question are incorrect. "cd /jim" would try to navigate to a directory called "jim" directly under the root directory, "cd .." would only move the user up one level in the current directory, and "cd ./." would stay in the current directory.