Search Header Logo

Mastering Linux Shell Scripting

Authored by Joe Cusack

Computers

12th Grade

Used 3+ times

Mastering Linux Shell Scripting
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

17 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which command is used to list all files and directories in the current directory in Linux?

`ls`

`cd`

`pwd`

`rm`

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

In a shell script, how do you assign the value "Hello" to a variable named `greeting`?

`greeting = Hello`

`greeting: Hello`

`greeting="Hello"`

`greeting <- Hello`

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the purpose of the `if` statement in a shell script?

To repeat a block of code multiple times

To execute a block of code based on a condition

To define a function

To redirect input and output

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which command is used to redirect the output of a command to a file, overwriting the file if it exists?

`command > file`

`command >> file`

`command < file`

`command | file`

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the significance of the `$?` variable in shell scripting?

It stores the last executed command.

It stores the exit status of the last executed command.

It stores the current process ID.

It stores the number of arguments passed to the script.

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

How would you use a `for` loop in a shell script to iterate over a list of files?

`for file in ls; do echo $file; done`

`for file in ls; echo $file; done`

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Explain how you would handle errors in a shell script using `trap`.

Use `trap` to execute a command when a signal is received.

Use `trap` to ignore all errors in the script.

Use `trap` to log errors to a file.

Use `trap` to automatically retry failed commands.

Access all questions and much more by creating a free account

Create resources

Host any resource

Get auto-graded reports

Google

Continue with Google

Email

Continue with Email

Classlink

Continue with Classlink

Clever

Continue with Clever

or continue with

Microsoft

Microsoft

Apple

Apple

Others

Others

Already have an account?