2nd Half Flashcards
Error messages generated by commands are sent where by default?
STDERR
STDIN
STDOUT
Log files
STDERR
A successful command may, or may not print output to STDOUT. True or False?
True
False
True
Which of the following commands will direct error messages to the file, error.log?
ls /root > error.log
ls /root»_space; error.log
ls /root $> error.log
ls /root 2> error.log
ls /root 2> error.log
A pipe allows you to…
…send the output of a command to a file.
…type multiple commands at one prompt.
…send the same input to multiple commands.
…send the output of one command to another.
…send the output of one command to another.
Channel 2 is
STDIN
STDALL
STDOUT
STDERR
STDERR
Which of the following commands will append its output to output.file?
echo Testing > output.file
echo Testing»_space; output.file
echo Testing -> output.file
output.file < echo Testing
echo Testing»_space; output.file
Which command(s) can be used to sort the lines of list.file alphabetically and display it on the screen?(choose two)
cat list.file | sort
echo list.file > sort
cat list.file»_space; sort
sort < list.file
cat list.file | sort
sort < list.file
Which option of the head command will display only the first five lines of a file?
-l 5
No option needed; head displays only five lines by default.
-n 5
-n
-n 5
The grep command…
…will display all the lines that begin with the specified Regular Expression.
…will display all the lines in a file containing the specified Regular Expression.
…is not case sensitive.
…will display the line numbers in a file that contain a specified Regular Expression.
…will display all the lines in a file containing the specified Regular Expression.
The grep command can be used with glob characters.True or False?
True
False
True
Which of the following commands will display only lines that begin with start?
grep $start file.txt
grep ^start file.txt
grep \start file.txt
grep *start file.txt
grep ^start file.txt
Which of the following commands will display only lines that begin with test?
grep test file.txt
grep $test file.txt
grep &test file.txt
grep ^test file.txt
grep ^test file.txt
Which of the following commands will display lines that contain either start or end?
egrep start end file.txt
egrep ‘start|end’ file.txt
egrep start&end file.txt
egrep (start|end) file.txt
egrep ‘start|end’ file.txt
Which of the following commands can be used to scroll through a text file? (choose two)
some
more
less
cat
more
less
Which option for the cut command is used to specify a delimiter?
=
-D
-f
-d
-d
Which option for the cut command is used to specify the field?
-d
-D
-f
#
-f
Which option for the wc command will print the number of lines in a file?
-L
-w
-C
-l
-l
Which option for the wc command will print the total number of words in a file?
-l
-C
-w
-L
-w
Which command can be used to print line numbers?
nl
ln
num
sort
nl
The command echo “text” > file.txt will create file.txt if it does not already exist. True or False?
True
False
True
The command echo “text” > file.txt will not overwrite file.txt if it already exists. True or False?
True
False
False
The command echo “text”»_space; file.txt will not overwrite file.txt if it already exists. True or False?
True
False
True
A file begins with #!/bin/csh. This means:
Nothing, this is a comment
Running the script will invoke /bin/csh to interpret the rest of the file
The operator should not be using /bin/csh
This is a Perl script
C Shell compatibility mode is enabled
Running the script will invoke /bin/csh to interpret the rest of the file
Which are appropriate editors for writing shell scripts?(choose two)
Firefox
/bin/bash
LibreOffice Writer
vi
nano
vi
nano
Most of nano’s commands take the form of:
Control and another character
Alt and another character
Mouse clicks
Escape followed by another character
The F1 through F12 function keys
Control and another character
What does this shell script do?
FOO= /tmp/ foo
if [ ! -d $FOO ] ; then
mkd ir $FOO
f i
Creates /tmp/foo if it does not exist
Makes the /tmp/foo directory if a file by that name exists
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
Outputs a message to the screen
Creates /tmp/foo if it does not exist
Which of the following are correct about for and while loops?(choose two)
while loops have a test each cycle to determine if it should run again
for loops have a test each cycle to determine if it should run again
while loops operate over a fixed list of items
for loops require a variable over which to iterate
for loops operate over a fixed list of items
while loops have a test each cycle to determine if it should run again
for loops operate over a fixed list of items
Given the following part of a script:
if [ - f $1 ]; then
echo “I am here”
fi
What is the meaning of $1?
It is a list of files that gets interpolated
It is a file called $1
It is a special variable that indicates the exit code of the command before it
It is a parameter to -f, indicating the size of the file
It is the first argument passed to the script
It is the first argument passed to the script
Given the following script that is run through ./test.sh hello goodbye:
if [ -f $2 ]; then
echo “I am here”
fi
When will “I am here” be printed?
The script will always print “I am here”
If a file called “goodbye” exists in the current directory
Never
If there are two files in the current directory
If a file called “hello” exists in the current directory
If a file called “goodbye” exists in the current directory
What is the correct way to assign the word “Hello” to a variable?
A = “Hello”
echo “Hello” > A
echo $A “Hello”
$A=”Hello”
A=”Hello”
A=”Hello”
What is the correct way to save the current directory to a variable?
A=cwd
pwd $A
pwd | $A
A=pwd
A=`pwd`
A=`pwd`
Which shell command accepts input from the user’s keyboard?
$1
echo
read
gets
input
read
What information is held inside $? ?
The name of the command run
The previous command’s exit code
The current process ID
The current user ID
The number of arguments passed to the script
The previous command’s exit code
How would you finish your script with an exit code of 42?
return 42
break 42
CODE=42
$?=42
exit 42
exit 42
The if command looks for what exit code to consider a condition to be true?
1
2
0
255
10
0
The number of users logged in is in a variable called USERS. How would you test to see if there are 5 users logged in?
test $USERS –a 5
test $USERS,5
test $USERS = 5
test $USERS –eq 5
test –f USERS=5
test $USERS –eq 5
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 screen will fill with dots.
process_data will be called at most once
If a file called /tmp/foo exists, process_data won’t be run
/tmp/foo will be removed if it exists
process_data will never be run
process_data will be called at most once
If a file called /tmp/foo exists, process_data won’t be run
A conditional that lets you make multiple comparisons with a pattern is called:
if
test
fanout
case
branch
case
What is the meaning of $(( $i + 1)) ?
This will return the value of the next argument to the script
This runs the command stored in variable i
Ifi is 0, the loop will stop
This will return the value of the first argument to the script
1 will be added to the i variable
1 will be added to the i variable
How would you write a test that says “if /tmp/foo is a directory or USERS is greater than 5″?
test –d /tmp/foo –o $USERS –gt 5
test /tmp/foo || $USERS > 5
test –d /tmp/foo | $USERS > 5
test /tmp/foo –d –o $USERS -gt 5
test –d /tmp/foo –o $USERS –gt 5
Which of the following are valid CPU types for Intel-based platforms?(choose two)
48-bit
24-bit
64-bit
32-bit
64-bit
32-bit
64 bit platforms can access more memory than 32 bit platforms. True or False?
True
False
True
Choose all of the following statements that are true in regard to virtual RAM: (choose three)
Virtual RAM is also called swap space
Virtual RAM is stored in the CPU
Virtual RAM is stored on a hard drive
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 used when available physical RAM is low.
Which of the following are common busing systems? (choose two)
CPU
PCI
RAM
BIOS
USB
PCI
USB
A division of a hard drive may be referred to as a _______ .
portion
block
partition
label
partition
Which of the following are valid partitioning types?(choose two)
MBR
PC
GPT
BIOS
MBR
GPT
The fdisk command is a tool used for working with the MBR partitioned disks. True or False?
True
False
True
Which of the following is the valid device file name for the first IDE hard drive on the system?
/dev/hda
/dev/hd1
/dev/ide
/dev/sda
/dev/hda
Which of the following are valid video cable connector types?(choose two)
AMD
HDA
VGA
DVI
VGA
DVI
Which of the following commands will display CPU information?(choose two)
showcpu
cpuinfo
arch
lspic
lscpu
arch
lscpu
What are the advantages of solid state disks when compared to traditional spinning platter hard disks?(choose three)
Low power consumption
Low cost
Faster system boot times
Higher capacity
Less heat
Low power consumption
Faster system boot times
Less heat
Software that allows hardware devices to communicate with the installed operating system is called?
Drivers
Programs
Instructions
Packages
Drivers
Which of the following commands will check hard disk MBR partitions?(choose three)
gfdisk
fdisk
sfdisk
gdisk
cfdisk
fdisk
sfdisk
cfdisk
Which of the following commands will check hard disk GPT partitions?(choose three)
sfdisk
sgdisk
gfdisk
gdisk
cgdisk
sgdisk
gdisk
cgdisk
When you execute the dmesg command, the system displays messages that are generated by the kernel. True or False?
True
False
True
The Linux kernel mounts the following pseudo-filesystems to provide access to information about hardware devices connected to the system: (choose two)
/devices
/sys
/proc
/info
/sys
/proc
The /proc directory contains a subdirectory for each process present on the system. True or False?
True
False
True
The Process ID (PID) of the init process is:
1
0
varies
100
1
The process (ps) command shows only processes running in the current shell by default. True or False?
True
False
True
The following system load averages are displayed by the top command: (choose three)
1 minute
15 minute
10 minute
5 minute
1 minute
15 minute
5 minute
The free command outputs statistics about:
Memory usage
Disk usage
Software usage
CPU usage
Memory usage
What directory typically contains log files?
/proc/loc
/log
/usr/log
/var/log
/var/log
Which log file contains messages regarding authentication and authorization?
syslog
messages
secure
dmesg
secure
All log files contain only text data. True or False?
True
False
False
A command that will continuously update statistics about running processes:
head
top
tail
bottom
top
Which of the following is a valid Linux option style for Traditional Unix:
no dash
two dashes (–)
a single dash (-)
slash (/)
a single dash (-)
Which file contains the information passed to the kernel at boot time?
/proc/kernel
/proc/cmdline
/proc/kargs
/proc/kopts
/proc/cmdline
To make changes permanent for kernel parameter files found under /proc/sys, the following file can have entries added to it:
/etc/sysinfo.conf
/etc/procctl.conf
/etc/procsys.conf
/etc/sysctl.conf
/etc/sysctl.conf
The /var directory has files that change over time. True or False?
True
False
True
Information about the init process can be found in the /proc/1 directory. True or False?
True
False
True
Which of the following commands will allow you to view all processes on the system?(choose two)
ps -eLf
ps aux
ps -ef
ps -A
ps
ps aux
ps -ef
The logging daemon on recent Linux distributions based on systemd is called:
klogd
syslogd
rsyslogd
journald
journald