wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Linux2 - Quizz 5 -bash scripting

Total questions: 16

Worksheet time: 12mins

Name
Class
Date
1.

How can I print the current system variables?

a)

echo bash

b)

echo $bash

c)

print bash

d)

printf bash

2.

How can I input data into a shell script in an neat way?

a)

read -p "Enter your age"

b)

read -p "Enter your age" age

c)

read "Enter your age"

d)

read "Enter your age" age

3.

How can I check if an file is readable?

a)

if [[ -r $file ]]; then

echo "File is not readable"

exit 0

fi

b)

if [[ -d $file ]]; then

echo "File is not readable"

exit 0

fi

4.

How to compare if 2 integers (a = 1, b = 2) are equal?

a)

if [a -eq b]

b)

if [a = b]

c)

if [a isequal b]

d)

if [ b equal a]

5.

How can I check if a directory exists ?

path = "/tmp/sound"

a)

if [ -d "$path" ];

b)

if [ -r "$path" ];

c)

if [ -e "$path" ];

d)

if [ -w "$path" ];

6.

Cron at 16:00 on day-of-month 1 in every month from January through December

a)

00 16 1 1-12 /home/frank/BackUpAll.sh; /home/frank/ScpTarBackup.sh

b)

00 04 1 1-12 /home/frank/BackUpAll.sh; /home/frank/ScpTarBackup.sh

c)

16 00 1 1-12 /home/frank/BackUpAll.sh; /home/frank/ScpTarBackup.sh

d)

16 16 1 1-12 /home/frank/BackUpAll.sh; /home/frank/ScpTarBackup.sh

7.

How can I edit a cronjob?

a)

crontab -l

b)

crontab -e

c)

crontab

d)

crontab -m

8.

The correct way to redirect stderror and stdout in a cronjob

a)

1 12 * * * /home/frank/BackUpAll.sh >/tmp/mycommand.log 2>&1

b)

1 12 * * * /home/frank/BackUpAll.sh >/tmp/mycommand.log

c)

1 12 * * * /home/frank/BackUpAll.sh >>/tmp/mycommand.log 2>&1

d)

1 12 * * * /home/frank/BackUpAll.sh >/tmp/mycommand.log 2>&@

9.

When using the crontab -e option, how to delete a single line?

a)

dd

b)

d

c)

press the del-key

d)

<ctrl> d

10.

How can you search for a text-string in the crontab when using crontab -e

a)

Using the ‘l’ command

b)

Using the ‘f’ command

c)

Using the ‘s’ command

d)

Using the ‘/’ command

11.

Which port is the default SSH port?

a)

9999

b)

2222

c)

22

d)

8080

12.

Which of the following statements is true (more answers might be correct)?

a)

Apache is an open source application and webserver

b)

Runs as HTTPD on RHEL systems, otherwise as Apache2

c)

Uses httpd.conf for configuration

d)

You need to check rights and permissions on files in /var/www and config-files

13.

What can you perform with the function ‘test –e "string"’ in your script

a)

It will return false if length of string is not zero

b)

It will return true if a file exists

c)

It will return 1 if length of string is not zero

d)

It will return 0 if a string is empty

14.

Which of the following anwsers is correct about the WHILE-statement (more answers can be correct)?

a)

A while statement is used to determine if a condition is true or false

b)

If it is true then a series of actions takes place and the condition is checked again

c)

If the condition is false, then no action takes place and the program continues

d)

The while statement along with the block of statements to be executed when it is true is also know as a while loop

15.

What command can be used to view the Exit Status of the last run script?

a)

print status

b)

echo status

c)

echo $?

d)

print $cc

16.

How to end a for-loop in a linux script?

a)

ROF

b)

DONE

c)

END

d)

STOP