Mastering Linux Shell Scripting

Mastering Linux Shell Scripting

12th Grade

17 Qs

quiz-placeholder

Similar activities

PHP nulmeting

PHP nulmeting

8th Grade - Professional Development

14 Qs

Pemrograman Berorientasi Objek

Pemrograman Berorientasi Objek

12th Grade

20 Qs

POCS-Ch4.1 & 4.2 (Vocab)

POCS-Ch4.1 & 4.2 (Vocab)

8th - 12th Grade

20 Qs

Introduction to Microsoft Word

Introduction to Microsoft Word

9th - 12th Grade

16 Qs

POCS-Ch. 4 Review (Comprehension)

POCS-Ch. 4 Review (Comprehension)

7th - 12th Grade

20 Qs

Text Files in Python

Text Files in Python

12th Grade

20 Qs

Python Basics & Syntax

Python Basics & Syntax

10th - 12th Grade

20 Qs

3.1.1 Commanding the OS

3.1.1 Commanding the OS

9th - 12th Grade

12 Qs

Mastering Linux Shell Scripting

Mastering Linux Shell Scripting

Assessment

Quiz

Computers

12th Grade

Hard

Created by

Grit and Motivation

Used 2+ times

FREE Resource

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.

Create a free account and access millions of resources

Create resources
Host any resource
Get auto-graded reports
or continue with
Microsoft
Apple
Others
By signing up, you agree to our Terms of Service & Privacy Policy
Already have an account?