WorksheetsLinux Commands and Scripting Quiz
Total questions: 44
Worksheet time: 23mins
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"?
Which of the following are valid partitioning types? (choose two)
PC
MBR
GPT
BIOS
Which of the following commands will check hard disk GPT partitions? (choose three)
gdisk
sgdisk
cgdisk
fdisk
Which option for the usermod command can be used to specify a user’s group ID (either primary or secondary)? (choose two)
-g
-G
-s
-S
Which two pager commands are used by the man command to control movement within the document? (choose two)
less
grep
more
page
To search the man page sections for the keyword example, which of the following command lines could you execute? (choose two)
man -f example
man -k example
whatis example
apropos example
Which of the following commands can be used to access the home directory of the user “bob” while logged in as root? (choose two)
cd /home/bob
cd ~bob
cd &&
~bob
Which option(s) can be used to prevent cp from overwriting an existing file? (choose two)
-n
-N
-z
-i
The touch command can be used to: (choose two)
Create new files
Change a file’s name
Update the time stamp of existing files
Change ownership of a file
Which of the following are glob characters? (choose three)
The asterisk “*”
The question mark “?”
The dash character “-“
The square brackets “[” and “]”
You type gzip myfile.tar. What happens? (choose two)
myfile.tar is removed
myfile.tar.gz holds a compressed version of myfile.tar
An error; you forgot to specify the file with –f
myfile.tar is unarchived into the current directory
An error; you forgot to pass the name of the output file
Given the command tar -cvif homedirs.tbz /home, which of the following are true? (choose two)
The /home directory will be restored with the contents of homedirs.tbz
Only files starting with /home will be extracted from the archive
The command will print out each filename as it is processed
Files that are present in the archive might overwrite files in /home
The output file will be compressed
Which of the following commands can be used to compress a file? (choose three)
bunzip2
bzip2
gzip
cat
zip
Which two commands do the same thing? (choose two)
tar –czf foo.tar.gz foo*
tar –c foo | gzip > foo.tar.gz*
tar –xzf foo.tar.gz
tar –x foo | gzip
tar –tzf foo.tar.gz
What does this shell script do? FOO=/tmp/foo if [ ! -d $FOO ] ; then mkdir $FOO fi
Creates /tmp/foo if it does not exist
Makes the /tmp/foo directory if a file by that name exists
Outputs a message to the screen
Creates /tmp/foo and raises an error if there is a problem
Nothing, since there is a problem with the conditions in the if statement
Which of the following are correct about for and while loops?(choose two)
for loops operate over a fixed list of items
while loops operate over a fix list of items
for loops have a test each cycle to determine if it should run again
while loops have a test each cycle to determine if it should run again
for loops require a variable over which to iterate
Given the following script: while [ ! -f /tmp/foo ] ; do echo -n "." process_data > /tmp/foo done Which of the following are true?(choose two)
The script will run until the file /tmp/foo is created
The process_data command is executed repeatedly until /tmp/foo exists
The script will terminate immediately if /tmp/foo exists before the script starts.
The echo -n "." command will run indefinitely.
A conditional that lets you make multiple comparisons with a pattern is called:
case
fanout
if
test
branch
Choose all of the following statements that are true in regard to virtual RAM: (choose three)
Virtual RAM is used when available physical RAM is low.
Virtual RAM is also called swap space
Virtual RAM is stored on a hard drive
Virtual RAM is stored in the CPU
Which of the following commands will display CPU information? (choose two)
arch
lscpu
cpuinfo
cat /proc/cpuinfo
lspic
The Linux kernel mounts the following pseudo-filesystems to provide access to information about hardware devices connected to the system: (choose two)
/info
/proc
/devices
/sys
Which of the following commands will allow you to view all processes on the system? (choose two)
/info
ps -ef
/devices
ps aux
A network packet contains …(choose two)
…the name of the router.
…the IP address of the source machine.
…a hard drive partition.
…the IP address of the destination machine.
Which of the following commands will display the routing table? (choose two)
netstat -r
dig
ifconfig
route
Which of the following chown commands will change the myFile user ownership to the user sam and the group ownership to administrators?(choose two)
chown sam administrators myFile
chown sam.administrators myFile
chown sam:administrators myFile
chown sam+administrators myFile
Which of the following long listings represents setgid set for /shared ?
drwxrwsrwx. 12 root group 4096 Oct 21 13:12 /shared
drwsrwxrwx. 12 root group 4096 Oct 21 13:12 /shared
drwxrwxrws. 12 root group 4096 Oct 21 13:12 /shared
drwSrwxrwx. 12 root group 4096 Oct 21 13:12 /shared
Which of the following directories are designed as locations where any user can create a temporary file? (choose two)
/lost+found
/sbin
/tmp
/home
/var/tmp
Conditional statements can be used to determine which of the following? (choose three)
File conditions
String conditions
Integer conditions
Numeric conditions
Errors from applications started via an icon in X Windows are sent which of the following files? (choose two)
~/.xsession-errors
/var/log/Xorg.0.log
/var/adm/x.0.log
/Zu/ben/ka-errors.0.login
Which of the commands will open a secure X11 graphical session on a remote host?
Regular users can modify their GECOS information using which of the following commands? (choose two)
set
finger
chfn
passwd
The root user can use which of the following commands for locking and unlocking a user’s account: (choose two)
moduser
passwd
usermod
password
To show all systemd timer units on a system use the following command:
systemctl list-timers PATTERN
systemctl list-timers
systemctl list-timers --all
systemctl list-timers --state=STATE
The /etc/ntp.conf file shows that NTP servers are being queried using iburst mode. This enables:
Sending a burst of three requests instead of one if the server is unreachable
Checking the closest server first
Speeding up of initial synchronization
Finding time even if the server is unreachable
Which of the following commands will set the system time to the same time as the hardware clock?
hwclock –s
hwclock –set –date “current system time”
hwclock –w
hwclock –r
To remove systemd-journald log data older than two (2) weeks use the following command:
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?
cupsd.conf
access_log
error_log
page_log
Which of the following statements are true about the routing table? (choose three)
Route tables can be shared between subnets.
Each virtual private cloud (VPC) is given a route table by default when the VPC is created.
Each subnet can have a maximum of five route tables associated with it.
Each subnet in a virtual private cloud (VPC) must be associated with a route table.
What does the ~/.ssh/id_rsa file contain?
RSA public signature of the user
RSA private key of the user
RSA private signature of the user
RSA public key of the user
Which of the following commands are used to setup SSH tunneling?
ssh -L
Which of the following commands will start a SSH session with X11 support?
ssh –L marks.gsource.com
ssh –X marks.gsource.com
ssh –l marks.gsource.com
ssh –x marks.gsource.com
Which command is used to generate a GnuPG key?
gpg --gen-key
gpg -gen-key
gpggen --key
gpg-gen --key
Environment variables can be viewed by running: (choose two)
export -e
vars
export -p
env
Which of the following is a valid way to add the /data directory to the existing PATH variable?
$PATH=$PATH:/data
PATH=$PATH:/data
$PATH=/data
PATH=/data
