LPI Linux Certification in a Nutshell (73 page)

Read LPI Linux Certification in a Nutshell Online

Authors: Adam Haeder; Stephen Addison Schneiter; Bruno Gomes Pessanha; James Stanger

Tags: #Reference:Computers

BOOK: LPI Linux Certification in a Nutshell
4.92Mb size Format: txt, pdf, ePub
  1. How does a process indicate to the controlling shell that it has
    exited with an error condition? Select one.

    1. It prints an error message to
      stderr
      .

    2. It prints an error message to
      stdout
      .

    3. It sets an exit code with a zero value.

    4. It sets an exit code with a nonzero value.

    5. It causes a segmentation fault.

  2. 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
    echo
    World
    .
    Why not? Select one.

    1. The syntax of the
      set
      command is
      incorrect.

    2. The script executes in a new shell, and
      myvar
      wasn’t exported.

    3. The
      #!/bin/bash
      syntax is
      incorrect.

    4. The
      $myvar
      syntax is
      incorrect.

    5. The script is sourced by the current shell, and
      myvar
      is available only to new
      shells.

  3. Consider the following line from
    /etc/passwd
    :

    adamh:x:500:1000:Adam Haeder:/home/adamh:/bin/bash

    What does the number 1000 mean?

    1. User
      adamh
      has a UID of 1000.

    2. The primary group that
      adamh
      belongs to
      is group 1000.

    3. User
      adamh
      was the 1000th user created
      on this system

    4. The password for
      adamh
      expires in 1000
      days.

    5. The secondary group that
      adamh
      belongs
      to is group 1000.

Answers
  1. c.
    $PATH

  2. 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.

  3. The
    man
    command displays manpages.

  4. b
    AND
    c.
    find
    and
    locate
    do not search the contents of files.
    /etc/passwd
    is not a script.

  5. a.
    The variable must be set
    and exported. The semicolon separates the two commands.

  6. c.
    UPDATE

  7. a.
    01;02;03;04;05;06;07;08;09;10
    . The
    -w
    option to
    seq
    instructs
    it to pad with zeros.

  8. a.
    cp
    should be aliased to the interactive mode with the
    -i
    option in
    .bashrc
    .
    .bash_profile
    normally doesn’t include
    aliases.

  9. e.
    The script has an error
    and will not produce the expected output. In a
    for
    statement, the loop variable does not
    have the dollar sign. Changing line 2 to
    for
    v1
    in a1 a2
    will correct the error and produce
    the output in answer b.

  10. d.
    The shadow password system
    has been implemented, placing all passwords in
    /etc/shadow
    as denoted by the
    x
    following the username.

  11. d.
    /etc/X11/xorg.conf

  12. c.
    ~/.Xresources

  13. d.
    Graphical login support
    for remote hosts on the network

  14. d.
    xfce
    and e.
    X11
    .

  15. c.
    An assistive technology
    that handles screen reading for a number of console
    applications

  16. c.
    The
    g
    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.

  17. b.
    /etc/syslog.conf

  18. c.
    Qmail

  19. d.
    /var/log/maillog

  20. 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.

  21. 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.

  22. c.
    As defined in
    /etc/services
    , port 25 is the SMTP port, often
    monitored by
    postfix
    .

  23. a.
    TCP. UDP is also a Layer 4
    protocol, but it is connectionless.

  24. b.
    The
    ifconfig
    command is used to configure and display
    interface information.
    ipconfig
    is a Windows
    utility.

  25. b.
    The spool directory
    directive looks like this:

    sd=/var/spool/lpd/lp
  26. c.
    Answer a attempts to mount
    the
    /proc
    filesystem. Answers b, d, and e have
    incorrect syntax.

  27. c.
    Both Telnet and FTP are
    connection-oriented and use TCP for reliable
    connections
    .

  28. a
    ,
    b
    ,
    d
    , AND
    e.

  29. c.
    Although both ICMP and UDP
    are connectionless, they are different
    protocols
    .

  30. The DNS daemon is
    named
    . It is included in
    a package called BIND.

  31. b.
    A print server translates
    formats, such as PostScript to PCL.

  32. 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.

  33. /etc/hosts
    .

  34. e.
    lpc
    is the line printer control program.

  35. c.
    traceroute
    .
    tracert
    is a
    Windows utility with the same function as
    traceroute
    .

  36. The file is
    /etc/profile.

  37. b.
    The
    .forward
    file is placed in the home directory
    containing a single line with the target email address.

  38. d.
    Zero exit values usually
    indicate success.

  39. b.
    Instead of using
    set
    , the command should have been:

    #
    export myvar='World'

    This gives the
    myvar
    variable
    to the new shell.

  40. b.
    The primary group that
    adamh
    belongs to is group 1000.

Chapter 27. Exam 102 Highlighter’s Index
Shells, Scripting, and Data Management
Objective 105.1: Customize and Use the Shell Environment
  • 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
  • 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.

Objective 105.2: Customize or Write Simple Scripts
  • 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.

Environment
  • 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.

Objective 105.3: SQL Data Management
  • 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.

The X Window System
Objective 106.1: Install and Configure X11
  • 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.

Objective 106.2: Set Up a Display Manager
  • 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.

Objective 106.3: Accessibility
  • 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.

Other books

House of Storms by Violet Winspear
The Kommandant's Girl by Pam Jenoff
Everyday Pasta by Giada De Laurentiis
Tengu by John Donohue
The Cathedral of Cliffdale by Melissa Delport
The Sometime Bride by Ginny Baird
Summerfall by Claire Legrand
Storm at Marshbay by Clara Wimberly