Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Linux Commands and Scripting Quiz

Total questions: 44

Worksheet time: 23mins

Name
Class
Date
1.

You've just finished working on a script that organizes files in a directory, and you want to share it with a colleague. However, you realize that they may not have permission to execute it. What command do you use to give everyone execute permissions to your script named "organize.sh"?

a)
chmod 777 organize.sh
b)
chmod u+x organize.sh
c)
chmod a+x organize.sh
d)
chmod +x organize.sh
2.

Which of the following are valid partitioning types? (choose two)

a)

PC

b)

MBR

c)

GPT

d)

BIOS

3.

Which of the following commands will check hard disk GPT partitions? (choose three)

a)

gdisk

b)

sgdisk

c)

cgdisk

d)

fdisk

4.

Which option for the usermod command can be used to specify a user’s group ID (either primary or secondary)? (choose two)

a)

-g

b)

-G

c)

-s

d)

-S

5.

Which two pager commands are used by the man command to control movement within the document? (choose two)

a)

less

b)

grep

c)

more

d)

page

6.

To search the man page sections for the keyword example, which of the following command lines could you execute? (choose two)

a)

man -f example

b)

man -k example

c)

whatis example

d)

apropos example

7.

Which of the following commands can be used to access the home directory of the user “bob” while logged in as root? (choose two)

a)

cd /home/bob

b)

cd ~bob

c)

cd &&

d)

~bob

8.

Which option(s) can be used to prevent cp from overwriting an existing file? (choose two)

a)

-n

b)

-N

c)

-z

d)

-i

9.

The touch command can be used to: (choose two)

a)

Create new files

b)

Change a file’s name

c)

Update the time stamp of existing files

d)

Change ownership of a file

10.

Which of the following are glob characters? (choose three)

a)

The asterisk “*”

b)

The question mark “?”

c)

The dash character “-“

d)

The square brackets “[” and “]”

11.

You type gzip myfile.tar. What happens? (choose two)

a)

myfile.tar is removed

b)

myfile.tar.gz holds a compressed version of myfile.tar

c)

An error; you forgot to specify the file with –f

d)

myfile.tar is unarchived into the current directory

e)

An error; you forgot to pass the name of the output file

12.

Given the command tar -cvif homedirs.tbz /home, which of the following are true? (choose two)

a)

The /home directory will be restored with the contents of homedirs.tbz

b)

Only files starting with /home will be extracted from the archive

c)

The command will print out each filename as it is processed

d)

Files that are present in the archive might overwrite files in /home

e)

The output file will be compressed

13.

Which of the following commands can be used to compress a file? (choose three)

a)

bunzip2

b)

bzip2

c)

gzip

d)

cat

e)

zip

14.

Which two commands do the same thing? (choose two)

a)

tar –czf foo.tar.gz foo*

b)

tar –c foo | gzip > foo.tar.gz*

c)

tar –xzf foo.tar.gz

d)

tar –x foo | gzip

e)

tar –tzf foo.tar.gz

15.

What does this shell script do? FOO=/tmp/foo if [ ! -d $FOO ] ; then mkdir $FOO fi

a)

Creates /tmp/foo if it does not exist

b)

Makes the /tmp/foo directory if a file by that name exists

c)

Outputs a message to the screen

d)

Creates /tmp/foo and raises an error if there is a problem

e)

Nothing, since there is a problem with the conditions in the if statement

16.

Which of the following are correct about for and while loops?(choose two)

a)

for loops operate over a fixed list of items

b)

while loops operate over a fix list of items

c)

for loops have a test each cycle to determine if it should run again

d)

while loops have a test each cycle to determine if it should run again

e)

for loops require a variable over which to iterate

17.

Given the following script: while [ ! -f /tmp/foo ] ; do echo -n "." process_data > /tmp/foo done Which of the following are true?(choose two)

a)

The script will run until the file /tmp/foo is created

b)

The process_data command is executed repeatedly until /tmp/foo exists

c)

The script will terminate immediately if /tmp/foo exists before the script starts.

d)

The echo -n "." command will run indefinitely.

18.

A conditional that lets you make multiple comparisons with a pattern is called:

a)

case

b)

fanout

c)

if

d)

test

e)

branch

19.

Choose all of the following statements that are true in regard to virtual RAM: (choose three)

a)

Virtual RAM is used when available physical RAM is low.

b)

Virtual RAM is also called swap space

c)

Virtual RAM is stored on a hard drive

d)

Virtual RAM is stored in the CPU

20.

Which of the following commands will display CPU information? (choose two)

a)

arch

b)

lscpu

c)

cpuinfo

d)

cat /proc/cpuinfo

e)

lspic

21.

The Linux kernel mounts the following pseudo-filesystems to provide access to information about hardware devices connected to the system: (choose two)

a)

/info

b)

/proc

c)

/devices

d)

/sys

22.

Which of the following commands will allow you to view all processes on the system? (choose two)

a)

/info

b)

ps -ef

c)

/devices

d)

ps aux

23.

A network packet contains …(choose two)

a)

…the name of the router.

b)

…the IP address of the source machine.

c)

…a hard drive partition.

d)

…the IP address of the destination machine.

24.

Which of the following commands will display the routing table? (choose two)

a)

netstat -r

b)

dig

c)

ifconfig

d)

route

25.

Which of the following chown commands will change the myFile user ownership to the user sam and the group ownership to administrators?(choose two)

a)

chown sam administrators myFile

b)

chown sam.administrators myFile

c)

chown sam:administrators myFile

d)

chown sam+administrators myFile

26.

Which of the following long listings represents setgid set for /shared ?

a)

drwxrwsrwx. 12 root group 4096 Oct 21 13:12 /shared

b)

drwsrwxrwx. 12 root group 4096 Oct 21 13:12 /shared

c)

drwxrwxrws. 12 root group 4096 Oct 21 13:12 /shared

d)

drwSrwxrwx. 12 root group 4096 Oct 21 13:12 /shared

27.

Which of the following directories are designed as locations where any user can create a temporary file? (choose two)

a)

/lost+found

b)

/sbin

c)

/tmp

d)

/home

e)

/var/tmp

28.

Conditional statements can be used to determine which of the following? (choose three)

a)

File conditions

b)

String conditions

c)

Integer conditions

d)

Numeric conditions

29.

Errors from applications started via an icon in X Windows are sent which of the following files? (choose two)

a)

~/.xsession-errors

b)

/var/log/Xorg.0.log

c)

/var/adm/x.0.log

d)

/Zu/ben/ka-errors.0.login

30.

Which of the commands will open a secure X11 graphical session on a remote host?

a)
ssh -X user@remote_host
b)
ssh user@remote_host
c)
xterm -display remote_host:0
d)
telnet remote_host
31.

Regular users can modify their GECOS information using which of the following commands? (choose two)

a)

set

b)

finger

c)

chfn

d)

passwd

32.

The root user can use which of the following commands for locking and unlocking a user’s account: (choose two)

a)

moduser

b)

passwd

c)

usermod

d)

password

33.

To show all systemd timer units on a system use the following command:

a)

systemctl list-timers PATTERN

b)

systemctl list-timers

c)

systemctl list-timers --all

d)

systemctl list-timers --state=STATE

34.

The /etc/ntp.conf file shows that NTP servers are being queried using iburst mode. This enables:

a)

Sending a burst of three requests instead of one if the server is unreachable

b)

Checking the closest server first

c)

Speeding up of initial synchronization

d)

Finding time even if the server is unreachable

35.

Which of the following commands will set the system time to the same time as the hardware clock?

a)

hwclock –s

b)

hwclock –set –date “current system time”

c)

hwclock –w

d)

hwclock –r

36.

To remove systemd-journald log data older than two (2) weeks use the following command:

a)
journalctl --vacuum-time=2weeks
b)
journalctl --clear-logs
c)
journalctl --delete-logs
d)
journalctl --remove-old-entries
37.

A system administrator needs to find out the number of copies of a confidential document printed by a particular user. Which of the following log files should he view for the information?

a)

cupsd.conf

b)

access_log

c)

error_log

d)

page_log

38.

Which of the following statements are true about the routing table? (choose three)

a)

Route tables can be shared between subnets.

b)

Each virtual private cloud (VPC) is given a route table by default when the VPC is created.

c)

Each subnet can have a maximum of five route tables associated with it.

d)

Each subnet in a virtual private cloud (VPC) must be associated with a route table.

39.

What does the ~/.ssh/id_rsa file contain?

a)

RSA public signature of the user

b)

RSA private key of the user

c)

RSA private signature of the user

d)

RSA public key of the user

40.

Which of the following commands are used to setup SSH tunneling?

a)
ssh -D
b)

ssh -L

c)
ssh -X
d)
ssh -C
41.

Which of the following commands will start a SSH session with X11 support?

a)

ssh –L marks.gsource.com

b)

ssh –X marks.gsource.com

c)

ssh –l marks.gsource.com

d)

ssh –x marks.gsource.com

42.

Which command is used to generate a GnuPG key?

a)

gpg --gen-key

b)

gpg -gen-key

c)

gpggen --key

d)

gpg-gen --key

43.

Environment variables can be viewed by running: (choose two)

a)

export -e

b)

vars

c)

export -p

d)

env

44.

Which of the following is a valid way to add the /data directory to the existing PATH variable?

a)

$PATH=$PATH:/data

b)

PATH=$PATH:/data

c)

$PATH=/data

d)

PATH=/data