1.
Which of the following UNIX commands will not take the user student5 to his personal home direcotry:
Correct Answer
A. Cd
Explanation
The command "cd" alone will not take the user student5 to his personal home directory. The "cd" command without any arguments will take the user to their default home directory, but it will not specifically take them to their personal home directory.
2.
What is a shell in UNIX:
Correct Answer
A. A program through which users can issue commands to UNIX.
Explanation
A shell in UNIX is a program that allows users to interact with the operating system by issuing commands. It provides a command-line interface where users can type commands and execute them. The shell interprets these commands and communicates with the operating system to perform the requested actions. It acts as an intermediary between the user and the kernel of the operating system, enabling users to control and manage various aspects of the UNIX system.
3.
What is the generic syntax for all UNIX commands:
Correct Answer
A. Command name, followed by arguments, followed by options
Explanation
The generic syntax for all UNIX commands is to have the command name followed by arguments, followed by options. This means that the command is specified first, followed by any required arguments or parameters, and then any optional options or flags.
4.
Which of the following represents an absolute path:
Correct Answer
D. /usr/bin/cat
Explanation
An absolute path specifies the location of a file or directory from the root directory of the file system, which is represented by the initial forward slash "/" in Unix-like operating systems. In this case, "/usr/bin/cat" indicates the file "cat" is located in the "bin" directory, which is within the "usr" directory at the root of the file system.
5.
Which of these commands will set the permissions on file textfile to read and write for the owner, read for the group, and nothing for everyone else:
Correct Answer
A. Chmod 046 textfile
Explanation
The command "chmod 046 textfile" will set the permissions on the file "textfile" to read and write for the owner, read for the group, and nothing for everyone else.
6.
Which of the following is not a UNIX file type:
Correct Answer
A. Plain file
Explanation
A plain file is a type of file in UNIX that stores data without any special formatting or structure. It is the most common type of file and can contain text, binary, or any other type of data. On the other hand, special files are used to represent devices or system resources, such as printers or input/output devices. Batch files are scripts that contain a series of commands to be executed in sequence. Lastly, directory files are used to store information about the files and directories within a directory. Therefore, the correct answer is plain file, as it is a valid UNIX file type.
7.
When the in command is used, which of the following occurs:
Correct Answer
A. A file is created that points to an existing file.
Explanation
When the "in" command is used, a file is created that points to an existing file. This means that a new file is created, but it does not contain any new data. Instead, it serves as a reference or shortcut to the original file. Any changes made to the original file will also be reflected in the file created with the "in" command. This allows for easy access and manipulation of the original file without directly modifying it.
8.
Which command will print the contents of ll files inthe current directory whose names start with the character 'a' and end with a period ('.') followed by any two characters followed by a number:
Correct Answer
A. Is a*.??[0-9]
Explanation
The correct answer is "Is a*.??[0-9]". This command will print the contents of all files in the current directory whose names start with the character 'a', followed by any two characters, followed by a number. The "?" represents any single character, and "[0-9]" represents any digit from 0 to 9. Therefore, this command will match file names like "aab12" or "axy3", but not file names like "abc" or "axz".
9.
The apropos command is used to:
Correct Answer
A. Obtain a list of commands whose description contains given keywords.
Explanation
The apropos command is used to obtain a list of commands whose description contains given keywords. This means that if you are unsure of the exact command name, but you know a keyword related to what you want to do, you can use apropos to find the relevant commands. It helps in searching and discovering commands based on their descriptions, making it easier to navigate and use the command line efficiently.
10.
Which of these is not a common UNIX shell:
Correct Answer
A. Bash
Explanation
The given question asks for the shell that is not commonly used in UNIX. The shells commonly used in UNIX systems are bash, sh, and ksh. However, "fresh" is not a commonly known UNIX shell, making it the correct answer.
11.
In ksh, what is the difference between the expressions VAR and $VAR:
Correct Answer
A. VAR refers to a variable name and $VAR to its value.
Explanation
In ksh, the expression VAR refers to a variable name, while $VAR refers to the value of that variable. This means that VAR is used to refer to the actual name of the variable, while $VAR is used to access the value stored in that variable.
12.
Which of these expressions shows the proper way to add the directory /usr/bin to a path:
Correct Answer
A. PATH+=/usr/bin
Explanation
The correct answer is "PATH+=/usr/bin". This expression appends the directory /usr/bin to the existing PATH variable, without overwriting it. The "+=" operator is used to concatenate the new directory to the existing value of PATH.
13.
What is the default datatype of variables in ksh shell scripts:
Correct Answer
A. Integer
Explanation
The default datatype of variables in ksh shell scripts is integer. This means that if a variable is not explicitly declared with a datatype, it is assumed to be an integer by default.
14.
Which of these situations would cause an error message to be printed after typing the commad "my_script" on the command line. This assumes that my_script is a ksh script.
Correct Answer
A. My_script dos not have execute permission set.
Explanation
When the command "my_script" is typed on the command line, an error message will be printed if "my_script" does not have execute permission set. This means that the user does not have the necessary permission to execute the script.
15.
In a ksh script, how is the beginning and end of a block of statements in a while loop indicated.
Correct Answer
A. With { and }
Explanation
In a ksh script, the beginning and end of a block of statements in a while loop are indicated with { and }. These curly brackets are used to enclose the statements that need to be executed repeatedly until the while condition becomes false. The opening curly bracket { indicates the start of the block, and the closing curly bracket } indicates the end of the block. This syntax helps in organizing and grouping the statements within the while loop, making the code more readable and maintainable.
16.
What is the meaning of the expression ${sports[*]} in a ksh script:
Correct Answer
A. All of the elements of the array sports.
Explanation
The expression ${sports[*]} in a ksh script refers to all of the elements in the array named "sports". It does not represent the number of elements in the array, the first element, or a statement about loving sports.
17.
What is the default list upon which a for loop operates in a ksh script (i.e. a script contains "for x" rather than "for x in y").
Correct Answer
A. The list of files in the current working directory.
Explanation
In a ksh script, when a for loop is written as "for x" without specifying a list, the default list upon which the loop operates is the list of files in the current working directory. This means that the loop will iterate over each file in the directory, performing the specified actions for each file.
18.
What UNIX command is used to update the modification time of a file:
Correct Answer
A. Time
19.
In which situation can regular expressions not be used.
Correct Answer
A. Filtering of email coming from a particular internet domain name.
Explanation
Regular expressions can be used in all of the given situations except for filtering email coming from a particular internet domain name. Regular expressions are commonly used for tasks such as pattern matching, string manipulation, and data extraction. However, filtering email based on the domain name requires more complex logic and cannot be efficiently achieved using regular expressions alone. It would require additional programming or filtering techniques specific to email protocols and domain filtering.
20.
What would be the output of the command: egrep "^[^A-Za-z].*!" file:
Correct Answer
A. All lines in file beginning with a non-alpHabetic character and containing an exclamation point elsewhere on the line.
Explanation
The command "egrep" is used to search for lines in a file that match a specific pattern. In this case, the pattern is "^[^A-Za-z].*!", which means the line should start with a non-alphabetic character and contain an exclamation point anywhere else on the line. Therefore, the output of the command would be all the lines in the file that meet this criteria.
21.
Which string(s) would be matched by the regular expression:| "stu(dent)? [0-9]+".
Correct Answer
A. Student 1
Explanation
The regular expression "| "stu(dent)? [0-9]+" matches any string that starts with "stu", followed by an optional "dent", and then a space followed by one or more digits. In this case, the string "student 1" matches the regular expression because it starts with "stu", followed by "dent" (which is optional), then a space, and finally the digit "1".
22.
Which regular expression (egrep style) means "all lines beginning with a number.
Correct Answer
A. “[^0-9]”
Explanation
The regular expression "^[0-9]" means "all lines beginning with a number". The caret symbol (^) at the beginning of the expression denotes the start of a line, and the [0-9] specifies any digit from 0 to 9. Therefore, this expression matches any line that starts with a number. The correct answer, "^[0-9]", accurately represents the desired pattern.
23.
Which regular expresion (egrep style) means "all lines containing an alphabetic word ending with ".txt" followed by a space or the end of the line":
Correct Answer
A. "*.txt "
Explanation
The correct answer is "*.txt ". This regular expression means that it will match any line containing an alphabetic word ending with ".txt" followed by a space or the end of the line. The asterisk (*) means that there can be zero or more characters before ".txt", the ".txt" matches the literal characters ".txt", and the space matches a space character.
24.
In order to edit a file called sample.txt, it will be necessary to type:
Correct Answer
A. Edit sample.txt
Explanation
To edit a file called sample.txt, the correct command to type is "edit sample.txt". This command specifies the action (edit) and the file name (sample.txt) that needs to be edited. The other options listed (vi sample.txt, sample.txt, vi qui - TAB, None of the above) do not accurately represent the correct command for editing a file.
25.
In order to delete a word in a file using vi, place the cursor on the first letter of the word, ESC and type:
Correct Answer
A. Dw
Explanation
In order to delete a word in a file using vi, the user needs to place the cursor on the first letter of the word and then press the keys "dw". The "d" key is used to delete and the "w" key is used to specify that a word needs to be deleted. The other options mentioned in the question ("a", "x", "z" and "None of the above") are not the correct sequence of keys to delete a word in vi.
26.
In vi, in order to make changes to a file and then save the work, type:
Correct Answer
A. ESC - :wq
Explanation
To make changes to a file and save the work in vi, the correct command is "ESC - :wq". The "ESC" key is used to enter command mode, and then ":wq" is typed to save the changes and exit the editor. This command combination ensures that any modifications made to the file are saved before exiting vi.
27.
Which command would delete a single line:
Correct Answer
A. Del
Explanation
The correct answer is "del" because it is a command commonly used in computer systems to delete files or directories. It is short for "delete" and is often used in command-line interfaces to remove a single line or a specific file. The other options provided, such as "DELETE," "dl," and "er," are not recognized commands for deleting a single line. Therefore, "del" is the appropriate command in this scenario.
28.
Why should macros (variables) be used in a Makefile?
Correct Answer
A. A single change to a macro can have a large effect on the way a target is built.
Explanation
Macros (variables) should be used in a Makefile because a single change to a macro can significantly impact the way a target is built. By modifying a macro, developers can easily customize the build process and adapt it to different requirements. This flexibility allows for efficient and dynamic development, as macros can be easily adjusted to meet specific needs. Additionally, macros can override make's defaults, providing further control over the build process. Overall, the correct use of macros enables the Makefile to be easily converted for use in different contexts, enhancing its versatility and reusability.
29.
In UNIX, a "process" refers to:
Correct Answer
A. Compiled source code.
30.
The term for an integer that defines the execution priority of a process is:
Correct Answer
A. Nice value
Explanation
The term for an integer that defines the execution priority of a process is "Nice value". The Nice value is a parameter in Unix-like operating systems that is used to indicate the priority of a process. It ranges from -20 (highest priority) to +19 (lowest priority). A lower Nice value means a higher priority, and a higher Nice value means a lower priority. The Nice value allows the operating system to allocate resources efficiently and prioritize processes based on their importance or urgency.
31.
Which UNIX system call is used to create a new process:
Correct Answer
A. Creat()
Explanation
The correct answer is "fork()". The fork() system call is used in UNIX to create a new process. It creates an exact copy of the currently running process, including all its memory, file descriptors, and other attributes. The new process, called the child process, starts executing from the same point as the parent process, but with a different process ID. The fork() system call is commonly used in UNIX systems for creating multiple processes and implementing features like multitasking and multiprocessing.
32.
Pipes are an example of what inter-process communication paradigm?
Correct Answer
A. Message passing
Explanation
Pipes are an example of the message passing inter-process communication paradigm. In this paradigm, processes communicate by sending and receiving messages to each other. Pipes provide a unidirectional communication channel between processes, where one process writes to the pipe and the other process reads from it. This allows for the exchange of data and synchronization between processes.
33.
Most UNIX system configuration files are located in which directory:
Correct Answer
C. /etc
Explanation
The /etc directory is the traditional location for system-wide configuration files on UNIX and Linux systems. These files control the behavior of the operating system, applications, and services. Examples include files for setting up network interfaces, user accounts, and system logging.
34.
System administration tasks must generally be performed by which username:
Correct Answer
A. Admin
Explanation
The correct answer is "admin" because the term "admin" is commonly used to refer to the administrator or system administrator role in computer systems. The admin user typically has elevated privileges and permissions to perform various system administration tasks, such as managing user accounts, installing software, configuring system settings, and maintaining system security. It is important to have a dedicated admin user to ensure proper management and security of the system.
35.
Which of the following pieces of informaiton is not contained in the passwd file?
Correct Answer
A. A user’s unencrypted password
Explanation
The passwd file contains information about a user's login name, preferred shell program, and group ID. However, it does not contain a user's unencrypted password. The passwd file stores an encrypted version of the password for security reasons.