wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

BSIT3201-Finals

Total questions: 50

Worksheet time: 25mins

Name
Class
Date
1.
  1. Which of the following best explains why using #!/bin/bash at the beginning of a script is important?

a)

It makes the script executable.

b)

It defines the location of the shell to execute the script.

c)

It comments out the second and last line of the executable script

d)

It sets the default permissions of the file in bash scriptng

2.
  1. You are writing a script to check disk space. Which command combination is most effective for storing and analyzing the used disk percentage?

a)

ls | grep

b)

df -h | awk '{print $5}'

c)

du -h | head -1

d)

ps aux | sort

3.
  1. Which statement is true regarding variables in shell scripting?

a)

All variables must be declared with var int.

b)

Variables are declared with a dollar sign $ prefix.

c)

Variable values are assigned using = without spaces.

d)

All variables are automatically global.

4.
  1. What will the following script output?
    bash

  2. x=5
    y=10

    echo $((x+y))

a)

x+y

b)

15

c)

5+10

d)

Error

5.
  1. Why is chmod +x script.sh necessary before executing a script directly?

a)

It changes the owner of the script.

b)

It adds write permissions to the script.

c)

It allows the script to be executed.

d)

It creates a backup of the script.

6.

A system admin wants to create a backup script that copies all .conf files from /etc to /backup and logs the time of backup.
Which of the following commands is most appropriate in the script?

a)

cp /etc/*.conf /backup && date >> log.txt

b)

mv /etc/*.conf /backup && time >> log.txt

c)

cat /etc/*.conf > /backup && echo $date >> log.txt

d)

ls /etc/*.conf | cp /backup && echo date >> log.txt

7.
  1. You wrote a script with this snippet:

What would happen if the user entered a non-numeric input like "abc"?

a)

The script prints "Low".

b)

It compares text and prints "High".

c)

It shows a syntax error.

d)

It crashes with an error message.

8.
  1. A user complains that their script doesn’t respond to keyboard interrupts (Ctrl+C) during a loop. What is the best way to handle this in the script?

a)

Add trap 'exit' INT at the beginning.

b)

Use kill -9 $$ inside the loop.

c)

Add continue to the loop.

d)

Use echo off to ignore input.

9.
  1. You want to display all files modified in the last 24 hours using a script. Which command best fits?

a)

ls -lt

b)

find . -mtime -1

c)

grep "today" *

d)

history | tail

10.

Your script processes user data from a file line by line. Which loop is best suited for this task?

a)

for user in file; do ...

b)

while read user; do ... done < file

c)

until read user; do ... done < file

d)

if read user; then ... fi

11.

What is the most efficient way to ensure a script variable is not empty before using it in a calculation?

a)

Use if $var != ""

b)

Use if [ -z "$var" ]

c)

Use test $var == NULL

d)

Use if [ $var -eq 0 ]

12.
  1. What is the purpose of using double brackets [[ ... ]] instead of single brackets [ ... ] in conditionals?

a)

There is no difference.

b)

It allows the use of && and || without escaping.

c)

It prevents variable expansion in an expression.

d)

It disables arithmetic comparisons between variables.

13.
  1. A script is designed to accept one argument—a filename—and print "File exists" if it is present.
    Which conditional best fits?

a)

if [[ -f $1 ]]; then echo "File exists"; fi

b)

if test $1; then echo "File exists"; fi

c)

if ls $1; then echo "File exists"; fi

d)

if $1 -eq 1; then echo "File exists"; fi

14.
  1. You wrote a script with this loop:

Which issue might arise if no .txt files exist in the directory?

a)

It loops infinitely.

b)

It throws a segmentation fault.

c)

It prints Processing *.txt

d)

It silently exits.

15.

You want a script to notify the user if a directory does not exist before trying to enter it. What is the best conditional structure?

a)

if [ -d "$dir" ]; then cd "$dir"; else echo "No such directory"; fi

b)

cd "$dir" || echo "Directory created"

c)

mkdir "$dir" && echo "Error"

d)

cd "$dir" && echo "Invalid folder"

16.

What does the -p option do when used with the read command in a shell script?

a)

Prints the input after reading

b)

Pauses the script before reading

c)

Prompts the user with a custom message before reading input

d)

Prevents the user from entering blank input upon running the script

17.
  1. Which of the following best explains the use of -gt in the conditional [ $a -gt $b ]?

a)

Compares strings lexicographically

b)

Compares two integers to check if $a is greater than $b

c)

Checks if both variables are positive integers

d)

Checks if both variables are null

18.

You are writing a script that accepts user age as input. If the user is older than 17, it should print "You are eligible". Which script fragment works correctly?

a)

if [ $age > 17 ]; then echo "You are eligible"; fi

b)

if (( $age > 17 )); then echo "You are eligible"; fi

c)

if [ $age -gt 17 ]; then echo "You are eligible"; fi

d)

Both b and c

19.

You want to prompt the user for their name and store it in a variable. Which is the most appropriate line?

a)

input "Enter name: " name

b)

read -n "Enter name: " name

c)

read name < "Enter name: "

d)

read -p "Enter name: " name

20.
  1. A script runs the following:

  2. What should the user avoid doing to prevent a script error?

a)

Inputting negative numbers

b)

Pressing Enter without typing anything

c)

Entering text instead of a number

d)

Both b and c

21.

You are troubleshooting system boot issues. Which directory should you inspect for essential boot-related files?

a)

/boot

b)

/dev

c)

/lib

d)

/opt

22.

A Linux user is complaining that their GUI is consuming too much RAM on an old PC. As an administrator, which environment would you recommend switching to?

a)

GNOME

b)

Xfce

c)

Cinnamon

d)


KDE

23.

You are asked to configure a multi-user server. Each user should have isolated space to store personal files. Which directory will you configure for this?

a)

/home

b)


/bin

c)

/etc

d)

/sbin

24.

Which combination of commands allows a user to create a directory, move into it, and confirm the change?

a)

mkdir, cd, ls

b)

mkdir, cd, pwd

c)

cp, cd, man

d)

cd, pwd, tree

25.

A user reports that a file is missing. Before restoring from backup, which command would be best to search for all files and directories under the current folder recursively?

a)

tree

b)

ls

c)

pwd

d)

file

26.

You are tasked to audit software in /usr/bin and /opt/bin. What does this suggest about the nature of these directories?

a)

Both B and C are reserved for device drivers

b)

/opt/bin contains optional or third-party software;
/usr/bin contains essential shared programs

c)

Both are temporary storage

d)

/opt/bin is for system libraries; /usr/bin is for user scripts

27.

You need to write a command-line instruction that navigates to the parent directory from the current one. Which command would be best?

a)

pwd

b)

cd ..

c)

cd /

d)

cd ~

28.

You are using a system where typing ls provides a list, but you want to know which files are directories, executables, or symbolic links. What should you do?

a)

Use pwd to check file types

b)

Use file on each listed item

c)

Use whatis

d)

Use tree instead

29.

A colleague wants to install a new app from source code without interfering with system files. Which directory is the most appropriate installation target?

a)

/boot

b)

/opt

c)

/home

d)


/usr

30.

A user with limited access needs to move a file into a protected system directory. The move fails. What is the best solution to resolve this issue?

a)

Try from the /home directory

b)

Run the command again with sudo

c)

Restart the system

d)

Use cp instead of mv

31.

What advantage does vi have over gedit in managing remote Linux servers?

a)

It supports only one editing mode

b)

It is available by default on all Linux distributions

c)

It has a graphical interface

d)


It can’t be used in command-line mode

32.

How does the Insert mode in vi differ from the Replace mode in terms of user interaction?

a)

Insert mode overwrites characters; Replace mode adds new ones.

b)

Insert mode adds characters; Replace mode overwrites them.

c)

Replace mode deletes whole lines

d)

Both work the same way

33.

A user accidentally deleted 10 lines in vi.

Which command could have done that?

a)

x10

b)

10dd

c)

10yy

d)


:q!

34.

Why is LibreOffice Base considered useful for enterprise users?

a)

It offers presentation slide tools

b)

It supports integration with major database systems

c)

It comes with Python pre-installed

d)

It has tools for vector graphics

35.

How does the Presenter Console in LibreOffice Impress enhance presentation delivery?

a)

By converting slides to animated GIFs for presentation

b)

By giving the presenter control over timing and slide notes

c)

By automatically translating slides

d)

By allowing note-taking by the audience

36.

While coding in vi, you want to copy the current line and the next four lines for reuse later. What command should you use?

a)

yy5

b)

5yy

c)

5dd

d)

yG

37.

What is the purpose of the A command in vi, and how does it differ from the i command?

a)

Both insert text at the beginning of the line

b)

A inserts at the end of the line, i inserts at the cursor

c)

A inserts text at the cursor, i inserts after the line

d)

A deletes text; i saves changes

38.

How does LibreOffice Writer’s AutoComplete enhance document creation efficiency?

a)

It translates foreign words automatically

b)

It suggests words based on a dictionary and open documents

c)

It completes code blocks using Artificial Intelligence

d)

It limits the use of non-standard words

39.

What would be the most efficient way in vi to delete from the current cursor position to the end of the line?

a)

x

b)

d$

c)

dd

d)

dW

40.


Why is vim often preferred over the original vi editor in modern Linux distributions?

a)

It is the only GUI-based editor

b)

It offers enhancements like syntax highlighting and plugins

c)

It is easier to install and configure

d)

It does not require command mode

41.

The comparison [ 5 -gt "3" ] in a shell script will return an error because one operand is a string.

a)

True

b)

False

42.

This condition will safely handle blank input:

a)

True

b)

False

43.

The command mkdir -p /home/user/docs will throw an error if /home/user already exists.

a)

True

b)

False

44.

Using a graphical user interface (GUI) for Linux system administration offers the same level of system control and scripting flexibility as the command line interface (CLI).

a)

True

b)

False

45.

Placing compiled third-party applications into the /opt directory instead of /usr/bin helps maintain a cleaner and more maintainable file structure.

a)

True

b)

False

46.

The man command can only be used by administrators and requires superuser privileges to display manual pages of commands.

a)

True

b)

False

47.

The /proc directory contains real, physical files stored on disk that remain unchanged after rebooting the system.

a)

True

b)

False

48.

LibreOffice Calc’s ability to integrate real-time data streams is especially useful for financial forecasting and live reporting.

a)

True

b)

False

49.

LibreOffice Impress’s Presenter Console reduces distractions during a presentation by hiding slide notes and timers from the presenter.

a)

True

b)

False

50.

In vi, the command dG deletes only the current line and leaves the rest of the file intact.

a)

True

b)

False