Top

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

ADMINISTRATION

Localisation

  • Unicode character set, UTF-8

    Unicode is a single unified character set, an industry standard for the consistent representation and manipulation of text expressed in most of the world's writing systems.

    It handles practically any script and language used on this planet and supports a comprehensive set of mathematical and technical symbols.

    Unicode can be implemented by different character encodings and is predominant in the internationalisation and localisation of computer software. The most commonly used encodings are UTF-8.

    UTF8

    • UTF-8 stands for Unicode Transformation Format-8. It is an octet (8-bit) lossless encoding of Unicode characters.
    • It uses 1 byte for all ASCII characters (the same code values as in the standard ASCII encoding) and up to 4 bytes for other characters.
  • Convert from one encoding to another
    /usr/bin/iconv

    Converts the encoding of characters in 'inputfile' (or stdin if no filename specified) from one coded character set to another. The result is written to standard output unless otherwise specified by the '--output' option.

    iconv -f encoding [-t encoding] [inputfile] ...
    

    List known coded character sets

    $ iconv -l
    The following list contain all the coded character sets known .....
    437, 500, 500V1, 850, 851, 852, 855, 856, 857, 860, 861, 862, 863, 864, 865,
    866, 866NAV, 869, 874, 904, 1026, 1046, 1047, 8859_1, 8859_2, 8859_3, 8859_4,
    .....
    
  • Get locale specific information
    /usr/bin/locale

    The 'locale' of a system refers to the locality of that system in terms of country/region. localisation routines determine a system's locale via locale environment variables.

    Writes information about the current locale environment or all locales to standard output. When run without any arguments locale summarises the current locale environment for each locale category defined by the LC_* environment variables.

    Summarise the current locale environment

    $ locale
    LANG=en_GB.UTF-8                      # Default value for all unset/empty locale variables
    LC_CTYPE="en_GB.UTF-8"                # Character classification and case conversion
    LC_NUMERIC="en_GB.UTF-8"              # Non-monetary numeric formats
    LC_TIME="en_GB.UTF-8"                 # Date and time formats
    LC_COLLATE="en_GB.UTF-8"              # Collation/sorting order
    LC_MONETARY="en_GB.UTF-8"             # Monetary formats
    LC_MESSAGES="en_GB.UTF-8"             # Formats of informative and diagnostic messages
                                          # and interactive responses
    .....
    LC_ALL=                               # Override for all other LC_* variables
    

    The environment variable LANGUAGE, used by GNU 'gettext', can be set to multiple values via a ':' separated list. This overrides LC_MESSAGES.

    A listed summarised variable (as above) is not necessarily set

    $ echo $LC_PAPER
    
    $ echo $LANG
    en_GB.UTF-8
    

    When LANG is set it's value will be used for local variables that aren't set.

    So, if you are only going to use a single value, you need set LANG or LC_ALL. If you are going to use more than one then LC_ALL must be unset.

    Variable processing order to determine which locale to use

    • If the LC_ALL environment variable is defined and is not null, its value is used.
    • If the locale category environment variable e.g. LC_COLLATE is set and non-null, its value is used.
    • If the LANG environment variable is defined and is not null, its value is used.
    • If the LANG environment variable is not set or is null, an implementation-dependent default locale is used.
  • Change the collating (sort order) for a command
    $ ls -a
    .  ..  afile  Afile  .Afile  bfile  .bfile  Bfile  photo1.png  photo2.png  photo 3 .png
    
    $ LC_COLLATE="C" ls -a
    .  ..  .Afile  .bfile  Afile  Bfile  afile  bfile  photo 3 .png  photo1.png  photo2.png
    

    LC_COLLATE="C" sets the sort order to use ASCII encoding.

    In the 'tcsh' use

    $ env LANG=C ls -a
    
  • Speeding up command execution time

    As stated in the UTF-8 section previously, UTF-8 encoded file and directory names use more bytes than actual characters in the file and directory names. Processing UTF-8 encoded data therefore, requires more resources.

    By setting the encoding to "C" (ASCII) the execution of scripts, shell commands can be speeded up - as demonstrated below.

    Run a command using my system's default encoding - UTF-8

    $ time ls -alR > /dev/null
    real    0m1.833s
    user    0m0.056s
    sys 0m0.084s
    

    Run the same command using ASCII encoding

    $ time LANG=C ls -alR > /dev/null
    real    0m0.108s
    user    0m0.024s
    sys 0m0.068s
    

    Quite a difference .....

  • Available configurabale time zones

    A TimeZone is a measure of how far local time differs from Coordinated Universal Time (UTC). Time zones available for use are in /usr/share/zoneinfo/.

    Programs for time zone configuration are largely distribution dependent e.g. system-config-date - Redhat GUI, tzconfig - Debian cmd-line.

  • RedHat, Fedora timezone file
    /etc/sysconfig/clock
    # The ZONE parameter is only evaluated by system-config-date.
    # The timezone of the system is defined by the contents of /etc/localtime
    ZONE="Europe/London"
    UTC=true
    ARC=false
    
  • Debian timezone file
    /etc/timezone

    Traditionally was a link to /etc/default/init. Was used to set the time zone environment variable TZ and several locale-related environment variables, not so with modern systems.

    If it exists it contains a string pointing to the relevant /usr/share/zoneinfo/ file.

    Contents of /etc/timezone

    Europe/London
    
  • A copy of a Timezone file
    /etc/localtime

    Traditionally this was a link to one of the time zone files in /usr/share/zoneinfo/.

    On modern systems it is much more likely to be a copy of the appropriate time zone data file since the /usr/share filesystem may not be mounted when the local time zone information is needed early in the boot process.

    Old and the new

    $ ls -al /usr/share/zoneinfo/Europe/London /etc/localtime
    -rw-r--r-- 1 root root 3661 2009-04-06 16:32 /etc/localtime
    -rw-r--r-- 5 root root 3661 2009-03-30 15:55 /usr/share/zoneinfo/Europe/London
    

    May also be a link in /usr/share/zoneinfo

    $ file /usr/share/zoneinfo/localtime
    /usr/share/zoneinfo/localtime: symbolic link to /etc/localtime
    

    /etc/localtime is a copy of a zoneinfo file

    $ strings /etc/localtime
    TZif2
    BDST
    TZif2
    BDST
    GMT0BST,M3.5.0/1,M10.5.0
    
    $ strings /usr/share/zoneinfo/Europe/London
    TZif2
    BDST
    TZif2
    BDST
    GMT0BST,M3.5.0/1,M10.5.0
    
  • View timezones (Debian)
    /usr/bin/tzselect

    Called from the command line without any parameters. 'tzselect' will not actually change the timezone - use 'dpkg-reconfigure tzdata' to do this.

    Usage example - output truncated

    $ tzselect
    Please identify a location so that time zone rules can be set correctly.
    Please select a continent or ocean.
     1) Africa
     2) Americas
     ......
     7) Australia
     8) Europe
     .....
    11) none - I want to specify the time zone using the Posix TZ format.
    #? 8
    Please select a country.
     1) Aaland Islands  18) Greece           35) Norway
     2) Albania         19) Guernsey         36) Poland
     .....
     8) Britain (UK)    25) Latvia           42) Slovakia
     9) Bulgaria        26) Liechtenstein    43) Slovenia
     .....
    #? 8
    The following information has been given:
        Britain (UK)
    Therefore TZ='Europe/London' will be used.
    Local time is now:  Fri Mar 19 20:32:53 GMT 2010.
    Universal Time is now:  Fri Mar 19 20:32:53 UTC 2010.
    Is the above information OK?
    1) Yes
    2) No
    #? 1
    You can make this change permanent for yourself by appending the line
        TZ='Europe/London'; export TZ
    to the file '.profile' in your home directory; then log out and log in again.
    Here is that TZ value again, this time on standard output so that you can use
    the /usr/bin/tzselect command in shell scripts:
    Europe/London
    

    Remember - it DOES NOT change or set the timezone

  • Configure the Timezone (Debian)
    /usr/bin/tzconfig

    The command attempts to update the link /etc/localtime to point to the correct timezone installed in /usr/share/zoneinfo/. If you have a modern system where /etc/localtime is a copy and not a link this command will either not be installed (as in this case) or it should not work.

    It is called from the command line without any parameters - need to be root. It presents the current setting and asks for verification to change it.

    Press 'Ctrl-C' to interrupt the script at any time.

  • Get date for alternate timezone
    /bin/date

    My timezone - europe/london

    $ date
    Fri Mar 19 20:49:58 GMT 2010
    

    Date and time in america/los_angeles

    $ TZ=America/Los_Angeles date
    Fri Mar 19 13:50:27 PDT 2010