Deck 5: Creating Shell Scripts and Displaying File Contents

ملء الشاشة (f)
exit full mode
سؤال
The functions of the three permission types (read, write, and execute) are applied the same for files and directories.
استخدم زر المسافة أو
up arrow
down arrow
لقلب البطاقة.
سؤال
By default, only root can execute a file automatically.
سؤال
Successful commands usually return the code 0 to the shell.
سؤال
You can use condition statements to create menu scripts that allow users to choose from a list of options.
سؤال
The if statement can only return a binary zero or one condition.
سؤال
Which symbol represents a permission that has not been granted?

A) Asterisk (*)
B) Carrot (^)
C) Hyphen (-)
D) Forward slash (/)
سؤال
Which command removes write and execute permissions for the other category on file4?

A) chmod o-wx file4
B) chmod file4 o-wx
C) rem file4 o-wx
D) del o-wx file4
سؤال
What is the corresponding numeric notation for a file with rw-rw-r-- permissions?

A) 221
B) 664
C) 110
D) 441
سؤال
____ consists of binary ones and zeros.

A) Script code
B) Variable code
C) Pseudocode
D) Machine code
سؤال
The BASH shell is an example of a(n)____.

A) interpreter
B) compiler
C) kernel file
D) machine code file
سؤال
With a compiled program, all the source code is converted to machine code and stored in a ____ before the user runs the script.

A) temporary file
B) buffer
C) binary file
D) variable
سؤال
Which command is used to display a list of all environment variables and their stored values?

A) dev
B) $echo
C) env
D) dvar
سؤال
Which variable assignment method would you use to specify a variable's value in a script command?

A) Conditional
B) Direct assignment
C) Prompt
D) Positional parameter
سؤال
Which variable assignment method is useful when you need information from the user to complete the script?

A) Conditional
B) Direct assignment
C) Prompt
D) Positional parameter
سؤال
When you run the scr1 script using the ./scr1 command, the filename is considered position zero in the command, and the text ./scr1 becomes the value of the ____ variable.

A) $0
B) $1
C) $run
D) $command
سؤال
Which command will display the exit status code on the screen?

A) env scode
B) echo $?
C) dis code
D) sh
سؤال
Which command ends a case statement?

A) ;;end
B) !!end
C) stop
D) esac
سؤال
The case statement syntax requires a(n) ____ to mark the end of each code portion matching a specific value.

A) period (.)
B) exclamation mark(!)
C) double semicolon (;;)
D) double exclamation mark(!!)
سؤال
The cat command is usually used to display the contents of a ____.

A) large text file
B) log file
C) small text file
D) memory dump
سؤال
The head command displays the first ____ lines of a text file.

A) two
B) five
C) ten
D) 100
سؤال
What is the result of running the head -15 scr8 command?

A) The command displays the last 15 lines of the scr8 file.
B) The command displays the first 15 lines of the scr8 file.
C) The command displays the contents of the scr8 file without the last 15 lines.
D) The command displays the contents of the scr8 file starting at line 15.
سؤال
What is the result of running the tail +5 scr8 command?

A) The command displays the last five lines of the scr8 file.
B) The command displays every fifth line of the scr8 file.
C) The command displays the contents of the scr8 file in reverse, five times.
D) The command displays the contents of the scr8 file starting at line five.
سؤال
Which command displays a file's contents one screen at a time?

A) head
B) show
C) echo
D) more
سؤال
Which command works the same as the more command but offers more flexibility in navigation?

A) less
B) dis
C) down
D) show
سؤال
A(n) ____________________ is a set of rules for instructing a computer how to perform specific tasks.
سؤال
With a(n) ____________________ program, the source code is converted to machine code, line by line, as the user runs the script.
سؤال
The purpose of a(n) ____________________ is to add documentation information for users and anyone else who might need to modify the script.
سؤال
When you quit a program or a command, a numeric code called a(n) ____________________ is sent to the shell.
سؤال
____________________ is used to perform a set of commands repeatedly.
سؤال
Match each statement with an item

-Indicates the end of the condition being tested.

A) if statement
B) then statement
C) else statement
D) fi statement
E) while statement
F) until statement
G) for statement
H) do statement
I) done statement
سؤال
Match each statement with an item

-Indicates the end of the code to be repeated.

A) if statement
B) then statement
C) else statement
D) fi statement
E) while statement
F) until statement
G) for statement
H) do statement
I) done statement
سؤال
Match each statement with an item

-A loop statement that specifies the number of times to execute the portion of code.

A) if statement
B) then statement
C) else statement
D) fi statement
E) while statement
F) until statement
G) for statement
H) do statement
I) done statement
سؤال
Match each statement with an item

-A loop statement that causes the interpreter to continue executing the code in the until loop portion of the script as long as the condition is false.

A) if statement
B) then statement
C) else statement
D) fi statement
E) while statement
F) until statement
G) for statement
H) do statement
I) done statement
سؤال
Match each statement with an item

-Starts the condition being tested.

A) if statement
B) then statement
C) else statement
D) fi statement
E) while statement
F) until statement
G) for statement
H) do statement
I) done statement
سؤال
Match each statement with an item

-A loop statement that tests a condition in much the same way as if-then statements.

A) if statement
B) then statement
C) else statement
D) fi statement
E) while statement
F) until statement
G) for statement
H) do statement
I) done statement
سؤال
Match each statement with an item

-Starts the portion of code specifying what to do if the condition evaluates to false.

A) if statement
B) then statement
C) else statement
D) fi statement
E) while statement
F) until statement
G) for statement
H) do statement
I) done statement
سؤال
Match each statement with an item

-Indicates the beginning of the code to be repeated.

A) if statement
B) then statement
C) else statement
D) fi statement
E) while statement
F) until statement
G) for statement
H) do statement
I) done statement
سؤال
Match each statement with an item

-Starts the portion of code specifying what to do if the condition evaluates to true.

A) if statement
B) then statement
C) else statement
D) fi statement
E) while statement
F) until statement
G) for statement
H) do statement
I) done statement
سؤال
Identify and define the three categories of file permissions.
سؤال
Why should you give only read and write permission to a file that is not a program?
سؤال
Why is it essential to understand the basics of shell scripting?
سؤال
After creating a shell script and assigning execute permissions, how do you define its stored location and why must you do this?
سؤال
Describe a shell variable.
سؤال
How do you combine the else and if statements? Why is this advantageous?
سؤال
Describe the case statement.
سؤال
Describe an until loop.
سؤال
Describe a for loop.
سؤال
Which command can be used to display a text file's contents in reverse order and why might a user want to do this?
فتح الحزمة
قم بالتسجيل لفتح البطاقات في هذه المجموعة!
Unlock Deck
Unlock Deck
1/48
auto play flashcards
العب
simple tutorial
ملء الشاشة (f)
exit full mode
Deck 5: Creating Shell Scripts and Displaying File Contents
1
The functions of the three permission types (read, write, and execute) are applied the same for files and directories.
False
2
By default, only root can execute a file automatically.
False
3
Successful commands usually return the code 0 to the shell.
True
4
You can use condition statements to create menu scripts that allow users to choose from a list of options.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 48 في هذه المجموعة.
فتح الحزمة
k this deck
5
The if statement can only return a binary zero or one condition.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 48 في هذه المجموعة.
فتح الحزمة
k this deck
6
Which symbol represents a permission that has not been granted?

A) Asterisk (*)
B) Carrot (^)
C) Hyphen (-)
D) Forward slash (/)
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 48 في هذه المجموعة.
فتح الحزمة
k this deck
7
Which command removes write and execute permissions for the other category on file4?

A) chmod o-wx file4
B) chmod file4 o-wx
C) rem file4 o-wx
D) del o-wx file4
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 48 في هذه المجموعة.
فتح الحزمة
k this deck
8
What is the corresponding numeric notation for a file with rw-rw-r-- permissions?

A) 221
B) 664
C) 110
D) 441
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 48 في هذه المجموعة.
فتح الحزمة
k this deck
9
____ consists of binary ones and zeros.

A) Script code
B) Variable code
C) Pseudocode
D) Machine code
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 48 في هذه المجموعة.
فتح الحزمة
k this deck
10
The BASH shell is an example of a(n)____.

A) interpreter
B) compiler
C) kernel file
D) machine code file
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 48 في هذه المجموعة.
فتح الحزمة
k this deck
11
With a compiled program, all the source code is converted to machine code and stored in a ____ before the user runs the script.

A) temporary file
B) buffer
C) binary file
D) variable
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 48 في هذه المجموعة.
فتح الحزمة
k this deck
12
Which command is used to display a list of all environment variables and their stored values?

A) dev
B) $echo
C) env
D) dvar
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 48 في هذه المجموعة.
فتح الحزمة
k this deck
13
Which variable assignment method would you use to specify a variable's value in a script command?

A) Conditional
B) Direct assignment
C) Prompt
D) Positional parameter
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 48 في هذه المجموعة.
فتح الحزمة
k this deck
14
Which variable assignment method is useful when you need information from the user to complete the script?

A) Conditional
B) Direct assignment
C) Prompt
D) Positional parameter
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 48 في هذه المجموعة.
فتح الحزمة
k this deck
15
When you run the scr1 script using the ./scr1 command, the filename is considered position zero in the command, and the text ./scr1 becomes the value of the ____ variable.

A) $0
B) $1
C) $run
D) $command
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 48 في هذه المجموعة.
فتح الحزمة
k this deck
16
Which command will display the exit status code on the screen?

A) env scode
B) echo $?
C) dis code
D) sh
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 48 في هذه المجموعة.
فتح الحزمة
k this deck
17
Which command ends a case statement?

A) ;;end
B) !!end
C) stop
D) esac
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 48 في هذه المجموعة.
فتح الحزمة
k this deck
18
The case statement syntax requires a(n) ____ to mark the end of each code portion matching a specific value.

A) period (.)
B) exclamation mark(!)
C) double semicolon (;;)
D) double exclamation mark(!!)
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 48 في هذه المجموعة.
فتح الحزمة
k this deck
19
The cat command is usually used to display the contents of a ____.

A) large text file
B) log file
C) small text file
D) memory dump
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 48 في هذه المجموعة.
فتح الحزمة
k this deck
20
The head command displays the first ____ lines of a text file.

A) two
B) five
C) ten
D) 100
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 48 في هذه المجموعة.
فتح الحزمة
k this deck
21
What is the result of running the head -15 scr8 command?

A) The command displays the last 15 lines of the scr8 file.
B) The command displays the first 15 lines of the scr8 file.
C) The command displays the contents of the scr8 file without the last 15 lines.
D) The command displays the contents of the scr8 file starting at line 15.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 48 في هذه المجموعة.
فتح الحزمة
k this deck
22
What is the result of running the tail +5 scr8 command?

A) The command displays the last five lines of the scr8 file.
B) The command displays every fifth line of the scr8 file.
C) The command displays the contents of the scr8 file in reverse, five times.
D) The command displays the contents of the scr8 file starting at line five.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 48 في هذه المجموعة.
فتح الحزمة
k this deck
23
Which command displays a file's contents one screen at a time?

A) head
B) show
C) echo
D) more
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 48 في هذه المجموعة.
فتح الحزمة
k this deck
24
Which command works the same as the more command but offers more flexibility in navigation?

A) less
B) dis
C) down
D) show
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 48 في هذه المجموعة.
فتح الحزمة
k this deck
25
A(n) ____________________ is a set of rules for instructing a computer how to perform specific tasks.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 48 في هذه المجموعة.
فتح الحزمة
k this deck
26
With a(n) ____________________ program, the source code is converted to machine code, line by line, as the user runs the script.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 48 في هذه المجموعة.
فتح الحزمة
k this deck
27
The purpose of a(n) ____________________ is to add documentation information for users and anyone else who might need to modify the script.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 48 في هذه المجموعة.
فتح الحزمة
k this deck
28
When you quit a program or a command, a numeric code called a(n) ____________________ is sent to the shell.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 48 في هذه المجموعة.
فتح الحزمة
k this deck
29
____________________ is used to perform a set of commands repeatedly.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 48 في هذه المجموعة.
فتح الحزمة
k this deck
30
Match each statement with an item

-Indicates the end of the condition being tested.

A) if statement
B) then statement
C) else statement
D) fi statement
E) while statement
F) until statement
G) for statement
H) do statement
I) done statement
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 48 في هذه المجموعة.
فتح الحزمة
k this deck
31
Match each statement with an item

-Indicates the end of the code to be repeated.

A) if statement
B) then statement
C) else statement
D) fi statement
E) while statement
F) until statement
G) for statement
H) do statement
I) done statement
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 48 في هذه المجموعة.
فتح الحزمة
k this deck
32
Match each statement with an item

-A loop statement that specifies the number of times to execute the portion of code.

A) if statement
B) then statement
C) else statement
D) fi statement
E) while statement
F) until statement
G) for statement
H) do statement
I) done statement
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 48 في هذه المجموعة.
فتح الحزمة
k this deck
33
Match each statement with an item

-A loop statement that causes the interpreter to continue executing the code in the until loop portion of the script as long as the condition is false.

A) if statement
B) then statement
C) else statement
D) fi statement
E) while statement
F) until statement
G) for statement
H) do statement
I) done statement
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 48 في هذه المجموعة.
فتح الحزمة
k this deck
34
Match each statement with an item

-Starts the condition being tested.

A) if statement
B) then statement
C) else statement
D) fi statement
E) while statement
F) until statement
G) for statement
H) do statement
I) done statement
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 48 في هذه المجموعة.
فتح الحزمة
k this deck
35
Match each statement with an item

-A loop statement that tests a condition in much the same way as if-then statements.

A) if statement
B) then statement
C) else statement
D) fi statement
E) while statement
F) until statement
G) for statement
H) do statement
I) done statement
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 48 في هذه المجموعة.
فتح الحزمة
k this deck
36
Match each statement with an item

-Starts the portion of code specifying what to do if the condition evaluates to false.

A) if statement
B) then statement
C) else statement
D) fi statement
E) while statement
F) until statement
G) for statement
H) do statement
I) done statement
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 48 في هذه المجموعة.
فتح الحزمة
k this deck
37
Match each statement with an item

-Indicates the beginning of the code to be repeated.

A) if statement
B) then statement
C) else statement
D) fi statement
E) while statement
F) until statement
G) for statement
H) do statement
I) done statement
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 48 في هذه المجموعة.
فتح الحزمة
k this deck
38
Match each statement with an item

-Starts the portion of code specifying what to do if the condition evaluates to true.

A) if statement
B) then statement
C) else statement
D) fi statement
E) while statement
F) until statement
G) for statement
H) do statement
I) done statement
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 48 في هذه المجموعة.
فتح الحزمة
k this deck
39
Identify and define the three categories of file permissions.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 48 في هذه المجموعة.
فتح الحزمة
k this deck
40
Why should you give only read and write permission to a file that is not a program?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 48 في هذه المجموعة.
فتح الحزمة
k this deck
41
Why is it essential to understand the basics of shell scripting?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 48 في هذه المجموعة.
فتح الحزمة
k this deck
42
After creating a shell script and assigning execute permissions, how do you define its stored location and why must you do this?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 48 في هذه المجموعة.
فتح الحزمة
k this deck
43
Describe a shell variable.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 48 في هذه المجموعة.
فتح الحزمة
k this deck
44
How do you combine the else and if statements? Why is this advantageous?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 48 في هذه المجموعة.
فتح الحزمة
k this deck
45
Describe the case statement.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 48 في هذه المجموعة.
فتح الحزمة
k this deck
46
Describe an until loop.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 48 في هذه المجموعة.
فتح الحزمة
k this deck
47
Describe a for loop.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 48 في هذه المجموعة.
فتح الحزمة
k this deck
48
Which command can be used to display a text file's contents in reverse order and why might a user want to do this?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 48 في هذه المجموعة.
فتح الحزمة
k this deck
locked card icon
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 48 في هذه المجموعة.