
Linux Essentials 2.21 - Basic Scripting M11 Exam
Authored by rehan myccsecurity
Information Technology (IT)
12th Grade

AI Actions
Add similar questions
Adjust reading levels
Convert to real-world scenario
Translate activity
More...
Content View
Student View
18 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
A file begins with #!/bin/csh. This means:
Nothing, this is a comment
Running the script will invoke /bin/csh to interpret the rest of the file
The operator should not be using /bin/csh
This is a Perl script
C Shell compatibility mode is enabled
Answer explanation
The line #!/bin/csh is a shebang that indicates the script should be run using the C shell located at /bin/csh. This means running the script will invoke /bin/csh to interpret the rest of the file.
2.
MULTIPLE SELECT QUESTION
30 sec • 1 pt
Which are appropriate editors for writing shell scripts? (Choose two)
Firefox
/bin/bash
LibreOffice Writer
vi
nano
Answer explanation
The appropriate editors for writing shell scripts are 'vi' and 'nano'. Both are text editors commonly used in Unix-like systems, while Firefox and LibreOffice Writer are not suitable for scripting.
3.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Most of nano’s commands take the form of:
Control and another character
Alt and another character
Mouse clicks
Escape followed by another character
The F1 through F12 function keys
Answer explanation
Most of nano's commands are executed using the Control key combined with another character, making 'Control and another character' the correct choice. This is a common shortcut method in many text editors.
4.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What does this shell script do? bash CopyEdit FOO=/tmp/foo if [ ! -d $FOO ]; then mkdir $FOO fi
Deletes the directory /tmp/foo if it exists
Creates the directory /tmp/foo if it does not exist
Renames /tmp/foo to /tmp/bar
Lists the contents of /tmp/foo
Answer explanation
The script checks if the directory /tmp/foo does not exist. If it doesn't, it creates the directory. Therefore, the correct answer is that it creates the directory /tmp/foo if it does not exist.
5.
MULTIPLE SELECT QUESTION
30 sec • 1 pt
Which of the following are correct about for and while loops? (Choose two)
while loops have a test each cycle to determine if it should run again
for loops have a test each cycle to determine if it should run again
while loops operate over a fixed list of items
for loops require a variable over which to iterate
for loops operate over a fixed list of items
Answer explanation
While loops check a condition each cycle to decide if they should continue running. For loops typically iterate over a fixed list of items, making them suitable for such operations.
6.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Given the following part of a script: bash copyEdit if [ -f $1 ]; then echo "I am here" fi What is the meaning of $1?
It is a list of files that gets interpolated
It is a file called $1
It is a special variable that indicates the exit code of the command before it
It is a parameter to -f, indicating the size of the file
It is the first argument passed to the script
Answer explanation
In bash scripts, $1 refers to the first argument passed to the script when it is executed. This is why the correct answer is 'It is the first argument passed to the script'. The other options do not accurately describe $1.
7.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
When will “I am here” be printed?
The script will always print “I am here”
If a file called “goodbye” exists in the current directory
Never
If there are two files in the current directory
If a file called “hello” exists in the current directory
Answer explanation
The script prints 'I am here' only if a file named 'goodbye' exists in the current directory. This condition is explicitly stated, making it the correct choice.
Access all questions and much more by creating a free account
Create resources
Host any resource
Get auto-graded reports

Continue with Google

Continue with Email

Continue with Classlink

Continue with Clever
or continue with

Microsoft
%20(1).png)
Apple
Others
Already have an account?