Read LPI Linux Certification in a Nutshell Online
Authors: Adam Haeder; Stephen Addison Schneiter; Bruno Gomes Pessanha; James Stanger
Tags: #Reference:Computers
How does a process indicate to the controlling shell that it has
exited with an error condition? Select one.
It prints an error message to
stderr
.
It prints an error message to
stdout
.
It sets an exit code with a zero value.
It sets an exit code with a nonzero value.
It causes a segmentation fault.
Consider the following trivial script called
myscript
:
#!/bin/bash
echo "Hello"
echo $myvar
Also consider this command sequence and result:
#set myvar='World'
#./myscript
Hello
The script ran without error but didn’t
echoWorld
.
Why not? Select one.
The syntax of the
set
command is
incorrect.
The script executes in a new shell, andmyvar
wasn’t exported.
The#!/bin/bash
syntax is
incorrect.
The$myvar
syntax is
incorrect.
The script is sourced by the current shell, andmyvar
is available only to new
shells.
Consider the following line from
/etc/passwd
:
adamh:x:500:1000:Adam Haeder:/home/adamh:/bin/bash
What does the number 1000 mean?
User
adamh
has a UID of 1000.
The primary group that
adamh
belongs to
is group 1000.
User
adamh
was the 1000th user created
on this system
The password for
adamh
expires in 1000
days.
The secondary group that
adamh
belongs
to is group 1000.
c.
$PATH
a.
The!!
command history expansion executes the
previous command. Entering the Ctrl-P keystroke uses the Emacs
key-binding
bash
to move up one line in the
history; pressing Enter executes that command.
The
man
command displays manpages.
b
AND
c.
find
and
locate
do not search the contents of files.
/etc/passwd
is not a script.
a.
The variable must be set
and exported. The semicolon separates the two commands.
c.
UPDATE
a.01;02;03;04;05;06;07;08;09;10
. The
-w
option to
seq
instructs
it to pad with zeros.
a.
cp
should be aliased to the interactive mode with the
-i
option in
.bashrc
.
.bash_profile
normally doesn’t include
aliases.
e.
The script has an error
and will not produce the expected output. In afor
statement, the loop variable does not
have the dollar sign. Changing line 2 tofor
v1in a1 a2
will correct the error and produce
the output in answer b.
d.
The shadow password system
has been implemented, placing all passwords in
/etc/shadow
as denoted by thex
following the username.
d.
/etc/X11/xorg.conf
c.
~/.Xresources
d.
Graphical login support
for remote hosts on the network
d.
xfce
and e.
X11
.
c.
An assistive technology
that handles screen reading for a number of console
applications
c.
Theg
indicates that we’re operating on the
group privilege, and the+s
indicates that we should add the “set id” bit, which means that the
SGID property will be applied.
b.
/etc/syslog.conf
c.
Qmail
d.
/var/log/maillog
e.
With the top bit of the
last byte set in the subnet mask (.128), there are 7 bits left.
2
7
is 128, less the network address and
broadcast address, leaving 126 addresses for hosts.
d.
Routes to the interface
and the network are required to exchange information on the local LAN.
To access the Internet or other nonlocal networks, a default gateway
is also necessary.
c.
As defined in
/etc/services
, port 25 is the SMTP port, often
monitored by
postfix
.
a.
TCP. UDP is also a Layer 4
protocol, but it is connectionless.
b.
The
ifconfig
command is used to configure and display
interface information.
ipconfig
is a Windows
utility.
b.
The spool directory
directive looks like this:
sd=/var/spool/lpd/lp
c.
Answer a attempts to mount
the
/proc
filesystem. Answers b, d, and e have
incorrect syntax.
c.
Both Telnet and FTP are
connection-oriented and use TCP for reliable
connections
.
a
,
b
,
d
, AND
e.
c.
Although both ICMP and UDP
are connectionless, they are different
protocols
.
The DNS daemon is
named
. It is included in
a package called BIND.
b.
A print server translates
formats, such as PostScript to PCL.
d.
The presence of the
localhost
address 127.0.0.1 indicates that
named
is running. Since the system is a
workstation, it’s safe to assume that it is not serving DNS to a wider
community.
/etc/hosts
.
e.
lpc
is the line printer control program.
c.
traceroute
.
tracert
is a
Windows utility with the same function as
traceroute
.
The file is
/etc/profile.
b.
The
.forward
file is placed in the home directory
containing a single line with the target email address.
d.
Zero exit values usually
indicate success.
b.
Instead of using
set
, the command should have been:
#export myvar='World'
This gives themyvar
variable
to the new shell.
b.
The primary group that
adamh
belongs to is group 1000.
A shell presents an interactive Textual User
Interface, an operating environment, a facility for launching
programs, and a programming language.
Shells can generally be divided into those derived from the
Bourne shell,
sh
(including
bash
), and the
C-shells, such as
tcsh
.
Shells are distinct from the kernel and run as user
programs.
Shells can be customized by manipulating variables.
Shells use configuration files at startup.
Shells pass environment variables to child processes,
including other shells.
bash
is a descendant of
sh
.
Shell variables are known only to the local shell and are
not passed on to other processes.
Environment variables are passed on to other
processes.
A shell variable is made an environment variable when it is
exported
.
This sets a shell variable:
#PI=3.14
This turns it into an environment variable:
#export PI
This definition does both at the same time:
#export PI=3.14
Shell
aliases conveniently create new commands or modify
existing commands:
#alias more='less'
Functions are defined for and called in scripts. This line
creates a function named
lsps
:
#lsps () { ls -l; ps; }
bash
configuration files control the
shell’s behavior.
Table 13-1
contains a list of these files.
Scripts are executable text files containing
commands.
Scripts must have appropriate execution bits set in the file
mode.
Scripts may define the command interpreter using the syntax#!/bin/bash
on the first
line.
A script that starts using#!/bin/bash
operates in a new invocation
of the shell. This shell first executes standard system and user
startup scripts. It also inherits exported variables from the
parent shell.
Like binary programs, scripts can offer a return value after
execution.
Scripts use file tests to examine and check for specific
information on files.
Scripts can use
command substitution
to utilize
the result of an external
command
.
Scripts often send email to notify administrators of errors
or status.
Refer to
Chapter 13
for details
on
bash
commands.
Common MySQL datatypes are integer, float, boolean,
date, timestamp, datetime, char, varchar, blob, and text.
The SQL syntax for creating a table with one varchar column
and one auto-increment integer column (which is also the primary
key) is:
CREATE TABLE test (id INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, \
column1 varchar(255), PRIMARY KEY (id));
INSERT is used to insert data into a table, UPDATE is used to
modify a data value in an existing table row, and SELECT is used to
display values from a table.
ALTER TABLE is used to add/remove columns to a table, or
modify a datatype.
A LEFT JOIN is used when we want to display items from two or
more tables connected by a relationship, where each item present in
the left table will display in the results, even if there is not a
match with the other table being joined.
X.Org is the most popular X Windows implementation on
Linux, replacing XFree86.
Window managers handle the functions of creating and managing
windows and things such as minimization, maximization, and screen
placement.
Desktop environments are collections of common desktop
programs that work together to create a unified desktop experience.
These will include applications such as window managers, file
managers, launch bars, screensavers, and session managers. The two
most common desktop environments are Gnome and KDE.
The main configuration file for X.Org is
/etc/X11/xorg.conf
.
X Windows can be configured to either read fonts from a local
directory or access a font server, such as
xfs
,
running either on the local machine or on another machine on the
network.
Display managers are GUI programs that handle the user
login process. They are most often invoked when a Linux system
enters runlevel 5. Common display managers are
xdm
,
gdm
, and
kdm
. They can all be configured to support
remote graphical logins from other terminals through the XDMCP
protocol.
Many applications exist to assist with accessibility
in Linux, including Emacspeak, Orca, and BLINUX. In addition to
these separate applications, most desktop environments support
assistive technologies such as StickyKeys, MouseKeys, and
RepeatKeys. On-screen keyboards are also a commonly used assistive
technology.