wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Linux Command and Scripting Quiz

Total questions: 78

Worksheet time: 42mins

Name
Class
Date
1.

Which key must be pressed in the interactive mode of the top utility to sort processes by memory consumption?

a)

h

b)

M (Shift+m)

c)

k

d)

P (Shift+p)

e)

q

2.

Which command returns a background process to the foreground?

a)

back

b)

jobs

c)

nohup

d)

fg

e)

restore

3.

How to display the latest log entries in real time?

a)

systemctl watch-logs

b)

sudo dmesg-l

c)

sudo journalctl-f

d)

sudo tail /var/log/messages

e)

journalctl--live

4.

Which command is used to change the priority (nice) of an already running process?

a)

ps --nice

b)

change_priority

c)

priority

d)

nice

e)

renice

5.

Which tool analyzes shell scripts for errors and provides recommendations?

a)

shellcheck

b)

shfmt

c)

grep

d)

awk

e)

systemd-analyze

6.

What does the recommendation 'Never work as root permanently' mean?

a)

Root should be used to launch user processes.

b)

This rule can be ignored in a local network.

c)

Use a regular user and perform administrative actions via sudo.

d)

The root account should be deleted after system installation.

e)

The root user should always be active on all servers.

7.

Which bootloader is the most common in Linux?

a)

BOOTMGR

b)

LILO

c)

SYSLINUX

d)

GRUB2

e)

PXE Loader

8.

What is the name of the 'mother' distribution that is the benchmark of stability for the family that includes Ubuntu and Kali?

a)

SUSE

b)

Red Hat Enterprise Linux

c)

Slackware

d)

Gentoo

e)

Debian

9.

How to hide password input in a shell script?

a)

Enter the password into a variable without quotes.

b)

Use read -s -p 'Enter password: ' user_password.

c)

Use the echo $password command.

d)

Use cat /dev/null > password.

e)

Hide the password via chmod.

10.

What is the primary function of the Kernel during system boot?

a)

Configure user interfaces.

b)

Monitor network connections.

c)

Manage BIOS parameters.

d)

Check checksums of all files.

e)

Initialize hardware, mount the root filesystem, and launch the first process.

11.

What is the Shell in Linux?

a)

A graphical shell for designing interfaces.

b)

A command interpreter that provides interaction between the user and the operating system.

c)

A service for managing user accounts.

d)

A kernel module responsible for network connections.

e)

A program for compiling source code.

12.

What does the command ping -c1 -W1 '$TARGET' &>/dev/null do in a script?

a)

Checks the availability of the $TARGET host by sending one ICMP packet and suppressing the output.

b)

Checks for an SSH key on the server.

c)

Establishes a persistent connection with $TARGET.

d)

Measures download speed from the host.

e)

Scans the network for open TCP ports.

13.

What is a 'process' in the context of the Linux operating system according to the lecture?

a)

A static program file stored on a hard disk.

b)

The smallest unit of execution that shares memory with other units.

c)

A set of drivers for connecting peripheral devices.

d)

An instance of a running program that has its own address space and resources.

e)

A special command for updating the system kernel.

14.

Which of the listed IP address ranges belongs to private addresses (Private IP, RFC 1918) and is not routable on the internet?

a)

8.8.8.8/32

b)

192.168.0.0/16

c)

77.88.55.242/24

d)

1.1.1.1/32

e)

150.10.10.0/24

15.

What is the main difference between the TCP and UDP protocols according to the lecture?

a)

TCP is used exclusively for DNS queries, while UDP is for websites.

b)

There is no difference; they are two names for the same protocol.

c)

UDP guarantees packet delivery in strict order, unlike TCP.

d)

TCP works only in local networks, while UDP works only on the global internet.

e)

TCP guarantees data delivery and establishes a connection, while UDP does not (faster but without guarantees).

16.

What is the primary task of the BIOS/UEFI stage during Linux boot?

a)

Launch security diagnostic utilities.

b)

Mount the root filesystem.

c)

Check the integrity of systemd logs.

d)

Initialize hardware and prepare to launch the bootloader.

e)

Load the user desktop.

17.

What is the advantage of the mtr utility over standard ping and traceroute?

a)

It combines the functions of ping and traceroute, providing real-time statistics.

b)

It works without using a network card (offline).

c)

It allows cracking Wi-Fi network passwords.

d)

It encrypts all traffic passing through it.

e)

It automatically fixes connection issues on the line.

18.

What does the process state 'Z' (Zombie) mean in the output of monitoring commands?

a)

The process has finished execution, but the parent process has not read its exit status (has not called wait()).

b)

The process is running with maximum real-time priority.

c)

The process is in a deep sleep and waiting for disk I/O.

d)

The process is infected with malware and blocked by antivirus.

e)

The process was forcibly terminated by the system due to lack of memory (OOM Killer).

19.

What does 'regular auditing' imply in the context of best practices?

a)

Archiving logs without analysis.

b)

Counting users in /home.

c)

Checking system permissions, ACLs, and SUID files for security violations.

d)

Allowing all users to run sudo.

e)

Clearing temporary directories without checking.

20.

Why is shell scripting required for a security specialist?

a)

To install graphical themes.

b)

To manage the NTFS file system.

c)

To manually edit the Linux kernel.

d)

To configure user desktop profiles.

e)

To automate tasks-collecting artifacts, analyzing logs, monitoring, and penetration testing.

21.

Why should variables always be enclosed in quotes when substituting ('$var', not $var)?

a)

To prevent splitting the value into multiple arguments and avoid erroneous deletions or expansions.

b)

To convert the value to uppercase.

c)

So that Bash treats the value as numeric.

d)

To speed up script execution.

e)

To make the variable global.

22.

How do local variables differ from environment variables?

a)

Local variables are automatically exported.

b)

Local variables are available to all system users.

c)

There is no difference-they are the same.

d)

Local variables are only valid within the current script, while environment variables are inherited by child processes.

e)

Environment variables are stored only in /etc/environment.

23.

What does the TTL (Time To Live) parameter do in network packets?

a)

Defines the 'lifetime' of a packet, decreasing by 1 at each router (protection against looping).

b)

Determines the maximum size of the transmitted file.

c)

Shows the exact sending time of the packet in milliseconds.

d)

Indicates how many times the packet was lost during transmission.

e)

Determines the priority of the packet over other data (higher TTL means faster delivery).

24.

Which command clears old logs to a size of 200 MB?

a)

journalctl-clear 200M

b)

sudo journalctl--truncate=200M

c)

sudo logclean--size=200M

d)

sudo journalctl--vacuum-size=200M

e)

systemctl clean-journal 200M

25.

Why is it necessary to protect the /root directory?

a)

Its contents are duplicated in /tmp.

b)

It is used for backing up users' home directories.

c)

It contains superuser configurations and scripts; access to them gives full control over the system.

d)

It is writable by every user.

e)

It only stores temporary files and poses no risk.

26.

Why is it important to forward system logs to a remote server?

a)

To speed up the work of systemd-journald.

b)

To reduce disk load.

c)

For automatic package updates.

d)

So that an attacker cannot delete or modify local logs on a compromised machine.

e)

For organizing file backups.

27.

Which low-level utility in the Debian family installs .deb files but does NOT resolve dependencies?

a)

dpkg

b)

synaptic

c)

tasksel

d)

dnf

e)

apt

28.

Why is the [[ ... ]] construct safer than [ ... ] for condition checks?

a)

It works faster than [ ... ] and executes in parallel.

b)

There is no difference between them.

c)

[[ ... ]] does not perform expansion of special characters, thus protecting values from Bash interpretation.

d)

It allows using Python syntax.

e)

It ignores command execution errors.

29.

What is EPEL in the context of RHEL systems?

a)

The 'Extra Packages for Enterprise Linux' repository, containing thousands of additional packages.

b)

A graphical interface for server management.

c)

A paid subscription for technical support from Oracle.

d)

A utility for recovering deleted configuration files.

e)

A special kernel mode for improving database performance.

30.

Which command allows displaying logs of a specific systemd service?

a)

syslog-s

b)

journalctl-u

c)

systemctl logs

d)

logshow

e)

cat /var/log/.log

31.

Why is it recommended to use the ss utility instead of netstat in modern Linux distributions?

a)

ss is a modern utility that works faster and shows more accurate information.

b)

ss allows remotely rebooting routers.

c)

ss has a beautiful graphical interface, unlike netstat.

d)

ss is used only for IPv6, while netstat is only for IPv4.

e)

netstat no longer supports the TCP protocol.

32.

What are the recommended permissions for the /etc/passwd file?

a)

755 (rwxr-xr-x)

b)

600 (rw-------)

c)

700 (rwx------)

d)

777 (rwxrwxrwx)

e)

644 (rw-r--r--)

33.

What is the main purpose of the Secure Boot function?

4 lines
34.

What is the main purpose of the Secure Boot function?

a)

Provide remote recovery of the boot partition.

b)

Monitor network connections during system startup.

c)

Verify the digital signature of the bootloader to prevent launching unsigned (malicious) code.

d)

Automatically select the kernel version at each boot.

e)

Compress initramfs before booting.

35.

How does the traceroute utility determine the path of packets?

a)

It sends a series of packets with a gradually increasing TTL (Time To Live) value.

b)

It downloads the routing table from the provider's central server.

c)

It connects to each router via SSH and requests its IP.

d)

It uses the DNS protocol to query the location of each router.

e)

It sends one packet with maximum priority and waits for a full report from the target node.

36.

Why is a password set on GRUB2?

a)

To automatically update GRUB configuration.

b)

To prevent changing boot parameters (e.g., booting into single-user mode to reset the root password).

c)

To hide the list of available kernels.

d)

To suppress kernel messages on the screen.

e)

To speed up system boot.

37.

What is the shfmt command used for?

a)

For running bash scripts as system services.

b)

For checking file integrity.

c)

For searching for vulnerabilities in logs.

d)

For automatic formatting and alignment of shell code.

e)

For encrypting environment variables.

38.

What is Heap Overflow?

a)

An error when reading kernel logs.

b)

An error where data is written beyond the allocated memory area (heap), which can lead to arbitrary code execution.

c)

Excessive traffic in the network buffer.

d)

A memory shortage leading to system hangs.

e)

Corruption of the filesystem table.

39.

What does the directive set -euo pipefail do at the beginning of a script?

a)

Increases reliability: terminates execution on errors, undeclared variables, and pipeline failures.

b)

Sets the PIPEFAIL environment variable.

c)

Ignores all errors except fatal ones.

d)

Runs the script in the background.

e)

Uses the Python interpreter.

40.

What is the Fail2Ban tool, mentioned in the lecture, used for?

a)

To monitor the server's CPU temperature.

b)

To speed up the web server by caching requests.

c)

To block ads in the browser on the server.

d)

To automatically block IP addresses after several failed login attempts.

e)

To recover forgotten user passwords.

41.

Which kernel vulnerability allowed modification of system files and obtaining root access?

a)

Dirty Pipe

b)

Meltdown

c)

Log4J

d)

Heartbleed

e)

EternalBlue

42.

What is Kali Linux mainly used for?

a)

Scientific computing and data analysis

b)

Cybersecurity and penetration testing

c)

Office applications and document work

d)

Gaming platform

e)

Web development and programming

43.

Which package manager is used in Debian-based distributions (e.g., Ubuntu)?

a)

zypper

b)

apt

c)

pacman

d)

yum

e)

dnf

44.

How do you redirect standard output and errors to a single file?

a)

command >> file.log 2>> file.log

b)

command &> file.log

c)

command > file.log 2>&1

d)

command | tee file.log

e)

command > file.log 2> file.log

45.

What does the command mkdir project && cd project do?

a)

Copies project to the current directory

b)

Shows the contents of project

c)

Deletes the project directory and creates a new one

d)

Creates the project directory or changes to it

e)

Creates the project directory and changes to it

46.

Which command copies a directory with all its contents?

a)

copy-all

b)

cp--recursive

c)

rcp

d)

cp-a

e)

cp-r

47.

Which find command searches for all files with .log extension in the /var/log directory?

a)

find /var/log -name "*.log"

b)

find /var/log -pattern "*.log"

c)

find /var/log -ext log

d)

find /var/log -type "*.log"

e)

find /var/log -file "*.log"

48.

How can I add text to the end of an existing file without deleting its contents?

a)

cat "text" >> file.txt

b)

write "text" file.txt

c)

append "text" file.txt

d)

echo "text" >> file.txt

e)

echo "text" > file.txt

49.

Which command can be used to safely delete a directory with confirmation for each file?

a)

remove--safe

b)

rm-rf

c)

rmdir

d)

rm-ri

e)

delete-i

50.

Which key combination is used in the Nano editor to save a file?

a)

Ctrl + X

b)

Ctrl + W

c)

Alt + S

d)

Ctrl + S

e)

Ctrl + O

51.

What command can be used to find all .txt files modified in the last 7 days?

a)

find . -type txt -days 7

b)

search "*.txt" -modified 7

c)

grep "*.txt" -mtime 7

d)

find . -name "*.txt" -mtime -7

e)

ls *.txt -new 7

52.

Which command can be used to view the value of the HOME environment variable?

a)

echo $HOME

b)

env HOME

c)

show $HOME

d)

get HOME

e)

print HOME

53.

What does the cd .. command do?

a)

Go to the root directory

b)

Create a new directory

c)

Go to the home directory

d)

Go to the parent directory

e)

Show the command history

54.

Which key combination in Nano starts selecting a block of text?

a)

Ctrl + A

b)

Alt + A

c)

Ctrl + K

d)

Ctrl + H

e)

Ctrl + 6

55.

How to exit the nano editor with saving changes?

a)

Ctrl + S

b)

Ctrl + W

c)

Esc

d)

Ctrl + X

e)

Ctrl + Q

56.

Which pattern (globbing) matches any single character in a filename?

a)

*

b)

?

c)

[]

d)

%

e)

_

57.

How to create a directory named "projects" in the Linux terminal?

a)

newdir projects

b)

create projects

c)

mkdir projects

d)

dir projects

58.

Which command in Vim copies the current line?

a)

copy

b)

cc

c)

yy

d)

pp

e)

dd

59.

Which key combination in Nano undoes the last action?

a)

Ctrl + R

b)

Alt + U

c)

Ctrl + Z

d)

Ctrl + U

e)

Alt + Z

60.

What command in Vim allows you to exit without saving changes?

a)

:wq

b)

:x!

c)

:quit

d)

:exit!

e)

:q!

61.

Which of the following freedoms is NOT included in the four freedoms of the GPL license?

a)

The freedom to distribute modified versions

b)

The freedom to distribute copies

c)

The freedom to run the program for any purpose

d)

The freedom to sell the program without disclosing the source code

e)

The freedom to study how the program works and modify it

62.

Which command counts the number of lines in a file or input data?

a)

total-l

b)

wc -l

c)

lines

d)

count-l

e)

grep-c

63.

What command in Linux creates a new group called "developers"?

a)

creategroup developers

b)

newgrp developers

c)

addgroup developers

d)

groupadd developers

e)

mkgroup developers

64.

Which numeric code corresponds to "read and write" access rights for the owner and "read only" for everyone else?

a)

600

b)

777

c)

644

d)

755

e)

744

65.

What command sets the "sticky bit" on the /tmp directory to protect files from being deleted by non-owners?

a)

chmod +s /tmp

b)

setfacl -m t /tmp

c)

chmod +t /tmp

d)

chmod 1755 /tmp

e)

chattr +s /tmp

66.

Which command in Vim displays line numbers?

a)

:line numbers

b)

:numbers on

c)

:show numbers

d)

:set linenum

e)

:set number

67.

How to delete a directory with all its contents in Linux?

a)

rmdir

b)

rm-d

c)

rm -r

d)

remove-all

e)

delete-r

68.

Which command allows you to find all files with 777 access rights in the current directory and its subdirectories?

a)

ls -l | grep 777

b)

search --mode 777

c)

find . -perm 777

d)

chmod 777 *

e)

locate -perm 777

69.

Which character at the beginning of a line in the output of ls -l indicates a regular file?

a)

c

b)

l

c)

-

d)

f

e)

d

70.

Which command is used to view the used and free space on mounted partitions?

a)

fdisk -l

b)

du -h

c)

mount | grep dev

d)

df -h

e)

lsblk

71.

Which file attribute, using the chattr command, makes a file immutable (cannot be deleted or modified)?

a)

+d

b)

+u

c)

+i

d)

+a

e)

+s

72.

What does the command ls [ab]*.log mean?

a)

Show all .log files

b)

Show .log files beginning with a or b

c)

Show .log files with two-character names

d)

Show hidden .log files

e)

Show .log files containing a or b

73.

What is the UID (user ID) of the root superuser in Linux?

a)

0

b)

1000

c)

999

d)

100

e)

1

74.

Which project did Richard Stallman aim to create a free UNIX-like operating system?

a)

The Hurd Project

b)

The BSD Project

c)

The OpenSource Project

d)

The Minix Project

e)

The GNU Project

75.

Which file system is recommended for working with large files and has high performance?

a)

Btrfs

b)

XFS

c)

ext4

d)

FAT32

e)

NTFS

76.

Which uniq command shows the number of repetitions of each line?

a)

uniq-count

b)

uniq-d

c)

uniq--repeat

d)

uniq-n

e)

uniq -c

77.

Which operator is used to redirect command output to a file with content overwriting?

a)

>>

b)

|

c)

<

d)

>

e)

&

78.

How do you perform a global replacement of "old" with "new" throughout an entire file in Vim?

a)

:s/old/new/g

b)

:%s/old/new/g

c)

:replace old new

d)

:all s/old/new/

e)

:global s/old/new/