Exam Flashcards

1
Q

True or False?

One of the tasks that an operating system must perform is to manage the resources.
Four resources that an operating system must manage are: the file system,
input/output, processes and memory.

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

The “cd ~” and “cd” commands in Linux will make your home directory
your home directory.

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

The “cat” command can NOT be used to create a file.

A

False
The “cat” command in Linux can be used to create a file. You can use the “cat > filename” command to create a new file and start entering text into it. The “>” symbol is used to redirect the output of the “cat” command to a file with the specified filename.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

In Linux the “..” directory refers to the parent of the current working
directory.

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

The “root directory” in Linux is represented by “\”.

A

False
False. In Linux, the root directory is represented by the forward slash (“/”) symbol, not the backslash (“”) symbol. The forward slash is used as the directory separator in Linux and UNIX-based systems, while the backslash is used as the directory separator in Microsoft Windows operating systems.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

The “rm” command can NOT be used to delete directories.

A

False. The “rm” command in Linux can be used to delete directories. However, if you try to delete a directory using the “rm” command, you will get an error message stating that the directory is not empty. To remove a directory and its contents, you can use the “rm -r” command, which will recursively remove all files and subdirectories within the specified directory.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

The commands “less filename” and “cat filename|less” both accomplish
the same task.

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Bash has a construct similar to switch in java which is called case and
proper syntax dictates that you must close a case construct with “endcase”.

A

False. Bash does have a construct similar to a switch statement in Java, which is called the “case” statement. However, in Bash, you do not need to use “endcase” to close a “case” block. Instead, you can use the “esac” keyword to signify the end of a “case” block.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

In class we discussed redirection of output and redirection of input. We
use the symbols&raquo_space; and > for redirection of output and < for redirection
of input.

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

nano, vi and sed are examples of editors found on most linux systems that
can be used to create and edit text files.

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

There are two ways to execute a linux script file. One way is to make the file
executable using “chmod” and the second way is to use the “bash” command.

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

. Regex can NOT be used with sed.

A

False. Regular expressions (regex) can be used with sed, which is a stream editor used for filtering and transforming text.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

egrep ‘.$’ science.txt |wc –l will count the number of lines that end with
with a period

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

sed in an interactive editor

A

False. Sed is not an interactive editor, it is a stream editor used for filtering and transforming text.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

ps –l displays all the processes currently running on the system.

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Bash does not support floating point (decimal fraction) data types.

A

True

17
Q

. It is possible to have two files with the same absolute name on a disk.

A

False. It is not possible to have two files with the same absolute name on a disk.

18
Q

Regex’s is an abbreviation for Regular Examples

A

False. “Regex” is an abbreviation for “Regular Expressions.”

Regular expressions (regex) are a powerful tool used to match and manipulate text patterns.

19
Q

The command “chmod 511 filename” would make the file executable for the
owner

A

True

20
Q

To input a value into a bash program you use the command “input”.

A

False. the command to read input from the user is “read”.

21
Q

Before you use a variable in bash programming you must first declare the
variable type.

A

False. In Bash, you don’t need to declare the variable type before using a variable. Bash variables are dynamically typed, which means that the type of a variable is determined by the value assigned to it at runtime.

22
Q

Which of the following commands would you use to determine the number of words
in the file.
a) head b) tail c) wc d) uniq e) none of these

A

C)
The command you would use to determine the number of words in a file is wc.

.

23
Q

. The printenv command is used to show a list of:
a) script variables b) environment variables c) shell operators
d) prototypes for a script. e) none of these

A

B)
The printenv command is used to show a list of environment variables.

24
Q

Which of the following commands will show all the processes on atlas:
a) ps -l b) ps -ef c) ls -la d) ps -all e) none of these

A

B)

The ps -ef command will show all the processes on Atlas.

25
Q

Which command will create a global variable:
a) shell b) global c) export d) set e) none of these

A

C)
The export command is used to create a global variable in Bash.

26
Q

Which of the following commands would you use to display the contents of a shell
variable.
a) echo b) cat c) more d) print e) none of
thes

A

A)

The echo command is used to display the contents of a shell variable.

27
Q

. Assume the current working directory (cwd) is your home directory and there is a
sub-directory called dir_1 in your home directory and you wish to move to the dir_1
directory. Which one of the following commands is incorrect.
a) cd /dir_1 b) cd ./dir_1 c) cd dir_1
d) they are all correct e) they are all incorrect

A

A)
Option (a) cd /dir_1 is incorrect as it specifies an absolute path and tries to change the directory to a folder called dir_1 located in the root directory, not in your home directory.

THIS MAY NOT BE ACCURATE

28
Q

. Write a bash program segment that will read a name and grade from the
keyboard and the display the name and a message according to the
following. Your program should continue to execute until the user presses
CTRL/C. (4 points)
The name the grade message
Where message is: “Failed” if grade is less than 50
“Passed” if grade is between 50 and 100
“Invalid value” if grade is greater than 100

A

!/bin/bash

while true
do
read -p “Enter name: “ name
read -p “Enter grade: “ grade

if [[ $grade -lt 0 || $grade -gt 100 ]]; then
    echo "$name: Invalid value"
elif [[ $grade -lt 50 ]]; then
    echo "$name: Failed"
else
    echo "$name: Passed"
fi done