Next Previous Contents

3. Software Configuration

These are the the configuration files we are going to custimise: /etc/profile /etc/bashrc .bashrc .bash_profile .inputrc .less .lessrc .xinitrc .fvwmrc .fvwm2rc95 .Xmodmap .Xdefaults .jedrc. .abbrevs.sl .joerc .emacs . Don't add users until you have completed your system configuration; you'll put the dot files in /etc/skel.

3.1 bash(1)

To tailor bash's behaviour, these are the main files to edit:

Examples of these files are shown below. First, the most important: /etc/profile. It's used to configure a lot of features in your Linux box, as you will see in the following sections.


# /etc/profile

# System wide environment and startup programs
# Functions and aliases go in /etc/bashrc

# This file sets up the following features:
#
#   o path
#   o prompts
#   o a few environment variables
#   o colour ls
#   o less
#
# Users can override these settings and/or add others in their
# $HOME/.bash_profile

# set a decent path

echo $PATH | grep X11R6 > /dev/null
if [ $? = 1 ] ; then   # add entries to the path
  PATH="$PATH:/usr/X11R6/bin:$HOME/bin:."
fi

# notify the user: login or non-login shell. If login, the prompt is
# coloured in blue; otherwise in magenta. Root's prompt is red.

USER=`whoami`
if [ $LOGNAME = $USER ] ; then
  COLOUR=44
else
  COLOUR=45
fi

if [ $USER = 'root' ] ; then
  COLOUR=41
fi

# put a real escape character instead of ^[. To do this:
# emacs: ^Q ESC   vi: ^V ESC   joe: ` 0 2 7   jed: ` ESC
# Remove `;1' if you don't like the `bold' attribute.
ESC=^[
PS1='$ESC[$COLOUR;37;1m$USER:$ESC[37;40;1m\w\$ '
PS2="Continue> "

# no core dumps, please

ulimit -c 0   

# set umask

if [ `id -gn` = `id -un` -a `id -u` -gt 14 ]; then
  umask 002
else
  umask 022
fi

# a few variables

USER=`id -un`
LOGNAME=$USER
MAIL="/var/spool/mail/$USER"
EDITOR=jed
HOSTNAME=`/bin/hostname`
HISTSIZE=1000
HISTFILESIZE=1000
export PATH PS1 PS2 USER LOGNAME MAIL EDITOR HOSTNAME HISTSIZE HISTFILESIZE

# enable colour ls

eval `dircolors /etc/DIR_COLORS -b`
export LS_OPTIONS='-F -s -T 0 --color=tty'

# customise less

LESS='-M-Q'
LESSEDIT="%E ?lt+%lt. %f"
LESSOPEN="| lesspipe.sh %s"
VISUAL=jed
LESSCHARSET=latin1
export LESS LESSEDIT LESSOPEN VISUAL LESSCHARSET

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

This is a sample /etc/bashrc:


# /etc/bashrc

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

alias which="type -path"
alias d="ls"
alias dir="d"

This is a sample .bashrc:


# $HOME/.bashrc
# Source global definitions

if [ -f /etc/bashrc ]; then
  . /etc/bashrc
fi

# this is needed to notify the user that they are in non-login shell

if [ "$GET_PS1" = "" ] ; then
  COLOUR=45
# put a real escape character instead of ^[
  ESC=^[
  PS1='$ESC[$COLOUR;37m`whoami`:$ESC[37;40m\w\$ '
  export PS1
fi

# aliases

alias cp='cp -i'
alias l=less
alias lyx='lyx -width 900 -height 700'
alias mv='mv -i'
alias rm='rm -i'
alias x=startx

# A few useful functions

inst() # Install a .tar.gz archive in the current directory.
{ gzip -dc $1 | tar xvf - }

cz() # List the contents of a .zip archive.
{ unzip -l $* }

ctgz() # List the contents of a .tar.gz archive.
{
  for file in $* ; do
    gzip -dc ${file} | tar tf -
  done
}

tgz() # Create a .tgz archive a la zip.
{
  name=$1 ; tar -cvf $1 ; shift
  tar -rf ${name} $*
  gzip -S .tgz ${name}
}

This is a sample .bash_profile:


# $HOME/.bash_profile

# User specific environment and startup programs
# This file contains user-defined settings that override
# those in /etc/profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
  GET_PS1="NO"  # don't change the prompt colour
  . ~/.bashrc
fi
    
# set a few `default' directories
export CDPATH="$CDPATH:$HOME:$HOME/text:$HOME/text/geology"

# fix rxvt 2.45 backspace
if [ "$COLORTERM" != "" ] ; then
  stty erase ^?
  ESC=^[  # put a real escape character instead of ^[
  echo -n "$ESC[36l"
fi

This is a sample .inputrc:


# $HOME/.inputrc

# key bindings

"\e[1~": beginning-of-line
"\e[3~": delete-char
"\e[4~": end-of-line
# (F1 .. F5) are "\e[[A" ... "\e[[E"
"\e[[A": "info \C-m"

set bell-style visible          # please don't beep
set meta-flag On                # allow 8-bit input (i.e, accented letters)
set convert-meta Off            # don't strip 8-bit characters
set output-meta On              # display 8-bit characters correctly
set horizontal-scroll-mode On   # scroll long command lines
set show-all-if-ambiguous On    # after TAB is pressed

To make the backspace and delete keys work correctly in in xterm and other X11 applications, the following is also needed:

rxvt is a wee bit more complicated, as some compile--time options influence its behaviour. See the above .bash_profile.

More info in bash(1) and readline(3) man pages.

Don't expect every application to work correctly! If you run joe in xterm, for instance, some keys won't work; the same holds for versions of rxvt older than 2.21.

3.2 ls(1)

ls can display directory listings using colours to highlight different file types. To enable this feature, add these lines to /etc/profile:

eval `dircolors /etc/DIR_COLORS -b`
export LS_OPTIONS='-F -T 0 --color=tty'

(If you don't have the file /etc/DIR_COLORS, remove the reference to it in the first line.) This sets the environment variable LS_COLORS that contains the colour list set up in /etc/DIR_COLORS. Note: don't ask me why, but this won't work with rxvt older than v. 2.21; use some flavour of xterm instead. It looks like rxvt has a bug that prevents it from inheriting the environment correctly in some circumstances.

Caldera's ls doesn't have colours, but there's an equivalent color-ls. Add this in /etc/bashrc:

alias ls="color-ls $LS_OPTIONS"

3.3 less(1)

With this excellent pager you can browse not only plain text files, but also gzip compressed, tar and zip archives, man pages, and what have you. Its configuration involves a few steps:

3.4 emacs(1)

I don't use emacs, so I have only one piece of advice to give you. Some emacs distributions don't come preconfigured for colours and syntax highlighting. Write this in your .emacs:

(global-font-lock-mode t)
(setq font-lock-maximum-decoration t)

This only works in X11. I'll leave it to you to peruse all of emacs' documentation to find out how to tailor it to your needs---potentially, it can take months of hacking...

3.5 joe(1)

Some people report that joe works with colours under X11, but not in tty. In addition, some special keys don't work. To my knowledge, no one has found a solution to the former small nag; someone suggested hacking on /etc/termcap.

If you experience that problem, a quick and dirty (and inelegant) solution is this:

~$ export TERM=vt100
~$ joe myfile
   (edit your file)
~$ export TERM=linux

3.6 jed(1)

This is my favourite editor: it does what I need, it's lighter and easier to configure than emacs, and IMHO emulates other editors quite better. Many users at my university want jed to emulate EDT, VMS' system editor.

jed's configuration files are .jedrc and /usr/lib/jed/lib/*; the former can be adapted from jed.rc in the latter directory.

3.7 efax(1)

This package is probably the most convenient for simple sending/receiving of faxes. You'll have to tailor the script /usr/bin/fax; easy job, but a couple of quirks caused me quite an headache:

3.8 TeX and Friends

I'll assume you have the teTeX distribution. Just a couple of things here:

3.9 PPP

I'll take it for granted that your kernel has PPP + TCP/IP support compiled in, that loopback is enabled, and that you already have the pppd package correctly installed and suid root. Obviously, your ISP must support PPP.

There are now two ways to get PPP to work: a) manual configuration, and b) a configuration program that automagically sees to it. Whichever option you choose, have the following information on hand:

Manual configuration is a drudgery. It's about editing files and writing scripts; not too much work, but it's easy to make mistakes and newcomers are often intimidated. The PPP HOWTO is there for you. Alternatively, there are tools that ask for the information above and do all the work.

You'll be surely better off if you reach out for a friend who's already connected and download one of the following nice tools:

3.10 POP Client

To retrieve your mail from a POP server, you use a POP client like fetchpop or fetchmail. The latter is more advanced, and is probably the only option if your ISP's PPP server can't deal with the command LAST. They're available on ftp://sunsite.unc.edu/pub/Linux/system/mail/pop.

To configure these clients:

3.11 X Window System

Once you've managed to make X work (right video card etc.), there are endless possibilities of configuration; it depends on the window manager you use. In any case, it's all down to editing one or more ASCII files in your home directory. As for the window manager:

In addition, make sure you have a proper .xinitrc. An example:

#!/bin/sh

# $HOME/.xinitrc

# set a few keys correctly

usermodmap=$HOME/.Xmodmap 
xmodmap $usermodmap

xset s noblank  # turn off the screen saver
xset s 300 2    # screen saver start after 5 min
xsetroot -solid "medium blue" &

# rxvt saves a lot of memory, but versions older than 2.21 have bugs
# affecting the keys and the way the environment is inherited. Upgrade 
# or use xterm instead.

xterm -ls -bg black -fg white -sb -sl 500 -j -ls -fn 10x20 -fb 10x20bold \
-title "Color xterm" -geometry 80x25+150+0 &

fvwm95-2

3.12 Fortran

In my experience, if you need Fortran a good alternative to g77 is the Fortran-to-C translator f2c and the front end yaf77.

Get yaf77-X.Y.tgz from ftp://sunsite.unc.edu/pub/Linux/devel/lang/fortran .

3.13 Users' Configurations

It's a good idea to let new users have a few configuration files ready when they first log in. Put the following files in /etc/skel: .bashrc .bash_profile .bash_logout .inputrc .less .xinitrc .fvwmrc .fvwm2rc95 .Xmodmap .Xdefaults .jedrc .abbrevs.sl. joerc .emacs

Note that .pinerc can't be fully tailored; make sure that at least the fields user-domain, smtp-server, and nntp-server are properly set up.

3.14 Upgrading

If you upgrade your machine, remember to save a few additional files beforehand. Some of them are: /etc/X11/XF86Config, /usr/bin/fax, ...


Next Previous Contents