Read LPI Linux Certification in a Nutshell Online
Authors: Adam Haeder; Stephen Addison Schneiter; Bruno Gomes Pessanha; James Stanger
Tags: #Reference:Computers
What command can be used to kill processes by name, rather than
process ID?
killproc
killname
killall
kill –name
killpath
Which command line would start the program
/usr/bin/top
with the highest priority
possible?
nice --20 /usr/bin/top
nice 20 /usr/bin/top
nice 19 /usr/bin/top
nice -20 /usr/bin/top
None of the above
Which command is used to modify the priority of a process
already running?
nice
renice
priority
chage
ps
Which command(s) would display every line in
/tmp/file.txt
that begins with the letter
h
and ends with the letter
t
?
grep "^h.+t$" /tmp/file.txt
grep –E "^h.+t$" /tmp/file.txt
grep –E "$h.+t^" /tmp/file.txt
grep –E "$ht^" /tmp/file.txt
grep –E "^h.*t$" /tmp/file.txt
Which command(s) would display every line in
/tmp/file.txt
that contains at least one
letter of the alphabet?
grep " [a-zA-Z] " /tmp/file.txt
grep " [:alpha:] " /tmp/file.txt
grep " [:letters:] "
/tmp/file.txt
grep " (a-zA-Z) " /tmp/file.txt
None of the above
In the
vi
editor, what command sequence
given in command mode will make a copy of the current line?
yyp
cp
yp
ccp
None of the above
In the
vi
editor, what command sequence
given in command mode will save the current file and quit the
editor?
:qw
:wq
:WQ
:pq
None of the above
In the
vi
editor, what command sequence
given in command mode will quit a file without saving, even if changes
have been made?
:q
:q1
:q!
:w
:w!
Which of the following are examples of journaling
filesystems?
ext2
ext3
xfs
reiserfs
vfat
What command will create an ext3 partition on the first
partition of the first SCSI hard drive?
mkfs –t ext3 /dev/sda1
fdisk –t ext3 /dev/sda1
fsck –t ext3 /dev/sda1
mkfs –s ext3 /dev/hda1
mkfs –t ext3 /dev/hda1
What command is used to convert an existing ext2 partition
(
/dev/sda1
) to an ext3 (journaled)
partition?
tune2fs –j /dev/sda1
dumpe2fs –j /dev/sda1
fsck –j /dev/sda1
mkfs.ext2 –j /dev/sda1
None of the above
What command is used to display the number of free inodes on an
ext2 or ext3 partition?
tune2fs
dumpe2fs
showe2fs
fsck
fdisk
Which file defines what partitions are mounted at boot
time?
/etc/partitions
/etc/mount
/etc/mtab
/etc/fstab
/etc/filesystems
Which command will mount all partitions of type nfs defined in
/etc/fstab
?
mount –a –t nfs
mount –a nfs –t
mount –nfs
mountall –nfs
None of the above
If you would like to give a normal (nonroot) user the ability to
mount a device, what option should you define for that device in
/etc/fstab
?
mountable
noroot
user
ok
mount
Which option to
chmod
would assign
read/write permission to the file owner, read-only permission to the
group owner, and read-only permission to everyone else?
chmod 644 file.txt
chmod 755 file.txt
chmod 466 file.txt
chmod 777 file.txt
None of the above
Which option to
umask
would set my default
file permissions such that files are created with these permissions:
user has read/write, group has read/write, and everyone else has read
only?
umask 002
umask 022
umask 200
umask 220
umask 775
Which command can be used to quickly tell you if an executable
command is in any directory defined in your$PATH
environment variable?
find
locate
which
who
what
Which directory, according to the Filesystem Hierarchy Standard,
is designed to hold essential system binaries?
/sbin
/bin
/usr/bin
/opt/bin
/usr/local/bin
According to the Filesystem Hierarchy Standard, what directory
(or directories) must hold the system kernel?
/boot
/
/opt
/sbin
/kernel
What command is used to maintain the filesystem index that the
command
/usr/bin/locate
searches?
update
updatelocate
locate –update
updatedb
update -db
c.
IDE Hard Drive
b.
/proc/interrupts
b.
1
AND
d.
single
.
Both answers are correct.
d.
init
b.
/var/log/messages
. This is the default logfile
that syslogd saves to.
d.
The BIOS
a.
/sbin/shutdown
–r –F now
. This may seem like a small detail to have to
remember, but this is an important command, and you should have its
options memorized, particularly the difference between
–F
(force
fsck
on reboot)
and
–f
(skip
fsck
on reboot).
c.
init
3
AND
d.
telinit
3
. Both answers are
correct.
a.
A symlink beginning with
S
in
/etc/rc.d/rc5.d/
AND
b.
/etc/rc.d/rc.local
. Both answers are correct.
Note that most distributions have an
/etc/rc.d/rc.local
file that runs after the
default runlevel scripts are run.
b.
df
c.
/tmp
.
If the question was just about a partition where data changed often,
that would be both
/tmp
and
/var
. But
/tmp
is the only
partition that needs to be writable by all users.
c.
Master Boot Record
a.
root
(hd0,0)
. GRUB (the Grand Unified Boot Loader) starts
counting drives and partitions at 0, so the first partition on the
first drive is 0,0.
d.
/etc/ld.so.conf
. When modifications are made to
this file, the command
/sbin/ldconfig
must be
run.
c.
apt-get
update
a.
dpkg –i package.deb
a.
rpm
–qa
a.
yum
update
a.
rpm –verify
–all
AND
b.
rpm –Va
. Both of these commands are
equivalent.
b.
echo
$PATH
d.
All of the above. Remember
that the ~ key indicates a user’s home directory.
d.
All of the above. The
history
command will list the last commands run
(how many commands are listed is configurable),
allow you to search the history by keyword, and
cycles through the last command typed in the order in which they were
typed.
a.
/opt/runme
AND
b.
./runme
b.
/bin/ls 1>
/dev/null
AND
c.
/bin/ls > /dev/null
. The syntax
>
and
1>
are
equivalent. If you don’t redirect
STDERR
, it will
display to the screen by default.
c.
head -5
/etc/passwd
AND
d.
cat /etc/passwd | head -5
a.
sed
AND
b.
tr
b.
tar
AND
c.
dd
. The
tar
command is often used to talk directly to
tape devices (
tar –xvf /dev/st0
), and
dd
can be used to make copies of devices. For
example, to create a raw image of a 1.44 MB floppy disk, use
dd if=/dev/fd0 of=/tmp/floppy.img
c.
ls *.txt
. Remember that the syntax for file
globbing is different from the syntax for regular expressions. In
particular, the behavior of the asterisk (*) is vastly different
between the two.
e.
ls
[abc]*
. Another file globbing example.
d.
All of the above. Since
file extensions are not really necessary in the Linux world, there
isn’t one single standard that covers them all. However,
tar.bz2
,
tbz2
, and
.tbz
are all examples of file
extensions you might see to indicate that a file is tarred and
bzipped.
d.
/dev/null
. Also referred to as the “bit
bucket.”
a.
ls
–l /tmp | tee /root/tmp.txt | more
. It’s
important to remember the order of commands when you are piping
multiple commands together, especially when the
tee
command is involved.
c.
&
c.
nohup
. The
nohup
command is
usually paired with
&
to put a process in the
background and detach it from the current terminal. For example,
nohup /opt/long_process.sh &
would start the
command
/opt/long_process.sh
and allow me to log
out while the process remains running.
d.
top
.
There are many ways to view processes on a machine, but the
top
command is probably one of the most useful
commands, giving you sort ability and process interaction
capability.
d.
kill
-9
. Note that this might not kill a process that is waiting
on disk I/O or some other kind of blocking, noninterruptible
process.
c.
killall
a.
nice --20
/usr/bin/top
. This is a tricky one. First, you have to
remember that priority values range from -20 (highest priority) to 19
(lowest priority). So if I want to pass the highest priority to a
process, I have to pass
-20
. However, options to
commands start with the
-
(dash) character, so I
need to make sure I type 2 dashes, the first to indicate that the next
argument is an option, and the second to indicate that I’m passing a
negative number to the
nice
command.
b.
renice
e.
grep –E "^h.*t$" /tmp/file.txt
. This
command literally means, “Search for the extended regular expression
that matches
h
as the first character, followed
by zero or more of any other character, and having
t
as the last character.” The
–E
option is required because the
presence of the
.*
makes this an extended regular
expression. The answer in
a.
is
close, but the syntax
.+
means “match 1 or more
characters of any kind.” The regular expression in
a.
would not match the line “ht”, whereas the
regular expression in
e.
would.
a.
grep " [a-zA-Z] " /tmp/file.txt
AND
b.
grep "
[:alpha:] " /tmp/file.txt
. Become familiar with the sets
that are defined with the syntax
[:setname:]
;
they are very useful in advanced regular expressions. You can see a
complete list of them in the manpage for
grep
.
a.yyp
. An easy way to remember this:
Yank-Yank-Put.
b.:wq
. The colon brings up the command entry
line at the bottom of the
vi
screen,w
stands for write, andq
stands for quit.
c.:q!
. The
vi
editor has
many, many commands, but if you become familiar with a few dozen,
you’ll be able to accomplish 99 percent of what you will commonly need
to accomplish in
vi
.
b.
ext3 AND
c.
xfs AND
d.
reiserfs. Ext3 is ext2 with journaling
support added. Vfat is a Microsoft filesystem.
a.
mkfs –t ext3
/dev/sda1
. The command
mkfs.ext3
is
equivalent to
mkfs –t ext3
.
a.
tune2fs –j
/dev/sda1
. Technically, the command listed in
d.
(
mkfs.ext2 –j
/dev/sda1
) will create an ext3 partition on
/dev/sda1
, but it will destroy whatever partition
is there in the process.
b.
dumpe2fs
d.
/etc/fstab
a.
mount –a –t
nfs
c.
user
a.
chmod 644 file.txt
b.
umask
022
c.
which
a.
/sbin
a.
/boot
AND
b.
/
. Both
directories are correct. Most Linux distributions will store the
kernel in
/boot
; the presence of a kernel in
/
is deprecated.
d.
updatedb