s i s t e m a o p e r a c i o n a l m a g n u x l i n u x | ~/ · documentação · suporte · sobre |
Next
Previous
Contents
4. Software Configuration
These are the the configuration files we are going to custimise:
/etc/profile /etc/bashrc
4.1 bash(1)
Arguably, the most important piece of software after the kernel. To tailor
the behaviour of
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: # path, prompts, a few environment variables, colour ls, less, # rxvt, Backspace key behaviour, xterm title. # # Users can override these settings and/or add others in their # $HOME/.bash_profile # first: root or normal user? Set PATH and umask accordingly. Note that the # PATH is normally set by login(1), but what if you access the machine # via ssh? if [ $(id -gn) = $(id -un) -a $(id -u) -gt 14 ]; then umask 002 # normal user PATH="/usr/local/bin:/bin:/usr/bin:." else umask 022 # root PATH="/sbin:/bin:/usr/sbin:/usr/bin" fi # Now extend the PATH. PATH="$PATH:/usr/X11R6/bin:$HOME/bin:." # !!! Beware of ./ !!! # notify the user: login or non-login shell. If login, the prompt is # blue; otherwise, 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" # my choice fi ESC="\033" PROMPT='\h' # hostname STYLE='m' # plain # PROMPT='\u' # username # STYLE=';1m' # bold PS1="\[$ESC[$COLOUR;37$STYLE\]$PROMPT:\[$ESC[37;40$STYLE\]\w\\$ " PS2="> " # Ulimits: no core dumps, max file size 200 Mb. ulimit -c 0 -f 200000 # a few variables USER=$(id -un) LOGNAME=$USER MAIL="/var/spool/mail/$USER" # sendmail, postfix, smail # MAIL="$HOME/Mailbox" # qmail NNTPSERVER=news.myisp.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 # LESSCHARSET=latin1 PAGER=less export LESS LESSEDIT LESSOPEN VISUAL LESSCHARDEF PAGER # you might need this to fix the backspace key in rxvt/xterm stty erase ^H # alternative: ^? # set xterm title: full path case $TERM in xterm*|rxvt) PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME}: ${PWD}\007"' ;; esac for i in /etc/profile.d/*.sh ; do if [ -x $i ]; then . $i # beware - variables and aliases might get overridden! 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 # Insert PS1 definitions here if you experience problems. export CDPATH="$CDPATH:~" # common aliases alias cp='cp -i' alias l=less alias ls="ls $LS_OPTIONS" alias mv='mv -i' alias rm='rm -i' alias rmbk='/bin/rm -f .*~ *~ *aux *bak *log *tmp 2> /dev/null' alias u='cd ..' alias which="type -path" alias x=startx # A few useful functions c () # cd to the new directory and list its contents { cd $1 ; ls } inst() # Install a .tar.gz archive in current directory { if [ $# != 0 ]; then tar zxvf $1; fi } cz() # List the contents of a .zip archive { if [ $# != 0 ]; then unzip -l $*; fi } 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. { if [ $# != 0 ]; then name=$1.tar; shift; tar -rvf ${name} $* ; gzip -9 ${name} fi } crpm() # list information on an .rpm file { if [ $# != 0 ]; then rpm -qil $1 | less; fi } This is a sample
# $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 # personal aliases alias backup='tar -Mcvf /dev/fd0' alias dial='eznet up myisp' alias f='cd ~/fortran' alias hangup='eznet down' alias lyx='lyx -width 580 -height 450' alias restore='tar -M -xpvf /dev/fd0' # personal functions xj() # Launch xjed and a file in background { xjed $1 & } This is a sample
# $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
# $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
More info in Don't expect every application to work correctly! If you run
4.2 I18n
(This section doesn't apply to native English speakers.) A.k.a. ``internationalisation''. Gasp. This long word means ``to adapt Linux to your local conventions: language, format of date, currency etc.''. Although Red Hat has its own method for setting up i18n
(/etc/sysconfig/i18n), you may want to
enable your language only in some cases. I, for one, enabled i18n in
Consider these lines:
If you insert them in your
4.3 ls(1)
4.4 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:
4.5 Editor
Only the most popular will be covered here.
emacs(1)
I rarely use
This only works in X11. Moreover, to enable accented characters you'll add this line:
I'll leave it to you to peruse all of
joe(1)
Some versions of
To make the special keys work, all you have to do is edit
Find out the desired ESC sequences typing
jed(1)
This is my favourite editor: it does what I need, it's lighter and easier to
configure than
4.6 pine(1)
Edit the global configuration in /usr/lib/pine.conf, taking
care at least of the following fields:
4.7 minicom(1)
Users can't use
4.8 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 or (mandrake) /etc/fax.config; easy job, but a couple of quirks caused me quite a headache:
That done, there are a few permissions to fix to enable non-root users to
send and receive faxes. The directories /var/lock and
/var/spool/fax must be writable. To do so, create the
group
As a normal user, you'll issue
4.9 Ghostscript
This essential tool suffers from a small snag. Owing to to the well-known
export regulations in the USA, the utility
4.10 TeX and Friends
The ``root'' of a TeX system is the directory $TEXMF, which is /usr/share/texmf in teTeX; other distributions may differ (search for ``texmf'' on your system). You normally add stuff or fiddle with files therein.
Expanding $TEXINPUTS
To include PostScript figures or TeX files that reside in subdirectories, it is convenient to expand TeX's search path to include subdirectories. Put this command in your .bash_profile:
which makes TeX search in
Hyphen Patterns
To configure the hyphenation pattern for your language, edit the file $TEXMF/tex/generic/config/language.dat, then do:
Even if you don't write in English, don't remove the entry ``english''; TeX pukes without it.
Dvips
To tailor
in your
Adding LaTeX Packages
Additional LaTeX packages are available from your nearest CTAN (Comprehensive TeX Archive Network) mirror site, e.g. ftp://ftp.dante.de/pub/tex. Unpack the package under $TEXMF/tex/latex. If no .sty file exist, run the command
4.11 Avoid PPProblems!
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 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. Gnome and KDE include, respectively,
A Quick Start with eznet
First of all, create an /etc/resolv.conf like this:
where you'll insert the address of your ISP's nameserver. To create an
account with
which creates the file /var/eznet/eznet.conf, owned by root.root
with permissions 600; chmod it to 666 if you want it to be world readable.
Now dial your ISP with
To hang up, the command is
A Quick Start with wvdial
4.12 POP Client
To retrieve your mail from a POP3 server, you need a POP client. Most such
clients require that you run an MTA like To configure these clients:
4.13 Basic Mail Filtering
You will want to protect yourself from spam or huge mail messages. There
are two cases: 1) permanent connection to the net, 2) a POP link. In the
first case, you can write a A very simple
POP users will want to use
4.14 X Window System (XFree86)
Setting Up the X Server
Come on, it's no longer as difficult as it used to be... All major
distributions include a tool for setting up X11 (e.g.
First of all, check out at the XFree86 site ( http://www.xfree86.org) whether your video card is supported. If so, then try this procedure:
This has always worked for me, but your mileage may vary. Please note that most times X11 won't start because you chose wrong specs for your monitor! 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! If your card isn't supported, you can either: 1) wait for the next version of XFree86; 2) buy a commercial X server; 3) buy a supported video card. Quartum non datur.
Keypad
We have seen above how to make a few special keys work. The sample file
Make sure that your /etc/X11/XF86Config does not contain these three lines:
and in case, comment them out. To re-enable the keypad, you'll issue the
command
Graphical Login with xdm
To be greeted by a graphical login, edit the file /etc/inittab, which should include a line like this:
where 5 is the runlevel corresponding to X11. Modify the line that defines the default runlevel (usually 2 or 3), changing it as above:
The number of colours is specified in /etc/X11/xdm/Xserver:
If you already have
Window Manager
Once X works, 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:
In short: if you don't mind editing config file, choose something like
It's important to have a good
Although it doesn't appear to be strictly required, make
it executable with The
Defaults for X11 Apps
Find out where the app-defaults directory is (it should be /usr/X11R6/lib/X11/app-defaults). Several apps keep a configuration file there.
Adding Fonts
Recent versions of XFree86 (say, > 3.3.4) use an X Font Server that supports PostScript Type 1 and True Type fonts natively, so you can use the wealth of fonts available on the net. There's a simple procedure to follow. Suppose that you download a Type 1 font collection, e.g. Freefont ( ftp://ftp.gimp.org/pub/gimp/fonts/freefonts-0.10.tar.gz). To make it visible to the font server, unpack the archive from /usr/X11R6/lib/X11/fonts/. Then edit /etc/X11/fs/config, add an entry for the new directory, and restart the font server. If you're rolling your own font collection, you'll need to supply the files
As for the True Type fonts, group them in a directory of your choice and
create It all started from the original True Type X font server: http://http://www.dcs.ed.ac.uk/home/jec/programs/xfsft/.
4.15 Users' Configurations
When you're done editing the dot files, copy them to /etc/skel as seen in Section Software Configuration.
4.16 Making .rpms
4.17 Upgrading
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. Then it's time to upgrade (in rare cases, downgrade!) applications that your distribution ship with, and to add additional packages. Keep a list of these ones.
Next Previous Contents |