These are the the configuration files we are going to custimise:
/etc/profile /etc/bashrc .bashrc
.bashrc .bash_profile .bash_logout .inputrc .less .lessrc .xinitrc
.fvwmrc .fvwm2rc95 .Xmodmap .Xmodmap.num .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.
Arguably, the most important piece of software after the kernel. To tailor
bash
's behaviour, these are the main files to edit:
$HOME/.bashrc
contains user aliases and functions;
$HOME/.bash_profile
contains user environment
stuff and startup programs;
$HOME/.inputrc
contains key bindings and other bits.
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. Please look out for reverse quotes!
# /etc/profile # System wide environment and startup programs # Functions and aliases go in /etc/bashrc # This file sets up the following features and programs: # # o path # o prompts # o a few environment variables # o colour ls # o less # o rxvt # # Users can override these settings and/or add others in their # $HOME/.bash_profile # set a decent path (including Kde) PATH="$PATH:/usr/X11R6/bin:/opt/kde/bin:$HOME/bin:." # notify the user: login or non-login shell. If login, the prompt is # coloured in blue; otherwise in magenta. Root's prompt is red. # See the Colour-ls mini HOWTO for an explanation of the escape codes. USER=`whoami` if [ $LOGNAME = $USER ] ; then COLOUR=44 # blue else COLOUR=45 # magenta fi if [ $USER = 'root' ] ; then COLOUR=41 # red PATH="$PATH:/usr/local/bin" fi ESC="\033" STYLE=';1m' # bold; choose which one to use # STYLE='m' # plain PS1="\[$ESC[$COLOUR;37$STYLE\]$USER:\[$ESC[37;40$STYLE\]\w\\$ " PS2="> " # 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" NNTPSERVER=news.iol.it # put your own here VISUAL=jed EDITOR=jed HOSTNAME=`/bin/hostname` HISTSIZE=1000 HISTFILESIZE=1000 export PATH PS1 PS2 USER LOGNAME MAIL NNTPSERVER export VISUAL EDITOR HOSTNAME HISTSIZE HISTFILESIZE # enable colour ls eval `dircolors /etc/DIR_COLORS -b` export LS_OPTIONS='-s -F -T 0 --color=yes' # customize less LESS='-M-Q' LESSEDIT="%E ?lt+%lt. %f" LESSOPEN="| lesspipe.sh %s" LESSCHARDEF=8bcccbcc13b.4b95.33b. # show colours in ls -l | less export LESS LESSEDIT LESSOPEN VISUAL LESSCHARDEF # fix the backspace key in rxvt if [ "$COLORTERM" != "" ] ; then stty erase ^H # alternative: ^H fi for i in /etc/profile.d/*.sh ; do if [ -x $i ]; then . $i fi done # call fortune, if available if [ -x /usr/games/fortune ] ; then echo ; /usr/games/fortune ; echo fi
This is a sample /etc/bashrc:
# /etc/bashrc # System wide functions and aliases # Environment stuff goes in /etc/profile # For some unknown reason bash refuses to inherit # PS1 in some circumstances that I can't figure out. # Putting PS1 here ensures that it gets loaded every time. USER=`whoami` if [ $LOGNAME = $USER ] ; then COLOUR=44 # blue else COLOUR=45 # magenta fi if [ $USER = 'root' ] ; then COLOUR=41 # red fi ESC="\033" STYLE=';1m' # bold # STYLE='m' # plain export PS1="\[$ESC[$COLOUR;37$STYLE\]$USER:\[$ESC[37;40$STYLE\]\w\\$ " export PS2="> " export CDPATH="$CDPATH:~" alias which="type -path" alias ls="ls $LS_OPTIONS"
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; ESC="\033"; STYLE=';1m'; # STYLE='m' USER=`whoami` export PS1="\[$ESC[$COLOUR;37$STYLE\]$USER:\[$ESC[37;40$STYLE\]\w\\$ " 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. { tar -zxvf $1 } cz() # List the contents of a .zip archive. { unzip -l $* } ctgz() # List the contents of a .tar.gz archive. { for file in $* ; do tar -ztf ${file} 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 user 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"
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 xterm
and other
X11 applications, the following is also needed:
.xinitrc
:
usermodmap=$HOME/.Xmodmap
xmodmap $usermodmap
.Xmodmap
will contain:
keycode 22 = BackSpace
keycode 107 = Delete
this fixes the console. To fix xterm
:
.Xdefaults
:
xterm*VT100.Translations: #override <Key>BackSpace: string(0x7F)\n\
<Key>Delete: string(0x1b) string("[3~")\n\
<Key>Home: string(0x1b) string("[1~")\n\
<Key>End: string(0x1b) string("[4~")\n\
Ctrl<Key>Prior: string(0x1b) string("[40~")\n\
Ctrl<Key>Next: string(0x1b) string("[41~")
nxterm*VT100.Translations: #override <Key>BackSpace: string(0x7F)\n\
<Key>Delete: string(0x1b) string("[3~")\n\
<Key>Home: string(0x1b) string("[1~")\n\
<Key>End: string(0x1b) string("[4~")\n\
Ctrl<Key>Prior: string(0x1b) string("[40~")\n\
Ctrl<Key>Next: string(0x1b) string("[41~")
rxvt
is a wee bit more complicated, as some compile--time options
influence its behaviour. See the above /etc/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.4.5.
ls
can display directory listings using colours to highlight different
file types. To enable this feature, you just need a couple of lines in
/etc/profile as seen above. However, 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. rxvt
2.4.5 upwards is
OK.
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"
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:
.lesskey
in your home directory:
^[[A back-line
^[[B forw-line
^[[C right-scroll
^[[D left-scroll
^[OA back-line
^[OB forw-line
^[OC right-scroll
^[OD left-scroll
^[[6~ forw-scroll
^[[5~ back-scroll
^[[1~ goto-line
^[[4~ goto-end
^[[7~ goto-line
^[[8~ goto-end
then run the command lesskey
. (These are escape sequences for
vt100-like terminals.) This creates a binary file .less
containing the key bindings.
#!/bin/sh # This is a preprocessor for 'less'. It is used when this environment # variable is set: LESSOPEN="|lesspipe.sh %s" lesspipe() { case "$1" in *.tar) tar tf $1 2>/dev/null ;; # View contents of .tar and .tgz files *.tgz|*.tar.gz|*.tar.Z|*.tar.z) tar ztf $1 2>/dev/null ;; *.Z|*.z|*.gz) gzip -dc $1 2>/dev/null ;; # View compressed files correctly *.zip) unzip -l $1 2>/dev/null ;; # View archives *.arj) unarj -l $1 2>/dev/null ;; *.rpm) rpm -qpil $1 2>/dev/null ;; *.cpio) cpio --list -F $1 2>/dev/null ;; *.1|*.2|*.3|*.4|*.5|*.6|*.7|*.8|*.9|*.n|*.man) FILE=`file -L $1` FILE=`echo $FILE | cut -d ' ' -f 2` if [ "$FILE" = "troff" ]; then groff -s -p -t -e -Tascii -mandoc $1 fi ;; *) file $1 | grep text > /dev/null ; if [ $? = 1 ] ; then # it's not some kind of text strings $1 fi ;; esac } lesspipe $1
chmod 755 lesspipe.sh
.
I rarely use emacs
, so I have only a couple of tips for you.
Some emacs
distributions don't come preconfigured for colours and
syntax highlighting. Put this in your .emacs
:
(global-font-lock-mode t)
(setq font-lock-maximum-decoration t)
This only works in X11. Moreover, to enable accented characters you'll add this line:
(standard-display-european 1)
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.
The Dotfile generator (Section
Configuration Software) is a good helping hand.
Some versions of joe
don't work with colours in console, and some
special keys don't work either. To my knowledge, no one has found a solution
to these small nags. A quick and dirty (and inelegant) solution to the
former problem is this:
~$ export TERM=vt100
~$ joe myfile
(edit your file)
~$ export TERM=linux
Configure joe
editing .joerc
, .jstarrc
or your
favourite emulation; you can start from the system-wide config files in
/usr/lib/joe.
This is my favourite editor: it does what I need, it's lighter and easier to
configure than emacs
, and emulates other editors quite well.
Many users at my university use 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.
jed
use the special keys correctly, write the file
/usr/lib/jed/lib/defaults.sl whose only line reads:
() = evalfile("linux");
xjed
apparently doesn't recognise the DEL key, add these
lines to your .jedrc
:
#ifdef XWINDOWS
x_set_keysym (0xFFFF, 0, "\e[3~");
setkey (``delete_char_cmd'', "\e[3~");
#endif
Info_Directory = "/usr/info";
and
/bin/mail
after /UCB_Mailer = "/bin/mail";
;
jed
emulate EDT
(or other editors) all you have to
do is edit a couple of lines in .jedrc
. If you want the numeric
keypad `+
' to delete words instead of a single character, add this
in .jedrc
:
unsetkey("\eOl");
unsetkey("\eOP\eOl");
setkey("edt_wdel", "\eOl");
setkey("edt_uwdel", "\eOP\eOl");
after the line that reads () = evalfile("edt")
(or similar);
xjed
use the numeric keypad for EDT
emulation,
insert the following in .Xmodmap
:
keycode 77 = KP_F1
keycode 112 = KP_F2
keycode 63 = KP_F3
keycode 82 = KP_F4
keycode 86 = KP_Separator
xjed
is done adding lines like these
in .Xdefaults
:
xjed*Geometry: 80x32+150+50
xjed*font: 10x20
xjed*background: midnight blue
# and so on...
$HOME/.abbrevs.sl
:
create_abbrev_table ("Global", "0-9A-Za-z");
define_abbrev ("Global", "GG", "Guido Gonzato");
create_abbrev_table ("TeX", "\\A-Za-z0-9");
define_abbrev ("TeX", "\\beq", "\\begin{equation}");
define_abbrev ("TeX", "\\eeq", "\\end{equation}");
% and so on...
and type ESC x abbrev_mode
to enable it. To have the abbreviation
enabled by default, add entries like these to your .jedrc
:
define text_mode_hook ()
{
set_abbrev_mode (1);
}
%
define fortran_hook ()
{
set_abbrev_mode (1);
use_abbrev_table ("Fortran");
}
% and so on...
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:
T
' or `P
'
won't work in some countries (in Italy, at least). Put `ATDT
' or
`ATDP
' instead;
-i
'
and `-k
', needed by efax
. If you want to add an AT command,
add it to the appropriate string leaving out `AT
' and preceding the
rest with either `-i
' or `-k
'. Example: to add the `ATX3
'
command to INIT, you'll append `-iX3
'.
I'll assume you have the teTeX distribution. Just a couple of things here:
~# texconfig init ; texconfig hyphen
texhash
so
that teTeX recognises the new package;
dvips
, the file to edit is
/usr/lib/texmf/texmf/dvips/config/config.ps. Be aware that the
fields regarding the default resolution also affect xdvi
's behaviour;
if you experience annoying attempts to create fonts each time you run it,
put the line
XDvi*mfmode:
in .Xdefault
. This should help.
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, if you will, 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 get hold of one of the following nice tools:
http://www.serv.net/~cameron/ezppp/index.html
.
Very easy to use, almost self--explanatory, but requires you to write the
connection script;
ftp://sunsite.unc.edu/pub/Linux/system/network/serial/ppp
. One of the finest is pppsetup-X.XX.tar.gz. Script required
here;
wvdial
and eznet
. You feed them your ISP's phone number, your username,
your password, and you're in business. Their home pages are at
http://www.worldvisions.ca/wvdial
and
http://www.hwaci.com/sw/eznet
. My preference goes to
the latter.
First of all, create an /etc/resolv.conf like this:
nameserver w.x.y.z
where you'll insert the address of your ISP's nameserver. To create an
account with eznet
, issue the following command:
#~ eznet add service=YOUR_ISP user=NAME password=PASSWORD phone=PHONE
then try to dial your ISP with eznet up YOUR_ISP
. If the modem
waits for the dial tone and won't connect, then try this command:
#~ eznet change YOUR_ISP init0=atx3
To hang up, the command is eznet down
. That's all!
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:
fetchpop
: the first time you run it, you'll be prompted for some
information. Answer the questions and you're set.
fetchmail
: adapt this sample .fetchmailrc
:
# $HOME/.fetchmailrc
poll mbox.myisp.com with protocol pop3;
user john there with password _Loo%ny is john here
One user reported that adding ``smtphost localhost'' to the second line
improved performance dramatically.
You must set the permissions to this file with the command
chmod 600 .fetchmailrc
, otherwise fetchmail
will rightly refuse
to start. This example is very basic and assumes that you have a running
sendmail
; there are endless possibilities of configuration. Check out
on
http://www.ccil.org/~esr/fetchmail.
Come on, it's not difficult as it used to be... All major distributions
include a tool for setting up X11 (e.g.
XConfigurator
, sax
, XF86Setup
, or at least xf86config
).
X configuration is virtually automatic these days, but a few video cards may
refuse to work. Each time I experience problems setting up X on a system, I
resort to a simple method that has always worked:
ftp://ftp.XFree86.org/pub/XFree86/current/binaries
, cd to
the proper Linux subdirectory, and download the archives
X_version_bin.tgz
, X_version_set.tgz
, and all the servers.
Amongst other programs, the first one contains the most up-to-date
SuperProbe
;
X_version_bin.tgz
to a temporary directory, cd to it,
and run ./SuperProbe
. If your video card is recognised, chances are
that you'll be able to set it up. Otherwise, hard luck;
X_version_set.tgz
from
/usr/X11R6/, then run
XF86Setup
.
This has always worked for me, but your mileage may vary. Please note that most times X11 won't configure because the specs you choose for your monitor are too low! Start with conservative settings, i.e. 800x600 and 256 colours, then pump it up. Warning: these operations are dangerous and your monitor might be damaged!
We have seen above how to make a few special keys work. The sample file
.Xmodmap
works well if you want to use Xjed, but it makes the keypad
unusable. You'll then need another config file, which we'll call
.Xmodmap.num
:
! Definitions can be found in <X11/keysymdef.h>
keycode 77 = Num_Lock
keycode 112 = KP_Divide
keycode 63 = KP_Multiply
keycode 82 = KP_Subtract
keycode 86 = KP_Add
keycode 79 = KP_7
keycode 80 = KP_8
keycode 81 = KP_9
keycode 83 = KP_4
keycode 84 = KP_5
keycode 85 = KP_6
keycode 87 = KP_1
keycode 88 = KP_2
keycode 89 = KP_3
keycode 90 = KP_0
keycode 91 = KP_Decimal
Make sure that your /etc/X11/XF86Config does not contain these three lines:
ServerNumLock
Xleds
XkbDisable
and in case, comment them out. To re-enable the keypad, you'll issue the
command xmodmap .Xmodmap.num
.
To be greeted by a graphical login, edit the file /etc/inittab, which should include a line like this:
x:5:respawn:/usr/bin/X11/xdm -nodaemon
where 5 is the runlevel corresponding to X11 (S.u.S.E. uses 4). Modify the line that defines the default runlevel (usually 2 or 3), changing it as above:
id:5:initdefault:
The number of colours is specified in /etc/X11/xdm/Xserver (AT2YD):
:0 local /usr/X11R6/bin/X -bpp 16 # 65k colours
If you already have .xinitrc
, copy it to .xsession
and
make the latter executable with chmod +x .xsession
. Now issue the
command telinit 5
and you're in business.
Once you've managed to make X work, there are endless possibilities of configuration; it depends on the window manager you use - there are tens to choose from. Mostly, it's all down to editing one or more ASCII files in your home directory; in other cases you don't have to edit a thing, and use an applet or even a menu.
Some examples:
$HOME/GNUstep
, and a cool configuration applet;
In short: if you don't mind editing config file, choose something like
icewm
, fvwm*
, blackbox
etc; if you do mind, the
choice is currently restricted to KDE and WindowMaker.
It's important to have a good .xinitrc
. An example:
#!/bin/sh
# $HOME/.xinitrc
usermodmap=$HOME/.Xmodmap
xmodmap $usermodmap
xset s noblank # turn off the screen saver
xset s 300 2 # screen saver start after 5 min
xset m 10 5 # set mouse acceleration
rxvt -cr green -ls -bg black -fg white -fn 7x14 \
-geometry 80x30+57+0 &
if [ "$1" = "" ] ; then # default
WINMGR=wmaker
else
WINMGR=$1
fi
$WINMGR
Although it doesn't appear to be strictly required, make
it executable with chmod +x .xinitrc
.
This .xinitrc
lets you choose the window manager: try
$ startx startkde # or other w.m.
(it doesn't work with some S.u.S.E. versions, though).
When you're done editing the dot files, copy them to /etc/skel
as seen in Section
Software Configuration.
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.
If you upgrade your machine, do your backup as usual and remember to save a few additional files. Some could be /etc/X11/XF86Config, /usr/bin/fax, all the stuff in /usr/local, the kernel configuration, the whole /etc, and all the mail in /var/spool/mail.