Next Previous Contents

3. 軟件設置

3.1 bash(1)

要使bash 符合個人的口味,有几個文檔需要修改:

下文將例舉對這些文檔的修改。首先,最重要的文檔是:/etc/profile。如以下几節中可以看到,一向以修改這個文檔的方式來設定Linux的各種功能。


# /etc/profile

# System wide environment and startup programs
# --整個系統環境和啟動程式
#
# Functions and aliases go in /etc/bashrc
# --/etc/bashhrc中的功能和別名
#
# This file sets the following features:
# --這個文檔設定下列功能:
#
#   o path      --路徑            
#   o prompts   --提示符
#   o a few environment variables       --几個環境變數
#   o colour ls --ls 的顏色
#   o less behaviour    --設定less的功能 
#   o keyboard settings --鍵盤設置
#
# Users can override these settings and/or add others in their
# $HOME/.bash_profile
# 用戶可在$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.
# 通知用戶:登錄(login)或不登錄(non-login)的外圍程序(shell)。
# 如果登錄,則提示符為藍色,否則為紫紅色。Root的提示符為紅色。

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
# 設定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
# 設定ls的顏色

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

# customize less
# 設定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

此處為 /etc/bashrc


# /etc/bashrc

# System wide functions and aliases
# 整個系統的功能和別名
#
# Environment stuff goes in /etc/profile
# /etc/profile中的環境參數
#

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

此處為 .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
# 需要以下設定,以便通知處於不登錄(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}
}

此處為.bash_profile


# $HOME/.bash_profile

# User specific environment and startup programs
# 用戶特定的環境參數和啟動程式
#
# This file contains user-defined settings that override
# those in /etc/profile
# 這個文檔中存有用戶自訂的設置,可取代/etc/profile 中的數值
#
# Get aliases and functions
# 設定別名和功能
#
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi

# re-get PS1 settings
# 重新設定PS1數值

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

此處為 .bash_logout


# $HOME/.bash_logout

clear

此處為 .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"
# (F1 .. F5) 分別為 "\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)
                                                # --允許8-位元輸入(例如重音字符)譯註:用于歐洲
                                                # 文字或GB碼及Big5碼)
set convert-meta Off    # don't strip 8-bit characters
                                                # 不取消8-位元字符
set output-meta On       # display 8-bit characters correctly
                                                # 正確顯示8-位元字符

set horizontal-scroll-mode On
set show-all-if-ambiguous On

設定下列參數使 backspace 和 delete 兩鍵在xterm 和其他X11應用中運作正常:

bash(1) 和 readline(3) 的man說明中有更多這方面的資料。

不要以為這些設定在每種應用中都可正常運作。例如,在xterm中運行joe,有些鍵位就不起作用;運行rxvt也有相同的問題。有人說,這是termcap的問題。

3.2 ls(1)

ls可顯示目錄,并用顏色提示不同種類的文檔。要使用這項功能,則在/etc/profile中增添以下內容:

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

這樣就設定了LS_COLORS的環境參數,其中存有/etc/DIR_COLORS中的顏色變數表。注意:這項設置對rxvt的有些版本無效,原因不明。不妨改用xterm中的一些其他特性。可能rxvt中仍有程序錯誤,以致有時不能運用設定的環境參數。

3.3 less(1)

利用這個優越的頁面調度程序不僅能瀏覽一般文字文檔,也能觀看壓縮的gzip文檔和以tar和zip格式儲存的檔案文檔,其設置如下:

3.4 emacs(1)

有些emacs 版本沒有預先設置顏色和語法標示。可在.emacs中增添:

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

這只對X11有用。各位不妨從emacs文獻中探索符合各種需要的設定 -- 有時可能要耗費几個月的時間測試....

3.5 joe(1)

檢查/usr/bin/中的jmacsjstar、和jpico 是否symlink到joe,或是獨立的二進制程式;如果仍為後者,則不妨將其作出symlink,以節省硬盤空間。

~# cd /usr/bin
/usr/bin# ln -sf joe jmacs ; ln -sf joe jstar ; ln -sf joe jpico

然後只要把/usr/lib/joe/joerc作為.joerc抄到home目錄,再作出符合需要的修改。

3.6 jed

這是個頗為好用的編輯器:比emacs短小精悍,宜於設置,並且IMHO模擬其他編輯器也相當不錯。在作者工作的大學中有許多使用者都用jed模擬VMS系統的編輯器EDT

設置文檔為.jedrc/usr/lib/jed/lib/*;前者可從後者目錄中的jed.rc修改而得。

3.7 TeX and Friends

如果電腦中裝有TeTeX,可作下列几項設定:

3.8 PPP

目前Linux的內核幾乎都已編入了PPP + TCP/IP功能,設定了回送地址(loopback)和正確安裝了pppd軟件。那麼有兩種方式可使PPP正常運作:(a)手動設定;和(b)利用一個程式自動設定。首先,試試手動設定。

假定ISP的資料如下:

手動設置PPP聯網的方式為:

花了這麼大的力氣,如果運氣好,有這樣的設定就夠了。否則,那就準備開始翻看PPP-HOWTO吧。

以上就是手動設置。不過,現在有一套不錯的軟件,可免除這項苦差事:這套軟件稱為ezppp,可在下列網址找到: http://www.serv.net/~cameron/ezppp/index.html

3.9 POP用戶端程序

要從POP伺服器收取郵件,可使用POP用戶端程序,如fetchpopfetchmail等。如果ISP的PPP伺服器不支持LAST指令,則後者可能是唯一可用的方法。

設置這些用戶端程序的方法如下:

3.10 X 視窗系統

一旦X 視窗可以運行後(正確地設定了顯示卡等細緻工作),就可作出其他各色各樣的設置,完全取決于使用何種視窗管理程序。不過,歸根結底,只是編輯home目錄內的一個或几個ASCII文檔。至於視窗管理程序:

此外,一定要有適當的.xinitrc,例如:

#!/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 --5分鐘後開始屏幕保護程序
xsetroot -solid "medium blue" &

# rxvt 節省內存,但有几個錯誤程序:
#   - 不認home和end兩鍵;
#   - backspace和delete兩鍵和在主控台時的作用不同;
#   - 顏色不依照環境參數設定;
#   - 與環境參數時有衝突;
# 因此,多數情況下,xterm比較好用。但rxvt在麥金塔機的一些顏色應用上顯示較好。

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.11 Fortran

依據經驗,代用g77的最好Fortran-to-C翻譯器是f2c和前端軟件yaf77

yaf77可從 ftp://sunsite.unc.edu/pub/Linux/devel/languages/fortran/yaf77-1.4.tgz及其鏡象網址取得。

3.12 用戶設置

新用戶在首次登錄時,最好已有几個設置文檔可用。可將下列設置檔放在/etc/skel中:bashrc、bash_profile、bash_logout、inputrc、less、 xinitrc、fvwmrc、fvwm2rc95、Xmodmap、Xdefaults、jedrc、joerc、emacs

(注意:由于排版的緣故,上面每個文檔前均未放置‘.’符號)

.pinerc 無法進行充分設定;但至少要設定user-domainsmtp-servernntp-server 的參數。


Next Previous Contents