wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Linux Commands Quiz

Total questions: 60

Worksheet time: 30mins

Name
Class
Date
1.

The man command is used to access the detailed user manual for any other command. It provides comprehensive information about the command's syntax, options, and usage examples. For instance, man ls shows everything about the ls command.

a)

Displays the manual (documentation) for other commands.

b)

Lists the contents of a directory (files and folders).

c)

Changes the current working directory.

d)

Prints the full path of the current/working directory.

2.

The ls command lists files and directories. The -l option provides a detailed list with permissions, owner, size, and modification time. The -a option includes hidden files (those starting with a dot). Combining them as ls -al is very common.

a)

Displays the manual (documentation) for other commands.

b)

Lists the contents of a directory (files and folders).

c)

Changes the current working directory.

d)

Prints the full path of the current/working directory.

3.

The cd command is used to navigate between directories. cd folder moves into 'folder', cd .. moves up to the parent directory, and cd or cd ~ takes you directly to your home directory from anywhere.

a)

Changes the current working directory.

b)

Lists the contents of a directory (files and folders).

c)

Prints the full path of the current/working directory.

d)

Creates new directories.

4.

The pwd command outputs the absolute path of the directory you are currently working in. This is essential for orientation within the complex Linux filesystem hierarchy.

a)

Changes the current working directory.

b)

Lists the contents of a directory (files and folders).

c)

Prints the full path of the current/working directory.

d)

Creates new directories.

5.

The mkdir command creates new directories. The powerful -p option allows you to create an entire path of nested directories at once, even if the parent directories don't already exist.

a)

Creates new directories.

b)

Removes empty directories.

c)

Moves or renames files and directories.

d)

Copies files and directories.

6.

The rmdir command is used to delete empty directories. It is a safe command as it will not delete a directory that contains any files or subdirectories, preventing accidental data loss.

a)

Creates new directories.

b)

Removes empty directories.

c)

Moves or renames files and directories.

d)

Copies files and directories.

7.

The mv command has a dual purpose. It is used to move files/directories from one location to another. It is also used to rename them, as renaming is essentially moving the file to the same location with a new name.

a)

Moves or renames files and directories.

b)

Creates new directories.

c)

Removes empty directories.

d)

Copies files and directories.

8.

The cp command creates a copy of a file. To copy an entire directory, including all its subdirectories and files, the -r (recursive) option must be used, as in cp -r dir1 dir2.

a)

Copies files and directories.

b)

Moves or renames files and directories.

c)

Creates new directories.

d)

Removes empty directories.

9.

(Primarily for macOS) The open command is used to open a file with its default GUI application or to open a directory in the Finder. For example, open . opens the current folder.

a)

Opens a file or directory using the default application.

b)

Creates new directories.

c)

Removes empty directories.

d)

Copies files and directories.

10.

The touch command's primary function is to update the access and modification timestamps of a file to the current time. A side effect is that if the file does not exist, touch will create a new, empty file with that name.

a)

Creates an empty new file or updates the timestamp of an existing file.

b)

Opens a file or directory using the default application.

c)

Removes empty directories.

d)

Copies files and directories.

11.

The find command is a powerful utility for searching the filesystem. It can locate files by name (-name), type (-type f for files), modification time (-mtime), and size. It can also execute commands on the results using -exec.

a)

Recursively searches for files and directories based on various criteria.

b)

Creates new directories.

c)

Removes empty directories.

d)

Copies files and directories.

12.

The ln command creates links. A hard link (ln file link) is a direct reference to the file's data. A soft link (ln -s file link) is a separate file that points to the original's path. Soft links are more flexible but break if the original is moved.

a)

Creates links (shortcuts) between files.

b)

Removes empty directories.

c)

Copies files and directories.

d)

Moves or renames files and directories.

13.

The gzip command compresses a file, replacing it with a compressed version ending in .gz. Use the -k option to keep the original file. The -d option is used to decompress a .gz file.

a)

Compresses files using the LZ77 algorithm.

b)

Removes empty directories.

c)

Creates new directories.

d)

Copies files and directories.

14.

The gunzip command is specifically used to decompress files that have been compressed with gzip. It is functionally identical to running gzip -d.

a)

Decompresses files compressed by gzip.

b)

Creates new directories.

c)

Removes empty directories.

d)

Copies files and directories.

15.

The tar command bundles multiple files into a single archive file. The -cf options create an archive, and -xf extract it. Adding the -z option (e.g., -czf) compresses the archive using gzip, creating a .tar.gz file.

a)

Archives multiple files into a single file.

b)

Creates new directories.

c)

Removes empty directories.

d)

Copies files and directories.

16.

The alias command lets you create a custom shorthand for a longer command. For example, alias ll='ls -al' allows you to type ll to get a detailed file listing. They are temporary unless saved in a shell startup file.

a)

Creates a shortcut or nickname for a longer command.

b)

Removes empty directories.

c)

Copies files and directories.

d)

Moves or renames files and directories.

17.

The cat command is primarily used to display the contents of a file on the screen. It can also be used to combine the contents of multiple files and redirect the output to a new file using >.

a)

Concatenates and prints the contents of files to the standard output.

b)

Creates new directories.

c)

Removes empty directories.

d)

Copies files and directories.

18.

The less command opens a file for interactive viewing. It allows you to scroll up and down through large files easily, search for text with /, and jump to the beginning (g) or end (G). It is more efficient than cat for large files.

a)

Views file contents interactively, one screen at a time.

b)

Creates new directories.

c)

Removes empty directories.

d)

Copies files and directories.

19.

The tail command displays the last few lines of a file by default (usually 10). The -n option specifies how many lines to show, and the -f option is vital for monitoring log files in real-time as new entries are added.

a)

Outputs the last part of a file.

b)

Creates new directories.

c)

Removes empty directories.

d)

Copies files and directories.

20.

The wc (word count) command prints the number of lines, words, and bytes contained in a file. Common options include -l to count only lines and -w to count only words. It is often used with pipes, e.g., ls | wc -l.

a)

Counts lines, words, and bytes in a file or input.

b)

Creates new directories.

c)

Removes empty directories.

d)

Copies files and directories.

21.

The grep command searches for patterns (text/regular expressions) within files or input.

a)

Searches for patterns within files or input.

b)

Creates new directories.

c)

Removes empty directories.

d)

Copies files and directories.

22.

What does the grep command do?

a)

Searches for patterns within files or input

b)

Sorts lines of text in a file

c)

Filters out adjacent duplicate lines

d)

Compares two files line by line

23.

What does the sort command do?

a)

Searches for patterns within files or input

b)

Sorts lines of text in a file

c)

Filters out adjacent duplicate lines

d)

Compares two files line by line

24.

What does the uniq command do?

a)

Searches for patterns within files or input

b)

Sorts lines of text in a file

c)

Filters out adjacent duplicate lines

d)

Compares two files line by line

25.

What does the diff command do?

a)

Searches for patterns within files or input

b)

Sorts lines of text in a file

c)

Filters out adjacent duplicate lines

d)

Compares two files line by line

26.

What does the echo command do?

a)

Prints text or variables to the terminal

b)

Changes the user and/or group ownership of a file

c)

Changes the permissions of a file or directory

d)

Sets the default permissions for newly created files

27.

What does the chown command do?

a)

Prints text or variables to the terminal

b)

Changes the user and/or group ownership of a file

c)

Changes the permissions of a file or directory

d)

Sets the default permissions for newly created files

28.

What does the chmod command do?

a)

Prints text or variables to the terminal

b)

Changes the user and/or group ownership of a file

c)

Changes the permissions of a file or directory

d)

Sets the default permissions for newly created files

29.

What does the umask command do?

a)

Prints text or variables to the terminal

b)

Changes the user and/or group ownership of a file

c)

Changes the permissions of a file or directory

d)

Sets the default permissions for newly created files

30.

What does the du command do?

a)

Estimates file and directory space usage

b)

Reports disk space usage for mounted filesystems

c)

Strips directory and trailing suffixes from a file path

d)

Strips the last component from a file path

31.

What does the df command do?

a)

Estimates file and directory space usage

b)

Reports disk space usage for mounted filesystems

c)

Strips directory and trailing suffixes from a file path

d)

Strips the last component from a file path

32.

What does the basename command do?

a)

Strips directory and trailing suffixes from a file path

b)

Strips the last component from a file path

c)

Provides a snapshot of currently running processes

d)

Provides a dynamic view of running processes

33.

What does the dirname command do?

a)

Strips directory and trailing suffixes from a file path

b)

Strips the last component from a file path

c)

Provides a snapshot of currently running processes

d)

Provides a dynamic view of running processes

34.

What does the ps command do?

a)

Provides a snapshot of currently running processes

b)

Provides a dynamic view of running processes

c)

Sends a signal to a process

d)

Kills processes by name

35.

What does the top command do?

a)

Provides a snapshot of currently running processes

b)

Provides a dynamic view of running processes

c)

Sends a signal to a process

d)

Kills processes by name

36.

What does the kill command do?

a)

Sends a signal to a process

b)

Kills processes by name

c)

Lists jobs that have been started in the current shell session

d)

Resumes a suspended job in the background

37.

What does the killall command do?

a)

Sends a signal to a process

b)

Kills processes by name

c)

Lists jobs that have been started in the current shell session

d)

Resumes a suspended job in the background

38.

What does the jobs command do?

a)

Lists jobs that have been started in the current shell session

b)

Resumes a suspended job in the background

c)

Brings a background or suspended job to the foreground

d)

Indicates how a command name would be interpreted by the shell

39.

What does the bg command do?

a)

Lists jobs that have been started in the current shell session

b)

Resumes a suspended job in the background

c)

Brings a background or suspended job to the foreground

d)

Indicates how a command name would be interpreted by the shell

40.

What does the fg command do?

a)

Lists jobs that have been started in the current shell session

b)

Resumes a suspended job in the background

c)

Brings a background or suspended job to the foreground

d)

Indicates how a command name would be interpreted by the shell

41.

What does the type command do?

a)

Indicates how a command name would be interpreted by the shell

b)

Lists jobs that have been started in the current shell session

c)

Resumes a suspended job in the background

d)

Brings a background or suspended job to the foreground

42.

The type command explains how the shell will interpret a given command. It reveals if the command is an alias, a shell built-in, a function, or an external executable file located on disk, which is useful for debugging and understanding shell behavior.

a)

True

b)

False

43.

Locates the executable file for a given command by searching the PATH environment variable.

a)

which

b)

whereis

c)

find

d)

locate

44.

Runs a command immune to hangups, allowing it to continue running after the user logs out.

a)

nohup

b)

bg

c)

fg

d)

disown

45.

Builds and executes command lines from standard input. It converts input into arguments for another command.

a)

xargs

b)

exec

c)

apply

d)

map

46.

A highly configurable and powerful modal text editor.

a)

vim

b)

nano

c)

emacs

d)

gedit

47.

A highly extensible and powerful text editor and application platform.

a)

emacs

b)

vim

c)

nano

d)

gedit

48.

A simple, user-friendly command-line text editor.

a)

nano

b)

vim

c)

emacs

d)

gedit

49.

Prints the effective username of the current user.

a)

whoami

b)

who

c)

id

d)

echo $USER

50.

Shows who is logged on to the system.

a)

who

b)

users

c)

w

d)

last

51.

Switches the current user to another user (Substitute User). Defaults to switching to the root user.

a)

su

b)

sudo

c)

login

d)

chown

52.

Executes a command as another user, typically the superuser (root). It uses the current user's password.

a)

sudo

b)

su

c)

runas

d)

exec

53.

Changes a user's password.

a)

passwd

b)

chpasswd

c)

usermod

d)

change

54.

Tests network connectivity to another host on a network (local or Internet).

a)

ping

b)

traceroute

c)

curl

d)

wget

55.

Shows the route (path) that packets take to reach a network host, listing all intermediate hops (routers).

a)

traceroute

b)

ping

c)

route

d)

netstat

56.

Clears the terminal screen.

a)

clear

b)

cls

c)

reset

d)

wipe

57.

Displays the command history list for the current shell session.

a)

history

b)

log

c)

record

d)

track

58.

Sets environment variables. These variables are passed to child processes of the shell.

a)

export

b)

set

c)

env

d)

define

59.

Edits, installs, deletes, or lists the user's cron jobs (scheduled tasks).

a)

crontab

b)

cron

c)

at

d)

schedule

60.

Prints system information (kernel name, version, hardware, etc.).

a)

uname

b)

info

c)

sysinfo

d)

version