A Linux User Reference

Search tips
  • search ignores words that are less than 4 characters in length
  • searches are case insensitve
  • if a search does not return anything try it in Boolean mode then Query expansion mode by checking the appropriate radio button e.g. searching for 'cron' in just the Administration category returns nothing - presumably because the 50% threshold is reached. Boolean mode ignores this threshold so a search for 'cron' returns several hits
  • in Boolean mode preceding a word with a '+' means the result must include that word, a '-' means it must not
  • in Boolean mode '+crontab -anacron' means match articles about crontab that DO NOT mention anacron
  • to match a phrase e.g. 'manage system' check the Boolean mode radio button and enclose the phrase in quotes "some phrase ..."
  • in Query expansion mode the search context is expanded beyond the keywords you entered - relevancy of hits may well be degraded


Dbus and HAL

  • Dbus and HAL
    basic introduction

    Inter-process communications - Dbus

    • A channel for inter-process communication and Remote Procedure Calls.
    • It provides for low-level communications between system processes and hardware as well as userspace application-to-application communications.
    • A central server (called the bus) must be running before any communication can take place, it also manages the communications.
    • Applications can query the bus to determine what is running and can have a service started on demand.

    HAL is obsolete - 2013 - replaced, superceded by udev

    Hardware Abstraction Layer - HAL

    • As of 2009 HAL has been replaced by 'DeviceKit'
    • A Hardware Abstraction Layer that is implemented in software and sits between the hardware and the software.
    • Its job is to hide differences in hardware from the kernel code. So, within reason, kernel code does not need to be changed to run on systems that have different hardware installed.
    • HALs are written in a low level language. They allow code written in higher level languages, such as the kernel, to communicate directly with hardware.
    • Hal uses dbus/D_BUS.
    `-- fdi 
        |-- information 
        |-- policy 
        |   `-- preferences.fdi 
        `-- preprobe 
    Device info package - hal-info (obsolete)

    A package containing .fdi (device information files) for HAL.

    Application - hal-device-manager (obsolete)

    GUI that provides a user interface which shows the information HAL knows about the devices on the system. On Ubuntu desktop this could have been found at Applications->System Tools->Device Manager.

    Centralised policy management - PolicyKit

    An application used by HAL to that allows unprivileged processes to speak to privileged processes, in order to grant some user the right to perform some tasks in some situations.

    Relies heavily on /proc entries. Mounting will not work if 'procfs' is not mounted on /proc.

    Sample uses

    • Let the user Hibernate and shutdown the computer.
    • Let the user manage (Wireless) connections.
    • Let the user mount/eject a removable media (CD/DVD, USB keys...)
    • Let the user access devices, like audio, scanner, etc.

    By default, PolicyKit allows

    • root to do everything
    • all users in the 'wheel' group to authenticate for admin tasks using their password
  • Change PolicyKit (polkit-1) settings

    Currently (2013) only manual editing of the configuration files is supported. As yet no desktop tool or the equivalent of the old cmd-line ('polkit-action') to make configuration changes.

    $ ls /usr/share/polkit-1/actions
    com.ubuntu.apport.policy              com.ubuntu.update-notifier.policy      \
    com.ubuntu.softwareproperties.policy  org.freedesktop.NetworkManager.policy  \
    $ more /usr/share/polkit-1/actions/org.debian.apt.policy
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE policyconfig PUBLIC
     "-//freedesktop//DTD PolicyKit Policy Configuration 1.0//EN"
      <vendor>Apt Daemon</vendor>

    See 'man polkit'.

  • List, modify registered PolicyKit actions
    /usr/bin/polkit-action (obsolete)

    Some options require org.freedesktop.policykit.modify-defaults authorisation. See man pages for more details.

    polkit-action [option action [value]]
     --action <action>                            Show detailed info. about a specific action.
     --reset-defaults <action>                    Reset an action defaults to factory defaults. 
     --show-overrides                             Prints all actions where defaults are overridden.
     --set-defaults-any <action> <value>          Override the given action with value.
     --set-defaults-inactive <action> <value>     Override the given action with value.
     --set-defaults-active <action> <value>       Override the given action with value.

    List all available actions

    # polkit-action

    Get detailed information for a specific action

    $ polkit-action --action
    description:      Directly access smart-card readers
    message:          System policy prevents access to the smart-card readers
    default_any:      no
    default_inactive: no
    default_active:   yes

    Modify an action value

    $ sudo polkit-action --set-defaults-any \ yes
    [sudo] password for mark:

    Observe the change(s)

    $ polkit-action --action
    description:      Directly access smart-card readers
    message:          System policy prevents access to the smart-card readers
    default_any:      yes (factory default: no)
    default_inactive: no
    default_active:   yes

    Identify 'none default' actions and reset them to their defaults

    $ polkit-action --show-overrides
    $ sudo polkit-action --reset-defaults
  • HAL daemon
    /usr/sbin/hald (obsolete)
    • Daemon that maintains a database of the devices connected to the system in real-time.
    • The daemon connects to the D-Bus system message bus.
    • It provides an API that applications can use to discover, monitor and invoke operations on devices.
    hald [--daemon=yes|no] [--verbose=yes|no] [--help]
     --daemon=yes|no             Become a daemon 
     --verbose=yes|no            Print out debug (overrides HALD_VERBOSE) 
     --retain-privileges         Retain privileges (for debugging) 
     --use-syslog                Print out debug messages to syslog instead of stderr
     --exit-after-probing        Exit after probing.  Useful only when profiling hald


    # /etc/init.d/dbus [ start | stop | restart | [reload | force-reload ] ]
    # /etc/init.d/hal  [ start | stop | [ restart | force-reload ] ]
  • Display HAL DB entries
    /usr/bin/lshal (obsolete)

    Utility for displaying items in the HAL device database.

    lshal [options] 
      -m, --monitor              Monitor - device list & all devices are monitored for changes
      -s, --short                Short output (print only non-static part of udi) 
      -t, --tree                 Tree view 
      -u, --show <udi>           Show only the specified device

    Display items in HAL db - long and short format

    $ lshal | head -n 8
    Dumping 112 device(s) from the Global Device List:
    udi = '/org/freedesktop/Hal/devices/computer'
      info.addons = {'hald-addon-cpufreq', 'hald-addon-acpi'} (string list)
      info.callouts.add = {'hal-acl-tool --remove-all', \
                           'hal-storage-cleanup-all-mountpoints'} (string list)
      info.callouts.session_active = {'hal-acl-tool --reconfigure'} (string list)
      info.callouts.session_add = {'hal-acl-tool --reconfigure'} (string list)
    $ lshal -s | head -n 8
  • List hardware configuration information
    $ lshw --help
    Hardware Lister (lshw) - B.02.16
    usage: lshw [-format] [-options ...]
           lshw -version
        -version        print program version (B.02.16)
    format can be
        -html           output hardware tree as HTML
        -xml            output hardware tree as XML
        -short          output hardware paths
        -businfo        output bus information
    options can be
        -class CLASS    only show a certain class of hardware
        -C CLASS        same as '-class CLASS'
        -c CLASS        same as '-class CLASS'
        -disable TEST   disable a test (like pci, isapnp, cpuid, etc. )
        -enable TEST    enable a test (like pci, isapnp, cpuid, etc. )
        -quiet          do not display status
        -sanitize       sanitise output (remove sensitive information like serial numbers, etc.)
        -numeric        output numeric IDs (for PCI, USB, etc.)

    List hardware configuration - short format, no status or sensitive information

    $ sudo lshw -short -quiet -sanitize
    H/W path        Device       Class       Description
                                 system      MS-7369
    /0                           bus         MS-7369
    /0/0                         memory      64KiB BIOS
    /0/4                         processor   AMD Athlon(tm) 64 X2 Dual Core Processor 6000+
    /0/4/5                       memory      256KiB L1 cache
    /0/4/6                       memory      2MiB L2 cache
    /0/4/7                       memory      L3 cache
    /0/2d                        memory      2GiB System Memory
    $ sudo lshw -short -quiet -sanitize
    [sudo] password for mark: 
    H/W path       Device      Class       Description
                               system      2181 (LENOVO_MT_2181)
    /0                         bus         Lenovo G585
    /0/0                       memory      128KiB BIOS
    /0/4                       processor   AMD E-300 APU with Radeon(tm) HD Graphics
    /0/4/8                     memory      128KiB L1 cache
    /0/4/9                     memory      1MiB L2 cache
    /0/22                      memory      4GiB System Memory
    /0/22/0                    memory      4GiB SODIMM DDR3 Synchronous 800 MHz (1.2 ns)
  • Makes changes to HAL device properties (obsolete)

    Prevent HAL from probing a specific device

    The notes in this section have been cut and pasted from a source on the net - again, apologies to the author as I failed to make note of the url.

    Create a .fdi (sml format) file under /usr/(local/)share/hal/fdi/preprobe/20thirdparty to ignore USB uhci controller 0

    Example .fdi file - /usr/local/share/hal/fdi/preprobe/20thirdparty/10-ignore-uhci0.fdi

    <?xml version="1.0" encoding="UTF-8"?>
    <deviceinfo version="0.2">
        <match key="freebsd.driver" string="uhci">
          <match key="freebsd.unit" int="0">
            <merge key="info.ignore" type="bool">true</merge>

    Merge, change other hal device properties (obsolete)

    Use the 'lshal' command to get a list of all available device properties or look at the system-provided '.fdi' files under /usr/local/share/hal/fdi/preprobe/10osvendor for more examples.

    All '.fdi' files in this 20thirdparty directory are loaded in alphabetical order. The convention is to start the files with a number. The lower the number, the earlier the file will be loaded.

    Using HAL to mount media - PolicyKit.conf

    • Volumes that you wish to manage using hal should NOT be listed in /etc/fstab.
    • All users MUST have procfs mounted on /proc. Users must be authorised to mount volumes using HAL - authorise via ConsoleKit and PolicyKit.

    A GNOME user using GDM to login does not need any additional changes to mount removable media. GDM will add a ConsoleKit record for the session

    Example ConsoleKit record

    $ ck-list-sessions 
     uid = '1000' 
     realname = 'mark,,,' 
     seat = 'Seat1' 
     session-type = '' 
     active = TRUE                    # Must be set = TRUE for auto-mounting to work
     x11-display = ':0' 
     x11-display-device = '/dev/tty7' 
     display-device = '' 
     remote-host-name = '' 
     is-local = TRUE 
     on-since = '2008-11-19T12:48:54Z'

    If a none GNOME user or GDM is not used then need to add the '' action to username.

    Edit PolicyKit.conf - /usr/local/etc/PolicyKit/PolicyKit.conf

    <config version="0.1">
       <!-- New configuration lines go here>
       <define_admin_auth group="wheel"/>        # Members of group wheel use their own passwords
                                                 # (not root's) to run privileged cmds  
       <match user="sam|fred">                   # Sam and(or) Fred can do any action
          <return result="yes"/> 
       <match action="">
          <match user="marcus">
             <return result="yes"/>              # Marcus can mount
          <match user="freddy">
             <return result="no"/>               # Freddy cannot
       <match action=""> 
          <match user="davidz"> 
             <return result="yes"/>              # Davidz can mount fixed drives

    Changes are propagated on saving, if syntax errors in file then return result is always NO.

    Validate PolicyKit.conf file syntax

    # polkit-config-file-validate <path to config file>
  • Troubleshoot some problems with hal (obsolete)
    • Can run '/usr/bin/dbus-launch' - a utility to start a message bus from a shell script.

    • When specifying a program to be run 'dbus-launch' will launch a session bus instance, set the appropriate environment variables so the specified program can find the bus and then execute the specified program with the specified arguments. See man pages.

    Get verbose output from hald when it is performing the problematic task

    # /usr/local/etc/rc.d/hald stop
    # /usr/local/sbin/hald --daemon=no --verbose=yes