CSCE 3600 MIDTERM QUESTIONS AND ANSWERS
The directory is a type of file - Answers - True
_________ Linux command is used to count the total number of lines, words, and
characters contained in a file. - Answers - wc
Which Linux command is used to go back from a directory to the directory before that? -
Answers - cd ..
How many types of basic permissions are available in Linux to grant a user? - Answers
-3
In a multiuser multitasking Linux operating system, what does "multitasking" refer to? -
Answers - The capability of the operating system to run multiple programs concurrently
on a single processor.
You need to list all files and directories in the current directory, including hidden ones.
Which linux command would you use? - Answers - ls -a
You need to copy a file named "report.txt" to a directory named "backup". How would
you do that? Choose the right command. - Answers - cp report.txt backup
What is the output shown for a type echo command? - Answers - echo is a shell built-in
Device drivers in an operating system are responsible only for providing hardware-
specific functionalities and have no role in managing the communication between
software applications and hardware devices. - Answers - False
What is a fundamental difference between the C standard library functions and system
calls in a Unix-like operating system? - Answers - C standard library functions execute
in user mode, while system calls transition to kernel mode to access privileged
operations.
What does cd .. command do ? - Answers - Directory switched to the previous level
Which sed command is used to read and insert the contents of a file at the current
position in the output? - Answers - r
Which regex metacharacter is used to specify the end of a line? - Answers - $
What does the regex (abc|def) match? - Answers - Either "abc" or "def".
, Which regex quantifier is used to match one or more occurrences of the preceding
element? - Answers - '+'
In regex, the . (dot) character typically represents _______________ - Answers - Any
single character except a newline.
You have a log file and want to find all lines that start with the word "ERROR" followed
by a colon. Which grep command would you use? - Answers - grep "^ERROR:"
logfile.txt
You want to count the number of lines in a file that do not contain the word "error."
Which grep command would you use? - Answers - grep -c -v "error" file.txt
How can you make sed edit a file in place (i.e., modify the file directly)? - Answers - -i
What is the purpose of the -n option in sed? - Answers - Suppresses automatic printing
of pattern space.
How can you specify a range of lines to apply a sed command to? - Answers - Using
line numbers separated by a comma (e.g., 1,3).
(True / False) The command below replaces the 5th line of a file with a new line of text
sed '5s/.*/This is a new line/' input.txt > output.txt - Answers - True
(True / False) The command below remove all non-empty lines from a file
sed '/^$/d' input.txt > output.txt - Answers - False
Match the regex with the right hand side
^\+\d{1,3}-\d{3}-\d{3}-\d{4}$
(https?|ftp)://[^\s/$.?#].[^\s]*
(\d{1,3}\.){3}\d{1,3} - Answers - +1 555-555-5555
https://linkedin.com
Matches IPv4 addresses
What does the following line in a Bash script do?
chmod +x script.sh - Answers - Makes script.sh executable
Which command is used to set an environment variable in Bash? - Answers - export
The directory is a type of file - Answers - True
_________ Linux command is used to count the total number of lines, words, and
characters contained in a file. - Answers - wc
Which Linux command is used to go back from a directory to the directory before that? -
Answers - cd ..
How many types of basic permissions are available in Linux to grant a user? - Answers
-3
In a multiuser multitasking Linux operating system, what does "multitasking" refer to? -
Answers - The capability of the operating system to run multiple programs concurrently
on a single processor.
You need to list all files and directories in the current directory, including hidden ones.
Which linux command would you use? - Answers - ls -a
You need to copy a file named "report.txt" to a directory named "backup". How would
you do that? Choose the right command. - Answers - cp report.txt backup
What is the output shown for a type echo command? - Answers - echo is a shell built-in
Device drivers in an operating system are responsible only for providing hardware-
specific functionalities and have no role in managing the communication between
software applications and hardware devices. - Answers - False
What is a fundamental difference between the C standard library functions and system
calls in a Unix-like operating system? - Answers - C standard library functions execute
in user mode, while system calls transition to kernel mode to access privileged
operations.
What does cd .. command do ? - Answers - Directory switched to the previous level
Which sed command is used to read and insert the contents of a file at the current
position in the output? - Answers - r
Which regex metacharacter is used to specify the end of a line? - Answers - $
What does the regex (abc|def) match? - Answers - Either "abc" or "def".
, Which regex quantifier is used to match one or more occurrences of the preceding
element? - Answers - '+'
In regex, the . (dot) character typically represents _______________ - Answers - Any
single character except a newline.
You have a log file and want to find all lines that start with the word "ERROR" followed
by a colon. Which grep command would you use? - Answers - grep "^ERROR:"
logfile.txt
You want to count the number of lines in a file that do not contain the word "error."
Which grep command would you use? - Answers - grep -c -v "error" file.txt
How can you make sed edit a file in place (i.e., modify the file directly)? - Answers - -i
What is the purpose of the -n option in sed? - Answers - Suppresses automatic printing
of pattern space.
How can you specify a range of lines to apply a sed command to? - Answers - Using
line numbers separated by a comma (e.g., 1,3).
(True / False) The command below replaces the 5th line of a file with a new line of text
sed '5s/.*/This is a new line/' input.txt > output.txt - Answers - True
(True / False) The command below remove all non-empty lines from a file
sed '/^$/d' input.txt > output.txt - Answers - False
Match the regex with the right hand side
^\+\d{1,3}-\d{3}-\d{3}-\d{4}$
(https?|ftp)://[^\s/$.?#].[^\s]*
(\d{1,3}\.){3}\d{1,3} - Answers - +1 555-555-5555
https://linkedin.com
Matches IPv4 addresses
What does the following line in a Bash script do?
chmod +x script.sh - Answers - Makes script.sh executable
Which command is used to set an environment variable in Bash? - Answers - export