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


Host configuration

  • Configure networking
    • This can be configured statically or via DHCP (Dynamic Host Configuration Protocol).
    • Static IP configuration is normally used for small networks with a few hosts e.g. a home network.
    • DHCP is used for larger networks with many hosts. A DHCP server allocates and distributes IP addresses to DHCP clients (along with other information).
    • Usually DHCP client programs run on boot up, as part of the network configuration and request an IP address from the/a DHCP server.
    • Depending on how the DHCP server is configured the IP address allocated to a client may vary each time the client starts up.

    For more info. on DHCP see Client DHCP configuration.

    The configuration files and scripts used to configure a host's interface(s) varies from distribution to distribution.

    Redhat, Fedora IPV4


    NETWORKING=yes              # localhost.localdomain

    For each interface there is a configuration file - /etc/sysconfig/network-scripts/ifcfg-<interface-device-name> where <interface-device-name> can be eth0, eth1, ... lo, wlan0, ... etc.

    Sample static configuration - /etc/sysconfig/network-scripts/ifcfg-eth0

    # Use STATIC

    Sample DHCP configuration - /etc/sysconfig/network-scripts/ifcfg-eth0

    # Use DHCP

    Take an interface up, down

    # /etc/sysconfig/network-scripts/if[up|down] <interface-device-name>
    # /etc/sysconfig/network-scripts/if[up|down]-<interface type>

    Where <interface type> can be ppp, ipx, eth, ipp, ... etc.

    Debian, Ubuntu IPV4


    # This is the main configuration file. 
    # 'auto' is used to identify the physical interfaces to be
    # brought up when ifup is run with the '-a' option.
    # DHCP
    auto lo eth0
    iface lo inet loopback
    iface eth0 inet dhcp
    # Static
    auto eth1
    iface eth1 inet static
    # Virtual point-to-point
    auto eth1:1
    iface eth1:1 inet static

    Follow link for debian wireless configuration examples.

    Command line

    Configure eth0 with a static IP, broadcast and netmask

    $ sudo ifconfig eth0 netmask broadcast
    $ sudo route add default gw

    Also add a route to the interface's network.

  • Debian zero-conf netwoking

    Zero-conf uses /etc/networks.

    (IPV4) Zero-conf enables two systems (such as laptops) to be connected via a crossover Ethernet cable and communicate to each other using IP without additional manual configuration - Zero Configuration Networking.

    On larger scale networks, with more than two hosts, MDNS (Multicast DNS) provides name-to-address translation and other DNS-like operations in the absence of a conventional DNS server. I disable this service.

    The purpose of Zero Configuration Networking is not solely to make current personal computer networking easier to use. The long-term goal is to enable the creation of entirely new kinds of networked products which would negate the inconvenience and support costs involved in setting up, configuring and maintaining a network to allow them to operate thus making the products commercially viable.

    Configuration (guess there may be some!) - /etc/networks

    # (debian) symbolic names for networks, zero-conf

    Not unusual for this file to be empty or not exist.

  • Configure a network interface

    Sets parameters and can take the interface up/down.

    ifconfig [-v] [-a] [-s] [interface]
    ifconfig interface [address [parameters]]
     -a                            Display all interfaces which are currently available,
                                   even if down
     -s                            Display a short list (like netstat -i)
     -v                            More verbose for some error conditions
     [-]arp                        Enable or disable ARP on this interface.
     [-]promisc                    Enable or disable promiscuous mode of the interface.
     [-]allmulti                   Enable or disable all-multicast mode.
     [-]broadcast [addr]           If the address argument is given, set the protocol 
                                   broadcast addr. Else set/clear
     [-]pointopoint [addr]         If addr argument is also given => destination address
     metric N                      Set the interface metric.
     mtu N                         Set the Maximum Transfer Unit
     netmask addr                  Set the IP network mask for this interface.
     hw class address              Set mac address
     multicast                     Set the multicast flag on the interface.
     address                       Set IP address to be assigned to this interface.
     txqueuelen length             Set the length of the transmit queue of the device.
     add addr/prefixlen            Add an IPv6 address to an interface.
     del addr/prefixlen            Remove an IPv6 address from an interface.
     tunnel            Create a SIT (IPv6-in-IPv4) device, tunnel to the 
                                   given destination.

    Configure an interface

    # ifconfig eth0 netmask broadcast
    # ifconfig eth0

    Set the IP address

    # ifconfig eth0

    Add an alias

    # ifconfig eth0 alias

    Configure Token Ring for a 4 Mbp

    # ifconfig tra0 speed 4

    Configure loopback

    # ifconfig lo0 inet up

    Add mac address

    # ifconfig eth0 hw ether ab:01:23:f3:00:24

    Configure an IPV6 primary interface

    # ifconfig lan0 inet6 up

    Configure an IPV6 secondary interface

    # ifconfig lan0:1 inet6 2345::5432 up

    Enable tunneling and create a configured tunnel

    # ifconfig tu0 inet6 up
    # route inet6 -t add c001::/64 ::

    Add network addresses 40-50 to subnets 18.240.32, 18.240.33, 18.240.34, 18.240.35, 18.240.36

    # ifconfig eth0 aliaslist 132.240.32-36.40-50/24

    Stop eth0, delete all addresses associated with the interface, and close all TCP connections

    # ifconfig eth0 down delete abort

    Delete the alias address on interface tu0 and close all

    # ifconfig eth0 -alias abort

    Associate MAC address aa:01:81:43:02:11 with the alias address

    # ifconfig eth0 alias physaddr aa:01:81:43:02:11

    Disassociate MAC address aa:01:81:43:02:11 from the alias address

    # ifconfig eth0 -alias -physaddr aa:01:81:43:02:11

    Display the hardware and IP

    # ifconfig -v eth0

    Configure an interface and bring it up

    # ifconfig eth1 inet mtu 1500 address netmask up

    Take an interface down

    # ifconfig eth1 down

    Configure MAC address of an interface

    # ifconfig eth1 hw ether 00E0206219E4

    Display a short list

    # ifconfig -s
    eth0    1500   0    15908      0      0      0    15860      0      0      0 BMRU
    eth1    1500   0        0      0      0      0       55      0      0      0 BMRU
    lo     16436   0     7673      0      0      0     7673      0      0      0 LRU

    Show all interfaces including those that are down

    # ifconfig -a
    eth0      Link encap:Ethernet  HWaddr 00:0F:EA:CB:7A:C4
              inet addr:  Bcast:  Mask:
              UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1             # up
    eth1      Link encap:Ethernet  HWaddr 00:E0:20:62:19:E4
              inet addr:  Bcast:  Mask:
              inet6 addr: fe80::2e0:20ff:fe62:19e4/64 Scope:Link
              BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1                # down
    lo        Link encap:Local Loopback
              inet addr:  Mask:
              inet6 addr: ::1/128 Scope:Host
              UP LOOPBACK RUNNING  MTU:16436  Metric:1
  • Take a network interface down, up
    /sbin/ifup, ifdown
    • When an interface is taken down all routes associated with it are removed, these routes clearly need to be added when the interface is back up.
    • On RedHat, these two scripts, available at boot, handle all configuration to get an interface and its routes up and running.
    • On Debian the names vary and a more modular approach is taken - /etc/if-up.d/..., if-down.d/..., if-pre-up.d/..., if-post-down.d/...

    Used to configure (or deconfigure) network interfaces based on interface definitions in the file /etc/network/interfaces. These are basically the same script that calls 'ifconfig' and 'route' to do the configuring, deconfiguring.

    ifup   [-nv] [--no-act] [--verbose]
           [-i FILE|--interfaces=FILE] 
           [--allow CLASS] 
    ifdown [-nv] [--no-act] [--verbose] 
           [-i FILE|--interfaces=FILE] 
           [--allow CLASS] 
     -a | --all                       'ifup' - bring up in the order listed and marked
                                      as 'auto'  in /etc/network/interfaces.
                                      'ifdown' - take down in the order listed, all 
                                      interfaces in /etc/network/interfaces.
     --force                          Force configuration/deconfiguration of interface.
     --allow=CLASS                    Only act on interfaces listed in an allow-CLASS 
                                      line in /etc/network/interfaces.
     -i FILE | --interfaces=FILE      Use alternative to /etc/network/interfaces.
     -n | --no-act                    Don't configure any interfaces or run any "up"
                                      or "down" commands.
     --no-mappings                    Don't run any mappings.

    Examples from the man page:

    Bring up all the interfaces defined with auto in /etc/network/interfaces

    # ifup -a

    Bring up interface eth0

    # ifup eth0

    Bring up interface eth0 as logical interface home

    # ifup eth0=home

    Bring down all interfaces that are currently up

    # ifdown -a

    View info on current state of network interfaces - /var/run/network/ifstate

    # more /var/run/network/ifstate

    Shows current state of network interfaces - does not include wireless interfaces.

  • System hostname


    $ cat /etc/hostname
    $ hostname


    $ cat /proc/sys/kernel/hostname
    $ sysctl kernel.hostname
    kernel.hostname = mark-Lenovo-G585

    Show, set a system's hostname - /bin/hostname

    • Show or set the system's host name.
    • Can't change the FQDN (as returned by 'hostname --fqdn') or the DNS domain name (as returned by 'dnsdomainname') with this command.
    hostname [options] [hostname]
    Common options::
     -a | --alias                 Display the alias name of the host
     -d | --domain                Display the name of the DNS domain
     -F | --file filename         Read the host name from the specified file
     -f | --fqdn | --long         Display the FQDN (Fully  Qualified  Domain  Name)
     -s | --short                 Display the short host name. The host name cut at 
                                  the first '.'
     -y | --yp | --nis            Display/Set the NIS domain name - needs root access
                                  to set a new NIS domain


    $ hostname
    $ hostname -d
    $ hostname --fqdn
    $ hostname -a
    ub-desktop  devbox
  • Host's domain name
    • Domain names are assigned through registration by http://www.internic/net/register.php.
    • A FQDN (Fully Qualified Domain Name) consists of a short host name and the DNS domain name.
    • The FQDN is the name that the resolver returns for the host name.
    • The DNS domain name is the part after the first '.'.

    To change depends on the configuration (/etc/hosts or /etc/nsswitch.conf), if the hosts file is parsed before DNS or NIS, can change it in /etc/hosts.

    Set, display a system's NIS domain name - /bin/domainname

    Set or display the domain name, do not use to get the DNS domain name - it shows the NIS/YP domain name.

    domainname [NIS domainname]
    $ sysctl kernel.domainname
    kernel.domainname = (none)

    Show a system's DNS domain name - /bin/dnsdomainname

    Show the system's DNS domain name, only option -v for verbose.

    dnsdomainname [-v]
    $ dnsdomainname
  • Name resolution using static hosts lookup table

    Sample entries

    # Static hosts lookup table, simple mappings of IP &rarr; hostnames.  
    # Used for small local networks with few hosts where allocating and 
    # maintaining IP addresses manually is not a big issue.
    # <IP address> <canonical_hostname> <aliases>
    # Sample entries     localhost ub-desktop devbox   
    # The above entry for the loopback is a Debian specific 'fix'
    # - Gnome likes to use a consistent hostname.  If not a fqdn 
    # 'dnsdomainname' and 'hostname -d' or '--fqdn' will return nothing.  ubuntu testsvr
    # The following lines are desirable for IPv6 capable hosts
    ::1     localhost ip6-localhost ip6-loopback
    fe00::0 ip6-localnet
    ff00::0 ip6-mcastprefix
    ff02::1 ip6-allnodes
    ff02::2 ip6-allrouters
    ff02::3 ip6-allhosts
  • Name resolution for pre-glibc2 systems

    Sample entries

    # Controls name resolution for pre-glibc2 systems, in case you have an old linux system.
    # Sample entries
    order hosts,bind              # Check /etc/hosts first then use DNS (bind)
    multi on                      # Allow multiple IP addresses for host
  • Name resolution for post-glibc2 systems

    Sample entries

    # Controls the sources used by various system library lookup functions 
    # e.g. name resolution.  Supercedes '/etc/host.conf'
    # The entry '[NOTFOUND=return]' means that the search for an entry
    # should stop if the search in the previous entry turned up nothing. 
    # NB that if the search failed due to some other reason (e.g. NIS 
    # server responding) then the search continues with the next entry.
    # Legal entries are:
    #       nisplus or nis+         Use NIS+ (NIS version 3)
    #       nis or yp               Use NIS (NIS version 2), also called YP
    #       dns                     Use DNS (Domain Name Service)
    #       files                   Use the local files
    #       db                      Use the local database (.db) files
    #       compat                  Use NIS on compat mode
    #       hesiod                  Use Hesiod for user lookups
    #       [NOTFOUND=return]       Stop searching if not found so far
    # To use db, put the "db" in front of "files" for entries you want
    # to be looked up first in the databases.
    # Example:
    #passwd:    db files nisplus nis
    #shadow:    db files nisplus nis
    #group:     db files nisplus nis
    passwd:     files
    shadow:     files
    group:      files
    #hosts:     db files nisplus nis dns
    hosts:      files dns            # Use local files then DNS for hostname resolution
    # Example - obey only what nisplus tells us...
    #services:   nisplus [NOTFOUND=return] files
    #networks:   nisplus [NOTFOUND=return] files
    #protocols:  nisplus [NOTFOUND=return] files
    #rpc:        nisplus [NOTFOUND=return] files
    #ethers:     nisplus [NOTFOUND=return] files
    #netmasks:   nisplus [NOTFOUND=return] files
    bootparams: nisplus [NOTFOUND=return] files
    ethers:     files
    netmasks:   files
    networks:   files
    protocols:  files
    rpc:        files
    services:   files
    netgroup:   nisplus
    publickey:  nisplus
    automount:  files nisplus
    aliases:    files nisplus
  • DNS client configuration file

    Sample entries

    # Controls the client side of DNS. Includes IP addresses of Name Servers 
    # to use, can have a maximum of three nameservers.

    In this case my nameserver is my router which forwards dns requests to my ISP's dns server.

    resolv.conf options:

     nameserver      Name server IP address. Maximum of three.  Queried in the order listed.
                     If no nameserver entries default is to use the name server on local 
     domain          Local domain name.  If no domain entry, the domain is determined from
                     the local host name. The domain part is taken to be everything after
                     the first '.'.  If the host name does not contain a domain part, the
                     root domain is assumed.
     search          Search list for host-name lookup. Normally determined from the local
                     domain name.  Default = local domain
     sortlist        A sortlist is specified by IP address netmask pairs.
                     The netmask is optional and defaults to the natural netmask of the net.
                     Up to 10 pairs may be specified. 
                     e.g. sortlist
     options         Options allows certain internal resolver variables to be modified
                     e.g. options inet6 timeout:n attempts:n