bash
(1)To tailor bash
's behaviour, these are the files to edit:
/etc/bashrc
contains system wide aliases and functions;
/etc/profile
contains system wide environment stuff and
startup programs;
$HOME/.bashrc
contains user's aliases and functions;
$HOME/.bash_profile
contains user's environment stuff
and startup programs;
$HOME/.bash_logout
contains actions to be performed at
logout;
$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.
# /etc/profile # System wide environment and startup programs # Functions and aliases go in /etc/bashrc # This file sets the following features: # # o path # o prompts # o a few environment variables # o colour ls # o less behaviour # o keyboard settings # # 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 ^[ PS1='^[[$COLOUR;37;1m$HOSTNAME:^[[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' # customize less LESS='-M-Q' LESSEDIT="%E ?lt+%lt. %f" LESSOPEN="| lesspipe.sh %s" VISUAL=jed LESSCHARSET=latin1 export LESS LESSEDIT LESSOPEN VISUAL LESSCHARSET # customise the keyboard /sbin/kbdrate -s -r 16 -d 500 for i in /etc/profile.d/*.sh ; do if [ -x $i ]; then . $i fi done
This is /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 .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 COLOUR=45 # put a real escape character instead of ^[ PS1='^[[$COLOUR;37m$USER:^[[37;40m\w\$ ' # 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 .bash_profile
:
# $HOME/.bash_profile # User specific environment and startup programs # This file contains user-defined settings that override # those in /etc/profile # Get aliases and functions if [ -f ~/.bashrc ]; then . ~/.bashrc fi # re-get PS1 settings if [ $USER = 'root' ] ; then COLOUR=41 else COLOUR=44 fi # put a real escape character instead of ^[ PS1='^[[$COLOUR;37;1m$HOSTNAME:^[[37;40;1m\w\$ ' export PS1
This is .bash_logout
:
# $HOME/.bash_logout clear
This is .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 set show-all-if-ambiguous On
To make the backspace and delete keys work correctly in in
xterm
and other X11 applications, the following is also needed:
.xinitrc
:
usermodmap=$HOME/.Xmodmap
xmodmap $usermodmap
.Xmodmap
:
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~")
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 goes for rxvt
.
Rumour has it that it's a termcap problem.
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'
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 some versions of rxvt
; use some flavour of xterm
instead. It looks like rxvt
has a bug that prevents it from inheriting
the environment correctly in some circumstances.
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 so on. 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
. This creates a binary file .less
containing the key bindings.
/usr/bin/lesspipe.sh
:
#!/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 -q -p -i -l $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=`file -L $1` ; # Check to see if binary FILE1=`echo $FILE | cut -d ' ' -f 2` FILE2=`echo $FILE | cut -d ' ' -f 3` if [ "$FILE1" = "Linux/i386" -o "$FILE2" = "Linux/i386" \ -o "$FILE1" = "ELF" -o "$FILE2" = "ELF" ]; then strings $1 fi ;; esac } lesspipe $1
chmod 755 lesspipe.sh
.
/etc/profile
:
LESS="-M-Q" # long prompt, silent
LESSEDIT="%E ?lt+%lt. %f" # edit top line
LESSOPEN="| lesspipe.sh %s" # filter
VISUAL=jed # default editor---insert your favourite
LESSCHARSET=latin1 # display accented letters if needed
export LESS LESSEDIT LESSOPEN VISUAL LESSCHARSET
The variable LESSCHARSET
depends on the fact that I live in Italy and
want to use the ISO 8859/1 character set. You fellow Americans, Japanese,
Russians and so on had better not set it.
emacs
(1)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 discover how to tailor it to your needs---potentially, it
can take months of hacking...
joe
(1)Check in /usr/bin/
whether jmacs
, jstar
, and jpico
are symlinks to joe
or standalone binaries; in the latter case, you may
turn them to symlinks to save some disk space:
~# cd /usr/bin
/usr/bin# ln -sf joe jmacs ; ln -sf joe jstar ; ln -sf joe jpico
Then, all you have to do is copy /usr/lib/joe/joerc
to your home
dir as .joerc
and tailor it.
jed
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.
The configuration files are .jedrc
and /usr/lib/jed/lib/*
; the
former can be adapted from jed.rc
in the latter directory.
jed
use some keys correctly, create
/usr/lib/jed/lib/defaults.sl
whose only line reads:
() = evalfile("linux");
/usr/lib/jed/lib/linux.sl
; remove the
comment from the line that reads Info_Directory = "/usr/info";
and
add /bin/mail
after UCB_Mailer =
;
jed
to make it emulate EDT
(or other editors)
is straightforward: you just have to edit a couple of lines in .jedrc
.
If you want to use 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");
.
xjed
use the numeric keypad for EDT
emulation
requires inserting the following in .Xmodmap
:
keycode 77 = KP_F1
keycode 112 = KP_F2
keycode 63 = KP_F3
keycode 82 = KP_F4
keycode 86 = KP_Separator
Moreover, make sure that your /etc/X11/XF86Config
contains the
following lines:
# ServerNumLock # must be commented out
XkbDisable
This applies to XFree 3.2. Unless you use a standard American keyboard
though, note that ``XkbDisable'' brings some little problems. You'll find
out by yourself.
xjed
is done adding lines like these
in .Xdefaults
:
xjed*Geometry: 80x32+150+50
xjed*font: 10x20
xjed*background: midnight blue
More info in xjed.doc, included in the package.
I'll assume you have the TeTeX distribution. Just a couple of things here:
/usr/lib/texmf/texmf/tex/generic/config/language.dat
, then do:
~# texconfig init ; texconfig hyphen
/usr/lib/texmf/texmf/tex/latex/
run the command texhash
to
make TeTeX recognise 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 in .Xdefault
the line
XDvi*mfmode:
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. (These requirements should be there by
default.) There are now two ways to get PPP to work: a) manual
configuration, and b) using a program that automagically sees to it. First,
the manual option.
Let's suppose that your ISP's specifications are the following:
To configure manually your PPP connections, you'll do:
/usr/local/bin/ppp-on
, which will be used to
connect to your ISP:
#!/bin/sh
# ppp-on: script to connect to an ISP
INIT=ATX3 # or whatever your modem wants
PHONE=1234567
/usr/sbin/pppd connect "/usr/sbin/chat '' $INIT OK ATDP$PHONE \
CONNECT '' " user John
then make it executable with chmod 755 /usr/local/bin/ppp-on
. If
your ISP doesn't use the PAP protocol, the following script applies:
#!/bin/sh
# ppp-on: script to connect to an ISP
INIT=atx3 # or whatever your modem wants
PHONE=1234567
/usr/sbin/pppd connect "/usr/sbin/chat '' $INIT OK ATDT$PHONE \
CONNECT '' 'ogin' John 'word' _Loo%ny ''" /dev/modem 38400 \
modem defaultroute
/usr/local/bin/ppp-off
, used to terminate a
ppp session:
#!/bin/sh
# ppp-off
DEVICE=ppp0
if [ -r /var/run/$DEVICE.pid ]; then
kill -INT `cat /var/run/$DEVICE.pid`
if [ ! "$?" = "0" ]; then
echo "removing stale $DEVICE pid file."
rm -f /var/run/$DEVICE.pid ; exit 1
fi
echo "$DEVICE link terminated" ; exit 0
fi
# link not active
echo "$DEVICE link is not active" ; exit 1
then make it executable with chmod 755 /usr/local/bin/ppp-off
.
/etc/ppp/options
:
# /etc/ppp/options
/dev/modem
38400
lock
crtscts
modem
asyncmap 0
remotename www.supernet.edu
defaultroute
/etc/ppp/pap-secrets
:
# /etc/ppp/pap-secrets
# username remotehost secret
John www.supernet.edu _Loo%ny
/etc/resolv.conf
:
# /etc/resolv.conf
search supernet.edu
nameserver 123.231.112.111
/etc/sendmail.cf
. Look for the line starting with
DS
, and make it like the following:
DSmbox.supernet.edu
Phew! If you're lucky, this should work. Otherwise, be prepared to study the PPP-HOWTO.
So much for manual configuration. There's a fine package that makes all this
drudgery a thing of the past, though: it's called ezppp
and you'll find
it at
http://www.serv.net/~cameron/ezppp/index.html
. Download
it at once.
To retrieve your mail from a POP server, use a POP client like fetchpop
or fetchmail
. The latter is probably the only option if your provider's
PPP server has problems with the command LAST.
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.supernet.edu with protocol pop3;
user john there with password _Loo%ny is john here
mda "/usr/bin/procmail -f fetchmail"
The last line may not be required. You must set the permissions to this file
with the command chmod 600 .fetchmailrc
, otherwise fetchmail
will
rightly refuse to start.
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:
/etc/X11/fvwm/system.fvwmrc
to your home
directory as .fvwmrc
, browse it and start experimenting. This
contributed system.fvwmrc
is IMHO a wee bit too simple and doesn't do
justice to fvwm
.
/etc/X11/fvwm95-2/fvwm2rc95
to your home
as .fvwm2rc95
, then edit it. The contributed example is quite good.
/etc/X11/TheNextLevel/.*
to your home dir, browse them carefully,
then try and tailor them. The first one to look at is .fvwm2rc.defines
.
In addition, be 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 memory, but has a few bugs:
# - home and end keys are not recognised;
# - backspace and delete don't work as in console;
# - colours are not properly inherited by the environment;
# - problems with the environment in general;
# xterm is therefore better in many cases. However, rxvt is best
# for running some colour apps like mc.
xterm -ls -bg black -fg white -sb -sl 500 -j -ls -fn 10x20 -fb 10x20bold \
-title "Color xterm" -geometry 80x25+150+0 &
fvwm95-2
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
from
ftp://sunsite.unc.edu/pub/Linux/devel/languages/fortran/yaf77-1.4.tgz
and its mirrors.
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, joerc, emacs
.
(Note: due to formatting problems, I had to remove the leading dot (`.') from each of these files.)
Note that .pinerc
can't be fully tailored; make sure that at least the
fields user-domain
, smtp-server
, and nntp-server
are set up.