# Home sweet /home

This chapter is about configuring your environment. Now that we now how to use an editor, we can change all kinds of files to make ourselves feel better at home. After completing this chapter, you will know more about:

- Organizing your environment

- Common shell setup files

- Shell configuration

- Configuring the prompt

- Configuring the graphical environment

- Sound and video applications

- Display and window managers

- How the X client-server system works

- Language and font settings

- Installing new software

- Updating existing packages

## General good housekeeping

### Introduction

As we mentioned before, it is easy enough to make a mess of the system. We can't put enough stress on the importance of keeping the place tidy. When you learn this from the start, it will become a good habit that will save you time when programming on a Linux or UNIX system or when confronted with system management tasks. Here are some ways of making life easier on yourself:

environment organization

- Make a `bin` directory for your program files and scripts.

- Organize non-executable files in appropriate directories, and make as many directories as you like. Examples include separate directories for images, documents, projects, downloaded files, spreadsheets, personal files, and so on.

- Make directories private with the `chmod 700 `dirname`` command.

- Give your files sensible names, such as `Complaint to the prime minister 050302` rather than `letter1`.

### Make space

On some systems, the `quota` system may force you to clean up from time to time, or the physical limits of your hard disk may force you to make more space without running any monitoring programs. This section discusses a number of ways, besides using the `rm` command, to reclaim disk space.

Run the `quota `-v`` command to see how much space is left.

#### Emptying files

Sometimes the content of a file doesn't interest you, but you need the file name as a marker (for instance, you just need the timestamp of a file, a reminder that the file was there or should be there some time in the future). Redirecting the output of a null command is how this is done in the Bourne and Bash shells:

I/O redirection null command
files emptying

    andy:~> cat wishlist > placeholder

    andy:~> ls -la placeholder
    -rw-rw-r--    1 andy   andy       200 Jun 12 13:34 placeholder

    andy:~>  > placeholder

    andy:~> ls -la placeholder

    -rw-rw-r--    1 andy   andy         0 Jun 12 13:35 placeholder

The process of reducing an existing file to a file with the same name that is 0 bytes large is called truncating.

truncating

For creating a new empty file, the same effect is obtained with the `touch` command. On an existing file, `touch` will only update the timestamp. See the Info pages on `touch` for more details.

touch

To almost empty a file, use the `tail` command. Suppose user andy's wishlist becomes rather long because he always adds stuff at the end but never deletes the things he actually gets. Now he only wants to keep the last five items:

tail

    andy:~> tail -5 wishlist > newlist

    andy:~> cat newlist > wishlist

    andy:~> rm newlist

#### More about log files

Some Linux programs insist on writing all sorts of output in a log file. Usually there are options to only log errors, or to log a minimal amount of information, for example setting the debugging level of the program. But even then, you might not care about the log file. Here are some ways to get rid of them or at least set some limits to their size:

files logs

- Try removing the log file when the program is not running, if you are sure that you won't need it again. Some programs may even see, when restarted, that there is no log file and will therefore not log.

- If you remove the log file and the program recreates it, read the documentation for this particular program in search for command options that avoid making log files.

- Try making smaller log files by logging only the information that is relevant to you, or by logging only significant information.

- Try replacing the log file with a symbolic link to `/dev/null`; if you're lucky the program won't complain. Don't do this with the log files of programs that run at system boot or programs that run from cron (see ). These programs might replace the symbolic link with a small file that starts growing again.

#### Mail

Regularly clean out your mailbox, make sub-folders and automatic redirects using `procmail` (see the Info pages) or the filters of your favorite mail reading application. If you have a trash folder, clean it out on a regular basis.

To redirect mail, use the `.forward` file in your home directory. The Linux mail service looks for this file whenever it has to deliver local mail. The content of the file defines what the mail system should do with your mail. It can contain a single line holding a fully qualified E-mail address. In that case the system will send all your mail to this address. For instance, when renting space for a website, you might want to forward the mail destined for the webmaster to your own account in order not to waste disk space. The webmaster's `.forward` may look like this:

.forward

    webmaster@www ~/> cat .forward
    mike@pandora.be

Using mail forwarding is also useful to prevent yourself from having to check several different mailboxes. You can make every address point to a central and easily accessible account.

You can ask your system administrator to define a forward for you in the local mail aliases file, like when an account is being closed but E-mail remains active for a while.

#### Save space with a link

When several users need access to the same file or program, when the original file name is too long or too difficult to remember, use a symbolic link instead of a separate copy for each user or purpose.

links saving space

Multiple symbolic links may have different names, e.g. a link may be called `monfichier` in one user's directory, and `mylink` in another's. Multiple links (different names) to the same file may also occur in the same directory. This is often done in the `/lib` directory: when issuing the command

`ls `-l` `/lib``

you will see that this directory is plenty of links pointing to the same files. These are created so that programs searching for one name would not get stuck, so they are pointed to the correct/current name of the libraries they need.

#### Limit file sizes

The shell contains a built-in command to limit file sizes, `ulimit`, which can also be used to display limitations on system resources:

ulimit
files limit size

    cindy:~> ulimit -a
    core file size (blocks)     0
    data seg size (kbytes)      unlimited
    file size (blocks)          unlimited
    max locked memory (kbytes)  unlimited
    max memory size (kbytes)    unlimited
    open files                  1024
    pipe size (512 bytes)       8
    stack size (kbytes)         8192
    cpu time (seconds)          unlimited
    max user processes          512
    virtual memory (kbytes)     unlimited

Cindy is not a developer and doesn't care about core dumps, which contain debugging information on a program. If you do want core dumps, you can set their size using the `ulimit` command. Read the Info pages on `bash` for a detailed explanation.

files core dumps

Core file?

A core file or core dump is sometimes generated when things go wrong with a program during its execution. The core file contains a copy of the system's memory, as it was at the time that the error occured.

#### Compressed files

Compressed files are useful because they take less space on your hard disk. Another advantage is that it takes less bandwidth to send a compressed file over your network. A lot of files, such as the man pages, are stored in a compressed format on your system. Yet unpacking these to get a little bit of information and then having to compress them again is rather time-consuming. You don't want to unpack a man page, for instance, read about an option to a command and then compress the man page again. Most people will probably forget to clean up after they found the information they needed.

So we have tools that work on compressed files, by uncompressing them only in memory. The actual compressed file stays on your disk as it is. Most systems support `zgrep`, `zcat`, `bzless` and other members of the z-family to prevent unnecessary decompressing/compressing actions. See your system's binary directory and the Info pages.

See for more on the actual compressing of files and examples on making archives.

## Your text environment

### Environment variables

#### General

We already mentioned a couple of environment variables, such as `PATH` and `HOME`. Until now, we only saw examples in which they serve a certain purpose to the shell. But there are many other Linux utilities that need information about you in order to do a good job.

What other information do programs need apart from paths and home directories?

A lot of programs want to know about the kind of terminal you are using; this information is stored in the `TERM` variable. In text mode, this will be the linux terminal emulation, in graphical mode you are likely to use xterm. Lots of programs want to know what your favorite editor is, in case they have to start an editor in a subprocess. The shell you are using is stored in the `SHELL` variable, the operating system type in `OS` and so on. A list of all variables currently defined for your session can be viewed entering the `printenv` command.

TERM
SHELL
OS
environment show variables
printenv

The environment variables are managed by the shell. As opposed to regular shell variables, environment variables are inherited by any program you start, including another shell. New processes are assigned a copy of these variables, which they can read, modify and pass on in turn to their own child processes.

There is nothing special about variable names, except that the common ones are in upper case characters by convention. You may come up with any name you want, although there are standard variables that are important enough to be the same on every Linux system, such as `PATH` and `HOME`.

#### Exporting variables

An individual variable's content is usually displayed using the `echo` command, as in these examples:

variables show content
echo

    debby:~> echo $PATH
    /usr/bin:/usr/sbin:/bin:/sbin:/usr/X11R6/bin:/usr/local/bin

    debby:~> echo $MANPATH
    /usr/man:/usr/share/man/:/usr/local/man:/usr/X11R6/man

If you want to change the content of a variable in a way that is useful to other programs, you have to export the new value from your environment into the environment that runs these programs. A common example is exporting the `PATH` variable. You may declare it as follows, in order to be able to play with the flight simulator software that is in `/opt/FlightGear/bin`:

variables export

    debby:~> PATH=$PATH:/opt/FlightGear/bin

This instructs the shell to not only search programs in the current path, `$PATH`, but also in the additional directory `/opt/FlightGear/bin`.

However, as long as the new value of the `PATH` variable is not known to the environment, things will still not work:

    debby:~> runfgfs
    bash: runfgfs: command not found

Exporting variables is done using the shell built-in command `export`:

export

    debby:~> export PATH

    debby:~> runfgfs
    --flight simulator starts--

In Bash, we normally do this in one elegant step:

`export `VARIABLE`=value`

The same technique is used for the `MANPATH` variable, that tells the `man` command where to look for compressed man pages. If new software is added to the system in new or unusual directories, the documentation for it will probably also be in an unusual directory. If you want to read the man pages for the new software, extend the `MANPATH` variable:

MANPATH

    debby:~> export MANPATH=$MANPATH:/opt/FlightGear/man

    debby:~> echo $MANPATH
    /usr/man:/usr/share/man:/usr/local/man:/usr/X11R6/man:/opt/FlightGear/man

You can avoid retyping this command in every window you open by adding it to one of your shell setup files, see .

#### Reserved variables

The following table gives an overview of the most common predefined variables:

variables reserved variables

Common environment variables

Variable name | Stored information
--- | ---
`DISPLAY` | used by the X Window system to identify the display server
`DOMAIN` | domain name
`EDITOR` | stores your favorite line editor
`HISTSIZE` | size of the shell history file in number of lines
`HOME` | path to your home directory
`HOSTNAME` | local host name
`INPUTRC` | location of definition file for input devices such as keyboard
`LANG` | preferred language
`LD_LIBRARY_PATH` | paths to search for libraries
`LOGNAME` | login name
`MAIL` | location of your incoming mail folder
`MANPATH` | paths to search for man pages
`OS` | string describing the operating system
`OSTYPE` | more information about version etc.
`PAGER` | used by programs like `man` which need to know what to do in case output is more than one terminal window.
`PATH` | search paths for commands
`PS1` | primary prompt
`PS2` | secondary prompt
`PWD` | present working directory
`SHELL` | current shell
`TERM` | terminal type
`UID` | user ID
`USER(NAME)` | user name
`VISUAL` | your favorite full-screen editor
`XENVIRONMENT` | location of your personal settings for X behavior
`XFILESEARCHPATH` | paths to search for graphical libraries

DISPLAY
DOMAIN
EDITOR
HISTSIZE
HOME
HOSTNAME
INPUTRC
LANG
LD_LIBRARY_PATH
LOGNAME
MAIL
MANPATH
OS
OSTYPE
PAGER
PATH
PS1
PS2
PWD
SHELL
TERM
UID
USER(NAME)
VISUAL
XENVIRONMENT
XFILESEARCHPATH

A lot of variables are not only predefined but also preset, using configuration files. We discuss these in the next section.

### Shell setup files

When entering the `ls `-al`` command to get a long listing of all files, including the ones starting with a dot, in your home directory, you will see one or more files starting with a . and ending in rc. For the case of `bash`, this is `.bashrc`. This is the counterpart of the system-wide configuration file `/etc/bashrc`.

.bashrc
bashrc

When logging into an interactive login shell, `login` will do the authentication, set the environment and start your shell. In the case of `bash`, the next step is reading the general `profile` from `/etc`, if that file exists. `bash` then looks for `~/.bash_profile`, `~/.bash_login` and `~/.profile`, in that order, and reads and executes commands from the first one that exists and is readable. If none exists, `/etc/bashrc` is applied.

shell configuration files
profile
.bash_profile
.bash_login
.profile

When a login shell exits, `bash` reads and executes commands from the file `~/.bash_logout`, if it exists.

.bash_logout

This procedure is explained in detail in the `login` and `bash` man pages.

login

### A typical set of setup files

#### /etc/profile example

Let's look at some of these config files. First `/etc/profile` is read, in which important variables such as `PATH`, `USER` and `HOSTNAME` are set:

profile example

    debby:~> cat /etc/profile
    # /etc/profile

    # System wide environment and startup programs, for login setup
    # Functions and aliases go in /etc/bashrc

    # Path manipulation
    if [ `id -u` = 0 ] && ! echo $PATH | /bin/grep -q "/sbin" ; then
        PATH=/sbin:$PATH
    fi

    if [ `id -u` = 0 ] && ! echo $PATH | /bin/grep -q "/usr/sbin" ; then
        PATH=/usr/sbin:$PATH
    fi

    if [ `id -u` = 0 ] && ! echo $PATH | /bin/grep -q "/usr/local/sbin"
        then
        PATH=/usr/local/sbin:$PATH
    fi

    if ! echo $PATH | /bin/grep -q "/usr/X11R6/bin" ; then
        PATH="$PATH:/usr/X11R6/bin"
    fi

These lines check the path to set: if root opens a shell (user ID 0), it is checked that `/sbin`, `/usr/sbin` and `/usr/local/sbin` are in the path. If not, they are added. It is checked for everyone that `/usr/X11R6/bin` is in the path.

    # No core files by default
    ulimit -S -c 0 > /dev/null 2>&1

All trash goes to `/dev/null` if the user doesn't change this setting.

    USER=`id -un`
    LOGNAME=$USER
    MAIL="/var/spool/mail/$USER"

    HOSTNAME=`/bin/hostname`
    HISTSIZE=1000

Here general variables are assigned their proper values.

    if [ -z "$INPUTRC" -a ! -f "$HOME/.inputrc" ]; then
        INPUTRC=/etc/inputrc
    fi

If the variable `INPUTRC` is not set, and there is no `.inputrc` in the user's home directory, then the default input control file is loaded.

    export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE INPUTRC

All variables are exported, so that they are available to other programs requesting information about your environment.

#### The profile.d directory

    for i in /etc/profile.d/*.sh ; do
        if [ -r $i ]; then
        	. $i
        fi
    done
    unset i

All readable shell scripts from the `/etc/profile.d` directory are read and executed. These do things like enabling color-ls, aliasing `vi` to `vim`, setting locales etc. The temporary variable `i` is unset to prevent it from disturbing shell behavior later on.

profile.d

#### .bash_profile example

Then `bash` looks for a `.bash_profile` in the user's home directory:

.bash_profile example

    debby:~> cat .bash_profile
    #################################################################
    #                                                               #
    #   .bash_profile file                                          #
    #                                                               #
    #   Executed from the bash shell when you log in.               #
    #                                                               #
    #################################################################

    source ~/.bashrc
    source ~/.bash_login

This very straight forward file instructs your shell to first read `~/.bashrc` and then `~/.bash_login`. You will encounter the `source` built-in shell command regularly when working in a shell environment: it is used to apply configuration changes to the current environment.

source

#### .bash_login example

The `~/.bash_login` file defines default file protection by setting the `umask` value, see . The `~/.bashrc` file is used to define a bunch of user-specific aliases and functions and personal environment variables. It first reads `/etc/bashrc`, which describes the default prompt (`PS1`) and the default umask value. After that, you can add your own settings. If no `~/.bashrc` exists, `/etc/bashrc` is read by default.

.bash_login example

#### /etc/bashrc example

Your `/etc/bashrc` file might look like this:

bashrc example

    debby:~> cat /etc/bashrc
    # /etc/bashrc

    # System wide functions and aliases
    # Environment stuff goes in /etc/profile

    # by default, we want this to get set.
    # Even for non-interactive, non-login shells.
    if [ `id -gn` = `id -un` -a `id -u` -gt 99 ]; then
    	umask 002
    else
    	umask 022
    fi

These lines set the `umask` value. Then, depending on the type of shell, the prompt is set:

    # are we an interactive shell?
    if [ "$PS1" ]; then
      if [ -x /usr/bin/tput ]; then
        if [ "x`tput kbs`" != "x" ]; then
    # We can't do this with "dumb" terminal
          stty erase `tput kbs`
        elif [ -x /usr/bin/wc ]; then
          if [ "`tput kbs|wc -c `" -gt 0 ]; then
    # We can't do this with "dumb" terminal
            stty erase `tput kbs`
          fi
        fi
      fi
      case $TERM in
    	xterm*)
    	if [ -e /etc/sysconfig/bash-prompt-xterm ]; then
    		PROMPT_COMMAND=/etc/sysconfig/bash-prompt-xterm
    	else
       PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME%%.*}:\
    ${PWD/$HOME/~}\007"'
    	fi
        ;;
    	*)
       [ -e /etc/sysconfig/bash-prompt-default ] && PROMPT_COMMAND=\
    /etc/sysconfig/bash-prompt-default
    	    ;;
        esac
        [ "$PS1" = "\\s-\\v\\\$ " ] && PS1="[\u@\h \W]\\$ "

        if [ "x$SHLVL" != "x1" ]; then # We're not a login shell
            for i in /etc/profile.d/*.sh; do
    	    if [ -x $i ]; then
    	        . $i
    	    fi
    	done
        fi
    fi

#### .bash_logout example

Upon logout, the commands in `~/.bash_logout` are executed, which can for instance clear the terminal, so that you have a clean window upon logging out of a remote session, or upon leaving the system console:

.bash_logout example

    debby:~> cat .bash_logout
    # ~/.bash_logout

    clear

Let's take a closer look at how these scripts work in the next section. Keep `info bash` close at hand.

### The Bash prompt

#### Introduction

The Bash prompt can do much more than displaying such simple information as your user name, the name of your machine and some indication about the present working directory. We can add other information such as the current date and time, number of connected users etc.

Before we begin, however, we will save our current prompt in another environment variable:

prompt backup

    [jerry@nowhere jerry]$ MYPROMPT=$PS1

    [jerry@nowhere jerry]$ echo $MYPROMPT
    [\u@\h \W]\$

    [jerry@nowhere jerry]$

When we change the prompt now, for example by issuing the command ``PS1`="->"`, we can always get our original prompt back with the command ``PS1`=`$MYPROMPT``. You will, of course, also get it back when you reconnect, as long as you just fiddle with the prompt on the command line and avoid putting it in a shell configuration file.

prompt configuration

#### Some examples

In order to understand these prompts and the escape sequences used, we refer to the Bash Info or man pages.

prompt examples

- `export `PS1`="[\t \j] "`

  Displays time of day and number of running jobs

- `export `PS1`="[\d][\u@\h \w] : "`

  Displays date, user name, host name and current working directory. Note that \W displays only base names of the present working directory.

- `export `PS1`="{\!} "`

  Displays history number for each command.

- `export `PS1`="\[\033[1;35m\]\u@\h\[\033[0m\] "`

  Displays user@host in pink.

- `export `PS1`="\[\033[1;35m\]\u\[\033[0m\] \[\033[1;34m\]\w\[\033[0m\] "`

  Sets the user name in pink and the present working directory in blue.

- `export `PS1`="\[\033[1;44m\]$USER is in \w\[\033[0m\] "`

  Prompt for people who have difficulties seeing the difference between the prompt and what they type.

- `export `PS1`="\[\033[4;34m\]\u@\h \w \[\033[0m\]"`

  Underlined prompt.

- `export `PS1`="\[\033[7;34m\]\u@\h \w \[\033[0m\] "`

  White characters on a blue background.

- `export `PS1`="\[\033[3;35m\]\u@\h \w \[\033[0m\]\a"`

  Pink prompt in a lighter font that alerts you when your commands have finished.

- `export `PS1`=...`

Variables are exported so the subsequently executed commands will also know about the environment. The prompt configuration line that you want is best put in your shell configuration file, `~/.bashrc`.

.bashrc

If you want, prompts can execute shell scripts and behave different under different conditions. You can even have the prompt play a tune every time you issue a command, although this gets boring pretty soon. More information can be found in the Bash-Prompt HOWTO.

### Shell scripts

#### What are scripts?

A shell script is, as we saw in the shell configuration examples, a text file containing shell commands. When such a file is used as the first non-option argument when invoking Bash, and neither the `-c` nor `-s` option is supplied, Bash reads and executes commands from the file, then exits. This mode of operation creates a non-interactive shell. When Bash runs a shell script, it sets the special parameter `0` to the name of the file, rather than the name of the shell, and the positional parameters (everything following the name of the script) are set to the remaining arguments, if any are given. If no additional arguments are supplied, the positional parameters are unset.

shell scripts

A shell script may be made executable by using the `chmod` command to turn on the execute bit. When Bash finds such a file while searching the `PATH` for a command, it spawns a sub-shell to execute it. In other words, executing

scripts chmod
`filename ARGUMENTS`

is equivalent to executing

`bash filename ARGUMENTS`

if filename is an executable shell script. This sub-shell reinitializes itself, so that the effect is as if a new shell had been invoked to interpret the script, with the exception that the locations of commands remembered by the parent (see `hash` in the Info pages) are retained by the child.

Most versions of UNIX make this a part of the operating system's command execution mechanism. If the first line of a script begins with the two characters #!, the remainder of the line specifies an interpreter for the program. Thus, you can specify `bash`, `awk`, `perl` or some other interpreter or shell and write the rest of the script file in that language.

The arguments to the interpreter consist of a single optional argument following the interpreter name on the first line of the script file, followed by the name of the script file, followed by the rest of the arguments. Bash will perform this action on operating systems that do not handle it themselves.

Bash scripts often begin with

script first line

    #! /bin/bash

(assuming that Bash has been installed in `/bin`), since this ensures that Bash will be used to interpret the script, even if it is executed under another shell.

#### Some simple examples

A very simple script consisting of only one command, that says hello to the user executing it:

script example

    [jerry@nowhere ~] cat hello.sh
    #!/bin/bash
    echo "Hello $USER"

The script actually consists of only one command, `echo`, which uses the value of ($) the `USER` environment variable to print a string customized to the user issuing the command.

Another one-liner, used for displaying connected users:

    #!/bin/bash
    who | cut -d " " -f 1 | sort -u

Here is a script consisting of some more lines, that I use to make backup copies of all files in a directory. The script first makes a list of all the files in the current directory and puts it in the variable `LIST`. Then it sets the name of the copy for each file, and then it copies the file. For each file, a message is printed:

    tille:~> cat bin/makebackupfiles.sh
    #!/bin/bash
    # make copies of all files in a directory
    LIST=`ls`
    for i in $LIST; do
    	ORIG=$i
    	DEST=$i.old
    	cp $ORIG $DEST
    	echo "copied $i"
    done

Just entering a line like `mv * *.old` won't work, as you will notice when trying this on a set of test files. An `echo` command was added in order to display some activity. `echo`'s are generally useful when a script won't work: insert one after each doubted step and you will find the error in no time.

The `/etc/rc.d/init.d` directory contains loads of examples. Let's look at this script that controls the fictive ICanSeeYou server:

script init script example

    #!/bin/sh
    # description: ICanSeeYou allows you to see networked people

    # process name: ICanSeeYou
    # pidfile: /var/run/ICanSeeYou/ICanSeeYou.pid
    # config: /etc/ICanSeeYou.cfg

    # Source function library.
    . /etc/rc.d/init.d/functions

    # See how (with which arguments) we were called.
    case "$1" in
    	start)
    		echo -n "Starting ICanSeeYou: "
    		daemon ICanSeeYou
    		echo
    		touch /var/lock/subsys/ICanSeeYou
    		;;
    	stop)
    		echo -n "Shutting down ICanSeeYou: "
    		killproc ICanSeeYou
    		echo
    		rm -f /var/lock/subsys/ICanSeeYou
    		rm -f /var/run/ICanSeeYou/ICanSeeYou.pid
    		;;
    	status)
    		status ICanSeeYou
    		;;
    	restart)
    		$0 stop
    		$0 start
    		;;
    	*)
    		echo "Usage: $0 {start|stop|restart|status}"
    		exit 1
    esac

    exit 0

First, with the `.` command (dot) a set of shell functions, used by almost all shell scripts in `/etc/rc.d/init.d`, is loaded. Then a `case` command is issued, which defines 4 different ways the script can execute. An example might be `ICanSeeYou start`. The decision of which case to apply is made by reading the (first) argument to the script, with the expression $1.

When no compliant input is given, the default case, marked with an asterisk, is applied, upon which the script gives an error message. The `case` list is ended with the `esac` statement. In the start case the server program is started as a daemon, and a process ID and lock are assigned. In the stop case, the server process is traced down and stopped, and the lock and the PID are removed. Options, such as the `daemon` option, and functions like `killproc`, are defined in the `/etc/rc.d/init.d/functions` file. This setup is specific to the distribution used in this example. The initscripts on your system might use other functions, defined in other files, or none at all.

Upon success, the script returns an exit code of zero to its parent.

This script is a fine example of using functions, which make the script easier to read and the work done faster. Note that they use `sh` instead of `bash`, to make them useful on a wider range of systems. On a Linux system, calling `bash` as `sh` results in the shell running in POSIX-compliant mode.

The `bash` man pages contain more information about combining commands, `for`- and `while`-loops and regular expressions, as well as examples. A comprehensible Bash course for system administrators and power users, with exercises, from the same author as this Introduction to Linux guide, is at http://tille.garrels.be/training/bash/. Detailed description of Bash features and applications is in the reference guide Advanced Bash Scripting.

## The graphical environment

### Introduction

The average user may not care too much about his login settings, but Linux offers a wide variety of flashy window and desktop managers for use under X, the graphical environment. The use and configuration of window managers and desktops is straightforward and may even resemble the standard MS Windows, Apple or UNIX CDE environment, although many Linux users prefer flashier desktops and fancier window managers. We won't discuss the user specific configuration here. Just experiment and read the documentation using the built-in Help functions these managers provide and you will get along fine.

environment graphical

We will, however, take a closer look at the underlying system.

### The X Window System

The X Window System is a network-transparent window system which runs on a wide range of computing and graphics machines. X Window System servers run on computers with bitmap displays. The X server distributes user input to and accepts output requests from several client programs through a variety of different interprocess communication channels. Although the most common case is for the client programs to be running on the same machine as the server, clients can be run transparently from other machines (including machines with different architectures and operating systems) as well. We will learn how to do this in on networking and remote applications.

X Window definition
X Window clients

X supports overlapping hierarchical sub-windows and text and graphics operations, on both monochrome and color displays. The number of X client programs that use the X server is quite large. Some of the programs provided in the core X Consortium distribution include:

X Window application overview

- `xterm`: a terminal emulator

- `twm`: a minimalistic window manager

- `xdm`: a display manager

- `xconsole`: a console redirect program

- `bitmap`: a bitmap editor

- `xauth`, `xhost` and `iceauth`: access control programs

- `xset`, `xmodmap` and many others: user preference setting programs

- `xclock`: a clock

- `xlsfonts` and others: a font displayer, utilities for listing information about fonts, windows and displays

- `xfs`: a font server

- ...

We refer again to the man pages of these commands for detailed information. More explanations on available functions can be found in the Xlib - C language X Interface manual that comes with your X distribution, the X Window System Protocol specification, and the various manuals and documentation of X toolkits. The `/usr/share/doc` directory contains references to these documents and many others.

Many other utilities, window managers, games, toolkits and gadgets are included as user-contributed software in the X Consortium distribution, or are available using anonymous FTP on the Internet. Good places to start are http://www.x.org and http://www.xfree.org.

Furthermore, all your graphical applications, such as your browser, your E-mail program, your image viewing programs, sound playing tools and so on, are all clients to your X server. Note that in normal operation, that is in graphical mode, X clients and the X server on Linux run on the same machine.

#### Display names

From the user's perspective, every X server has a display name in the form of:

X Window display names
`hostname:displaynumber.screennumber`

This information is used by the application to determine how it should connect to the X server and which screen it should use by default (on displays with multiple monitors):

- hostname: The host name specifies the name of the client machine to which the display is physically connected. If the host name is not given, the most efficient way of communicating to a server on the same machine will be used.

  X Window hostname

- displaynumber: The phrase display is usually used to refer to a collection of monitors that share a common key board and pointer (mouse, tablet, etc.). Most workstations tend to only have one keyboard, and therefore, only one display. Larger, multi-user systems, however, frequently have several displays so that more than one person can be doing graphics work at once. To avoid confusion, each display on a machine is assigned a display number (beginning at 0) when the X server for that display is started. The display number must always be given in a display name.

  X Window display number

- screen number: Some displays share a single keyboard and pointer among two or more monitors. Since each monitor has its own set of windows, each screen is assigned a screen number (beginning at 0) when the X server for that display is started. If the screen number is not given, screen 0 will be used.

  X Window screen number

On POSIX systems, the default display name is stored in your `DISPLAY` environment variable. This variable is set automatically by the `xterm` terminal emulator. However, when you log into another machine on a network, you might need to set `DISPLAY` by hand to point to your display, see .

DISPLAY

More information can be found in the X man pages.

#### Window and desktop managers

The layout of windows on the screen is controlled by special programs called window managers. Although many window managers will honor geometry specifications as given, others may choose to ignore them (requiring the user to explicitly draw the window's region on the screen with the pointer, for example).

window manager

Since window managers are regular (albeit complex) client programs, a variety of different user interfaces can be built. The X Consortium distribution comes with a window manager named `twm`, but most users prefer something more fancy when system resources permit. Sawfish and Enlightenment are popular examples which allow each user to have a desktop according to mood and style.

A desktop manager makes use of one window manager or another for arranging your graphical desktop in a convenient way, with menubars, drop-down menus, informative messages, a clock, a program manager, a file manager and so on. Among the most popular desktop managers are Gnome and KDE, which both run on almost any Linux distribution and many other UNIX systems.

KDE applications in Gnome/Gnome applications in KDE

You don't need to start your desktop in KDE in order to be able to run KDE applications. If you have the KDE libraries installed (the kdelibs package), you can run these applications from the Gnome menus or start them from a Gnome terminal.

Running Gnome applications in a KDE environment is a bit more tricky, because there is no single set of base-libraries in Gnome. However, the dependencies and thus extra packages you might have to install will become clear when running or installing such an application.

### X server configuration

The X distribution that used to come with Linux, XFree86, uses the configuration file `XF86Config` for its initial setup. This file configures your video card and is searched for in a number of locations, although it is usually in `/etc/X11`.

X Window configuration

If you see that the file `/etc/X11/XF86Config` is present on your system, a full description can be found in the Info or man pages about `XF86Config`.

XF86Config

Because of licensing issues with XFree86, newer systems usually come with the X.Org distribution of the X server and tools. The main configuration file here is `xorg.conf`, usually also in `/etc/X11`. The file consists of a number of sections that may occur in any order. The sections contain information about your monitor, your video adaptor, the screen configuration, your keyboard etcetera. As a user, you needn't worry too much about what is in this file, since everything is normally determined at the time the system is installed.

X.Org
xorg.conf

Should you need to change graphical server settings, however, you can run the configuration tools or edit the configuration files that set up the infrastructure to use the XFree86 server. See the man pages for more information; your distribution might have its own tools. Since misconfiguration may result in unreadable garbage in graphical mode, you may want to make a backup copy of the configuration file before attempting to change it, just to be on the safe side.

## Region specific settings

### Keyboard setup

Setting the keyboard layout is done using the `loadkeys` command for text consoles. Use your local X configuration tool or edit the Keyboard section in `XF86Config` manually to configure the layout for graphical mode. The `XkbdLayout` is the one you want to set:

keyboard layout
loadkeys
XF86Config KeyBoard
keyboard XkbdLayout

        XkbLayout       "us"

This is the default. Change it to your local settings by replacing the quoted value with any of the names listed in the subdirectories of your `keymaps` directory. If you can't find the keymaps, try displaying their location on your system issuing the command

`locate `keymaps``

It is possible to combine layout settings, like in this example:

    Xkblayout      "us,ru"

Make a backup of the `/etc/X11/XF86Config` file before editing it! You will need to use the root account to do this.

Log out and reconnect in order to reload X settings.

The Gnome Keyboard Applet enables real-time switching between layouts; no special pemissions are needed for using this program. KDE has a similar tool for switching between keyboard layouts.

KeyBoard switching layouts

### Fonts

Use the `setfont` tool to load fonts in text mode. Most systems come with a standard `inputrc` file which enables combining of characters, such as the French é (meta characters). The system admin should then add the line

fonts configuration
setfont
inputrc

    export INPUTRC="/etc/inputrc"

to the `/etc/bashrc` file.

### Date and time zone

Setting time information is usually done at installation time. After that, it can be kept up to date using an NTP (Network Time Protocol) client. Most Linux systems run `ntpd` by default:

date configuration
NTP

    debby:~> ps -ef | grep ntpd
    ntp      24678     1  0  2002 ?        00:00:33 ntpd -U ntp

You can run `ntpdate` manually to set the time, on condition that you can reach a time server. The `ntpd` daemon should not be running when you adjust the time using `ntpdate`. Use a time server as argument to the command:

ntpdate

    root@box:~# ntpdate 10.2.5.200
    26 Oct 14:35:42 ntpdate[20364]: adjust time server 10.2.5.200 offset
     -0.008049 sec

See your system manual and the documentation that comes with the NTP package. Most desktop managers include tools to set the system time, providing that you have access to the system administrator's account.

For setting the time zone correct, you can use `tzconfig` or `timezone` commands. Timezone information is usually set during the installation of your machine. Many systems have distribution-specific tools to configure it, see your system documentation.

time zone configuration
tzconfig
timezone

### Language

If you'd rather get your messages from the system in Dutch or French, you may want to set the `LANG` and `LANGUAGE` environment variables, thus enabling locale support for the desired language and eventually the fonts related to character conventions in that language.

messages language
LANG
LANGUAGE

With most graphical login systems, such as `gdm` or `kdm`, you have the possibility to configure these language settings before logging in.

login language configuration

Note that on most systems, the default tends to be en_US.UTF-8 these days. This is not a problem, because systems where this is the default, will also come with all the programs supporting this encoding. Thus, `vi` can edit all the files on your system, `cat` won't behave strange and so on.

character encoding

Trouble starts when you connect to an older system not supporting this font encoding, or when you open a UTF-8 encoded file on a system supporting only 1-byte character fonts. The `recode` utility might come in handy to convert files from one character set to another. Read the man pages for an overview of features and usage. Another solution might be to temporarily work with another encoding definition, by setting the `LANG` environment variable:

UTF-8
recode

    debby:~> acroread /var/tmp/51434s.pdf
    Warning: charset "UTF-8" not supported, using "ISO8859-1".
    Aborted

    debby:~> set | grep UTF
    LANG=en_US.UTF-8

    debby:~> export LANG=en_US

    debby:~> acroread /var/tmp/51434s.pdf
    <--new window opens-->

Refer to the Mozilla web site for guidance on how to get Firefox in your language. The OpenOffice.org web site has information on localization of your OpenOffice.org suite.

### Country-specific Information

The list of HOWTOs contains references to Bangla, Belarusian, Chinese, Esperanto, Finnish, Francophone, Hebrew, Hellenic, Latvian, Polish, Portugese, Serbian, Slovak, Slovenian, Spanish, Thai and Turkish localization instructions.

## Installing new software

### General

Most people are surprised to see that they have a running, usable computer after installing Linux; most distributions contain ample support for video and network cards, monitors and other external devices, so there is usually no need to install extra drivers. Also common tools such as office suites, web browsers, E-mail and other network client programs are included in the main distributions. Even so, an initial installation might not meet your requirements.

If you just can't find what you need, maybe it is not installed on your system. It may also be that you have the required software, but it does not do what it is supposed to do. Remember that Linux moves fast, and software improves on a daily basis. Don't waste your time troubleshooting problems that might already be resolved.

software installing

You can update your system or add packages to it at any time you want. Most software comes in packages. Extra software may be found on your installation CDs or on the Internet. The website of your Linux distribution is a good place to start looking for additional software and contains instructions about how to install it on your type of Linux, see . Always read the documentation that comes with new software, and any installation guidelines the package might contain. All software comes with a `README` file, which you are very strongly advised to read.

README

### Package formats

#### RPM packages

##### What is RPM?

RPM, the RedHat Package Manager, is a powerful package manager that you can use to install, update and remove packages. It allows you to search for packages and keeps track of the files that come with each package. A system is built-in so that you can verify the authenticity of packages downloaded from the Internet. Advanced users can build their own packages with RPM.

packages RPM

An RPM package consists of an archive of files and meta-data used to install and erase the archive files. The meta-data includes helper scripts, file attributes, and descriptive information about the package. Packages come in two varieties: binary packages, used to encapsulate software to be installed, and source packages, containing the source code and recipe necessary to produce binary packages.

Many other distributions support RPM packages, among the popular ones RedHat Enterprise Linux, Mandriva (former Mandrake), Fedora Core and SuSE Linux. Apart from the advice for your distribution, you will want to read `man rpm`.

##### RPM examples

Most packages are simply installed with the upgrade option, `-U`, whether the package is already installed or not. The RPM package contains a complete version of the program, which overwrites existing versions or installs as a new package. The typical usage is as follows:

packages install RPM
RPM installation
`rpm `-Uvh` `/path/to/rpm-package(s)``

The `-v` option generates more verbose output, and `-h` makes `rpm` print a progress bar:

    [root@jupiter tmp]# rpm -Uvh totem-0.99.5-1.fr.i386.rpm
    Preparing...                ########################################### [100%]
       1:totem                  ########################################### [100%]
    [root@jupiter tmp]#

New kernel packages, however, are installed with the install option `-i`, which does not overwrite existing version(s) of the package. That way, you will still be able to boot your system with the old kernel if the new one does not work.

You can also use `rpm` to check whether a package is installed on your system:

rpm
RPM search packages

    [david@jupiter ~] rpm -qa | grep vim
    vim-minimal-6.1-29
    vim-X11-6.1-29
    vim-enhanced-6.1-29
    vim-common-6.1-29

Or you can find out which package contains a certain file or executable:

RPM search files

    [david@jupiter ~] rpm -qf /etc/profile
    setup-2.5.25-1

    [david@jupiter ~] which cat
    cat is /bin/cat

    [david@jupiter ~] rpm -qf /bin/cat
    coreutils-4.5.3-19

Note that you need not have access to administrative privileges in order to use `rpm` to query the RPM database. You only need to be root when adding, modifying or deleting packages.

Below is one last example, demonstrating how to uninstall a package using `rpm`:

RPM remove package

    [root@jupiter root]# rpm -e totem
    [root@jupiter root]#

Note that uninstalling is not that verbose by default, it is normal that you don't see much happening. When in doubt, use `rpm `-qa`` again to verify that the package has been removed.

RPM can do much more than the couple of basic functions we discussed in this introduction; the RPM HOWTO contains further references.

#### DEB (.deb) packages

##### What are Debian packages?

This package format is the default on Debian GNU/Linux, where `dselect`, and, nowadays more common, `aptitude`, is the standard tool for managing the packages. It is used to select packages that you want to install or upgrade, but it will also run during the installation of a Debian system and help you to define the access method to use, to list available packages and to configure packages.

packages DEB
dselect
aptitude

The Debian web site contains all information you need, including a dselect Documentation for Beginners.

According to the latest news, the Debian package format is becoming more and more popular. At the time of this writing, 5 of the top-10 distributions use it. Also `apt-get` (see is becoming extremely popular, also on non-DEB systems.

apt-get

##### Examples with DEB tools

Checking whether a package is installed is done using the `dpkg` command. For instance, if you want to know which version of the Gallery software is installed on your machine:

    nghtwsh@gorefest:~$ dpkg -l *gallery*
    Desired=Unknown/Install/Remove/Purge/Hold
    | Status=Not/Installed/Config-files/Unpacked/Failed-config/Half-installed
    |/ Err?=(none)/Hold/Reinst-required/X=both-problems (Status,Err: uppercase=bad)
    ||/ Name           Version        Description
    +++-==============-==============-============================================
    ii  gallery        1.5-1sarge2    a web-based photo album written in php

The ii prefix means the package is installed. Should you see un as a prefix, that means that the package is known in the list that your computer keeps, but that it is not installed.

Searching which package a file belongs to is done using the `-S` to `dpkg`:

    nghtwsh@gorefest:~$ dpkg -S /bin/cat
    coreutils: /bin/cat

More information can be found in the Info pages for `dpkg`.

#### Source packages

The largest part of Linux programs is Free/Open Source, so source packages are available for these programs. Source files are needed for compiling your own program version. Sources for a program can be downloaded from its web site, often as a compressed tarball (`program-version.tar.gz` or similar). For RPM-based distributions, the source is often provided in the `program-version.src.rpm`. Debian, and most distributions based on it, provide themselves the adapted source which can be obtained using `apt-get source`.

packages source

Specific requirements, dependencies and installation instructions are provided in the `README` file. You will probably need a C compiler, `gcc`. This GNU C compiler is included in most Linux systems and is ported to many other platforms.

### Automating package management and updates

#### General remarks

The first thing you do after installing a new system is applying updates; this applies to all operating systems and Linux is not different.

The updates for most Linux systems can usually be found on a nearby site mirroring your distribution. Lists of sites offering this service can be found at your distribution's web site, see .

system updates

Updates should be applied regularly, daily if possible - but every couple of weeks would be a reasonable start. You really should try to have the most recent version of your distribution, since Linux changes constantly. As we said before, new features, improvements and bug fixes are supplied at a steady rhythm, and sometimes important security problems are addressed.

packages updates

The good news is that most Linux distributions provide tools so that you don't have to upgrade tens of packages daily by hand. The following sections give an overview of package manager managers. There is much more to this subject, even regular updates of source packages is manageable automatically; we only list the most commonly known systems. Always refer to the documentation for your specific distribution for advised procedures.

#### APT

The Advanced Package Tool is a management system for software packages. The command line tool for handling packages is `apt-get`, which comes with an excellent man page describing how to install and update packages and how to upgrade singular packages or your entire distribution. APT has its roots in the Debian GNU/Linux distribution, where it is the default manager for the Debian packages. APT has been ported to work with RPM packages as well. The main advantage of APT is that it is free and flexible to use. It will allow you to set up systems similar to the distribution specific (and in some cases commercial) ones listed in the next sections.

packages APT
apt-get

Generally, when first using `apt-get`, you will need to get an index of the available packages. This is done using the command

apt-get update package list
`apt-get update`

After that, you can use `apt-get` to upgrade your system:

apt-get upgrade system
`apt-get upgrade`

Do this often, it's an easy way to keep your system up-to-date and thus safe.

Apart from this general usage, `apt-get` is also very fast for installing individual packages. This is how it works:

apt-get installing packages

    [david@jupiter ~] su - -c "apt-get install xsnow"
    Password:
    Reading Package Lists... Done
    Building Dependency Tree... Done
    The following NEW packages will be installed:
      xsnow
    0 packages upgraded, 1 newly installed, 0 removed and 3 not upgraded.
    Need to get 33.6kB of archives.
    After unpacking 104kB of additional disk space will be used.
    Get:1 http://ayo.freshrpms.net redhat/9/i386/os xsnow 1.42-10 [33.6kB]
    Fetched 33.6kB in 0s (106kB/s)
    Executing RPM (-Uvh)...
    Preparing...                ########################################### [100%]
       1:xsnow                  ########################################### [100%]

Note the `-c` option to the `su` command, which indicates to the root shell to only execute this command, and then return to the user's environment. This way, you cannot forget to quit the root account.

If there are any dependencies on other packages, `apt-get` will download and install these supporting packages.

More information can be found in the APT HOWTO.

#### Systems using RPM packages

Update Agent, which originally only supported RedHat RPM packages, is now ported to a wider set of software, including non-RedHat repositories. This tool provides a complete system for updating the RPM packages on a RedHat or Fedora Core system. On the command line, type `up2date` to update your system. On the desktop, by default a small icon is activated, telleng you whether or not there are updates available for your system.

packages Update Agent
up2date

Yellowdog's Updater Modified (`yum`) is another tool that recently became more popular. It is an interactive but automated update program for installing, updating or removing RPM packages on a system. It is the tool of choice on Fedora systems.

packages yum
yum

On SuSE Linux, everything is done with YaST, Yet another Setup Tool, which supports a wide variety of system administration tasks, among which updating RPM packages. Starting from SuSE Linux 7.1 you can also upgrade using a web interface and YOU, Yast Online Update.

packages YaST
packages YOU

Mandrake Linux and Mandriva provide so-called URPMI tools, a set of wrapper programs that make installing new software easier for the user. These tools combine with RPMDrake and MandrakeUpdate to provide everything needed for smooth install and uninstall of software packages. MandrakeOnline offers an extended range of services and can automatically notify administrators when updates are available for your particular Mandrake system. See `man urpmi`, among others, for more info.

packages URPMI

Also the KDE and Gnome desktop suites have their own (graphical) versions of package managers.

### Upgrading your kernel

Most Linux installations are fine if you periodically upgrade your distribution. The upgrade procedure will install a new kernel when needed and make all necessary changes to your system. You should only compile or install a new kernel manually if you need kernel features that are not supported by the default kernel included in your Linux distribution.

kernel upgrade
packages kernel

Whether compiling your own optimized kernel or using a pre-compiled kernel package, install it in co-existence with the old kernel until you are sure that everything works according to plan.

Then create a dual boot system that will allow you to choose which kernel to boot by updating your boot loader configuration file `grub.conf`. This is a simple example:

grub.conf example

    # grub.conf generated by anaconda
    #
    # Note that you do not have to rerun grub after making config changes.
    # NOTICE:  You have a /boot partition.  This means that
    #          all kernel and initrd paths are relative to /boot/, e.g.
    #          root (hd0,0)
    #          kernel /vmlinuz-version ro root=/dev/hde8
    #          initrd /initrd-version.img
    #boot=/dev/hde
    default=0
    timeout=10
    splashimage=(hd0,0)/grub/splash.xpm.gz
    title Red Hat Linux new (2.4.9-31)
    	root (hd0,0)
    	kernel /vmlinuz-2.4.9-31 ro root=/dev/hde8
    	initrd /initrd-2.4.9-31.img
    title old-kernel
            root (hd0,0)
            kernel /vmlinuz-2.4.9-21 ro root=/dev/hde8
            initrd /initrd-2.4.9-21.img

After the new kernel has proven to work, you may remove the lines for the old one from the GRUB config file, although it is best to wait a couple of days just to be sure.

### Installing extra packages from the installation CDs

#### Mounting a CD

This is basically done in the same way as installing packages manually, except that you have to append the file system of the CD to your machine's file system to make it accessible. On most systems, this will be done automatically upon insertion of a CD in the drive because the `automount` daemon is started up at boot time. If your CD is not made available automatically, issue the `mount` command in a terminal window. Depending on your actual system configuration, a line similar to this one will usually do the trick:

packages install from CD
automount
mount
mount mount a CD

`mount `/dev/cdrom /mnt/cdrom``

On some systems, only root can mount removable media; this depends on the configuration.

For automation purposes, the CD drive usually has an entry in `/etc/fstab`, which lists the file systems and their mount points, that make up your file system tree. This is such a line:

/etc/fstab

    [david@jupiter ~] grep cdrom /etc/fstab
    /dev/cdrom	/mnt/cdrom	iso9660		noauto,owner,ro 0 0

This indicates that the system will understand the command `mount `/mnt/cdrom``. The `noauto` option means that on this system, CDs are not mounted at boot time.

You may even try to right click on the CD icon on your desktop to mount the CD if your file manager doesn't do it for you. You can check whether it worked issuing the `mount` command with no arguments:

mount example

    [david@jupiter ~] mount | grep cdrom
    /dev/cdrom on /mnt/cdrom type iso9660 (ro,nosuid,nodev)

#### Using the CD

After mounting the CD, you can change directories, usually to the mount point `/mnt/cdrom`, where you can access the content of the CD-ROM. Use the same commands for dealing with files and directories as you would use for files on the hard disk.

CD using

#### Ejecting the CD

In order to get the CD out of the drive after you've finished using it, the file system on the CD should be unused. Even being in one of the subdirectories of the mount point, `/mnt/cdrom` in our example, will be considered as using the file system, so you should get out of there. Do this for instance by typing `cd` with no arguments, which will put you back in your home directory. After that, you can either use the command

CD eject
`umount `/mnt/cdrom``

or

`eject cdrom`

Blocked drives

NEVER force the drive. The trick with the paperclip is a bad idea, because this will eventually expunge the CD, but your system will think the CD is still there because normal procedures were not followed. Chances are likely that you will have to reboot to get the system back in a consistent state.

If you keep getting device busy messages, check first that all shell sessions have left the CD file system and that no graphical applications are using it anymore. When in doubt, use the `lsof` tool to trace down the process(es) still using the CD resource.

## Summary

When everything has its place, that means already half the work is done.

While keeping order is important, it is equally important to feel at home in your environment, whether text or graphical. The text environment is controlled through the shell setup files. The graphical environment is primarily dependent on the X server configuration, on which a number of other applications are built, such as window and desktop managers and graphical applications, each with their own config files. You should read the system and program specific documentation to find out about how to configure them.

Regional settings such as keyboard setup, installing appropriate fonts and language support are best done at installation time.

Software is managed either automatically or manually using a package system.

The following commands were introduced in this chapter:

New commands in chapter 7: Making yourself at home

Command | Meaning
--- | ---
`aptitude` | Manage packages Debian-style.
`automount` | automatically include newly inserted file systems.
`dpkg` | Debian package manager.
`dselect` | Manage packages Debian-style.
`loadkeys` | Load keyboard configuration.
`lsof` | Identify processes.
`mount` | Include a new file system into the existing file system tree.
`ntpdate` | Set the system time and date using a time server.
`quota` | Display information about allowed disk space usage.
`recode` | Convert files to another character set.
`rpm` | Manage RPM packages.
`setfont` | Choose a font.
`timezone` | Set the timezone.
`tzconfig` | Set the timezone.
`ulimit` | Set or display resource limits.
`up2date` | Manage RPM packages.
`urpmi` | Manage RPM packages.
`yum` | Manage RPM packages.

## Exercises

### Shell environment

- Print out your environment settings. Which variable may be used to store the CPU type of your machine?

- Make a script that can say something on the lines of hello, world. Give it appropriate permissions so it can be run. Test your script.

- Create a directory in your home directory and move the script to the new directory. Permanently add this new directory to your search path. Test that the script can be executed without giving a path to its actual location.

- Create subdirectories in your home directory to store various files, for instance a directory `music` to keep audio files, a directory `documents` for your notes, and so on. And use them!

- Create a personalized prompt.

- Display limits on resource usage. Can you change them?

- Try to read compressed man pages without decompressing them first.

- Make an alias `lll` which actually executes `ls `-la``.

- Why does the command `tail `testfile` > `testfile`` not work?

- Mount a data CD, such as your Linux installation CD, and have a look around. Don't forget to unmount when you don't need it anymore.

- The script from is not perfect. It generates errors for files that are directories. Adapt the script so that it only selects plain files for copying. Use `find` to make the selection. Do not forget to make the script executable before you try to run it.

### Graphical environment

- Try all the mouse buttons in different regions (terminal, background, task bar).

- Explore the menus.

- Customize your terminal window.

- Use the mouse buttons to copy and paste text from one terminal to another.

- Find out how to configure your window manager; try different workspaces (virtual screens).

- Add an applet, such as a load monitor, to the task bar.

- Apply a different theme.

- Enable the so-called sloppy focus - this is when a window is activated by just moving the mouse over it, so that you do not need to click the window in order to be able to use it.

- Switch to a different window manager.

- Log out and select a different session type, like KDE if you were using Gnome before. Repeat the previous steps.