Username: Password:

关于debian的启动脚本
来源: ChinaUnix博客  作者: ChinaUnix博客   发布时间:2008-04-24 08:28:58

apt-get install rcconf
然后执行rcconf
rc*.d一般是init.d的连接来的
个人启动项能够写到~/.bashrc里
/etc/rcS.d中S打头的脚本(启动)、K打头的脚本(停止)。
通常情况下,debian运行在2级别下。因此会运行/etc/rc2.d目录下S打头的脚本(启动)、K打头的脚本(停止)。
.bashrc的周详样板
http://www.tldp.org/LDP/abs/html/sample-bashrc.html
               
       
               
               
               
               
-----------------------------------------------
#===============================================================
#
# PERSONAL $HOME/.bashrc FILE for bash-2.05a (or later)
#
# Last modified: Tue Apr 15 20:32:34 CEST 2003
#
# This file is read (normally) by interactive shells only.
# Here is the place to define your aliases, functions and
# other interactive features like your prompt.
#
# This file was designed (originally) for Solaris but based
# on Redhat’s default .bashrc file
# --> Modified for Linux.
# The majority of the code you’ll find here is based on code found
# on Usenet (or internet).
# This bashrc file is a bit overcrowded - remember it is just
# just an example. Tailor it to your needs
#
#
#===============================================================
# --> Comments added by HOWTO author.
# --> And then edited again by ER :-)
#-----------------------------------
# Source global definitions (if any)
#-----------------------------------
if [ -f /etc/bashrc ]; then
        . /etc/bashrc   # --> Read /etc/bashrc, if present.
fi
#-------------------------------------------------------------
# Automatic setting of $DISPLAY (if not set already)
# This works for linux - your mileage may vary....
# The problem is that different types of terminals give
# different answers to ’who am i’......
# I have not found a ’universal’ method yet
#-------------------------------------------------------------
function get_xserver ()
{
    case $TERM in
        xterm )
            XSERVER=$(who am i | awk ’{print $NF}’ | tr -d ’)’’(’ )
            # Ane-Pieter Wieringa suggests the following alternative:
            # I_AM=$(who am i)
            # SERVER=${I_AM#*(}
            # SERVER=${SERVER%*)}
            XSERVER=${XSERVER%%:*}
            ;;
        aterm | rxvt)
        # find some code that works here.....
            ;;
    esac  
}
if [ -z ${DISPLAY:=""} ]; then
    get_xserver
    if [[ -z ${XSERVER}  || ${XSERVER} == $(hostname) || ${XSERVER} == "unix" ]]; then
        DISPLAY=":0.0"                # Display on local host
    else               
        DISPLAY=${XSERVER}:0.0        # Display on remote host
    fi
fi
export DISPLAY
#---------------
# Some settings
#---------------
ulimit -S -c 0                # Don’t want any coredumps
set -o notify
set -o noclobber
set -o ignoreeof
set -o nounset
#set -o xtrace          # useful for debuging
# Enable options:
shopt -s cdspell
shopt -s cdable_vars
shopt -s checkhash
shopt -s checkwinsize
shopt -s mailwarn
shopt -s sourcepath
shopt -s no_empty_cmd_completion  # bash>=2.04 only
shopt -s cmdhist
shopt -s histappend histreedit histverify
shopt -s extglob        # necessary for programmable completion
# Disable options:
shopt -u mailwarn
unset MAILCHECK                # I don’t want my shell to warn me of incoming mail
export TIMEFORMAT=$’\nreal %3R\tuser %3U\tsys %3S\tpcpu %P\n’
export HISTIGNORE="&:bg:fg:ll:h"
export HOSTFILE=$HOME/.hosts        # Put a list of remote hosts in ~/.hosts
#-----------------------
# Greeting, motd etc...
#-----------------------
# Define some colors first:
red=’\e[0;31m’
RED=’\e[1;31m’
blue=’\e[0;34m’
BLUE=’\e[1;34m’
cyan=’\e[0;36m’
CYAN=’\e[1;36m’
NC=’\e[0m’              # No Color
# --> Nice. Has the same effect as using "ansi.sys" in DOS.
# Looks best on a black background.....
echo -e "${CYAN}This is BASH ${RED}${BASH_VERSION%.*}${CYAN} - DISPLAY on ${RED}$DISPLAY${NC}\n"
date
if [ -x /usr/games/fortune ]; then
    /usr/games/fortune -s     # makes our day a bit more fun.... :-)
fi
function _exit()        # function to run upon exit of shell
{
    echo -e "${RED}Hasta la vista, baby${NC}"
}
trap _exit EXIT
#---------------
# Shell Prompt
#---------------
if [[ "${DISPLAY#$HOST}" != ":0.0" &&  "${DISPLAY}" != ":0" ]]; then  
    HILIT=${red}   # remote machine: prompt will be partly red
else
    HILIT=${cyan}  # local machine: prompt will be partly cyan
fi
#  --> Replace instances of \W with \w in prompt functions below
#+ --> to get display of full path name.
function fastprompt()
{
    unset PROMPT_COMMAND
    case $TERM in
        *term | rxvt )
            PS1="${HILIT}[\h]$NC \W > \[\033]0;\${TERM} [\u@\h] \w\007\]" ;;
        linux )
            PS1="${HILIT}[\h]$NC \W > " ;;
        *)
            PS1="[\h] \W > " ;;
    esac
}
function powerprompt()
{
    _powerprompt()
    {
        LOAD=$(uptime|sed -e "s/.*: \([^,]*\).*/\1/" -e "s/ //g")
    }
    PROMPT_COMMAND=_powerprompt
    case $TERM in
        *term | rxvt  )
            PS1="${HILIT}[\A \$LOAD]$NC\n[\h \#] \W > \[\033]0;\${TERM} [\u@\h] \w\007\]" ;;
        linux )
            PS1="${HILIT}[\A - \$LOAD]$NC\n[\h \#] \w > " ;;
        * )
            PS1="[\A - \$LOAD]\n[\h \#] \w > " ;;
    esac
}
powerprompt     # this is the default prompt - might be slow
                # If too slow, use fastprompt instead....
#===============================================================
#
# ALIASES AND FUNCTIONS
#
# Arguably, some functions defined here are quite big
# (ie ’lowercase’) but my workstation has 512Meg of RAM, so .....
# If you want to make this file smaller, these functions can
# be converted into scripts.
#
# Many functions were taken (almost) straight from the bash-2.04
# examples.
#
#===============================================================
#-------------------
# Personnal Aliases
#-------------------
alias rm=’rm -i’
alias cp=’cp -i’
alias mv=’mv -i’
# -> Prevents accidentally clobbering files.
alias mkdir=’mkdir -p’
alias h=’history’
alias j=’jobs -l’
alias r=’rlogin’
alias which=’type -all’
alias ..=’cd ..’
alias path=’echo -e ${PATH//:/\\n}’
alias print=’/usr/bin/lp -o nobanner -d $LPDEST’   # Assumes LPDEST is defined
alias pjet=’enscript -h -G -fCourier9 -d $LPDEST’  # Pretty-print using enscript
alias background=’xv -root -quit -max -rmode 5’    # Put a picture in the background
alias du=’du -kh’
alias df=’df -kTh’
# The ’ls’ family (this assumes you use the GNU ls)
alias la=’ls -Al’               # show hidden files
alias ls=’ls -hF --color’        # add colors for filetype recognition
alias lx=’ls -lXB’              # sort by extension
alias lk=’ls -lSr’              # sort by size
alias lc=’ls -lcr’                # sort by change time  
alias lu=’ls -lur’                # sort by access time   
alias lr=’ls -lR’               # recursive ls
alias lt=’ls -ltr’              # sort by date
alias lm=’ls -al |more’         # pipe through ’more’
alias tree=’tree -Csu’                # nice alternative to ’ls’
# tailoring ’less’
alias more=’less’
export PAGER=less
export LESSCHARSET=’latin1’
export LESSOPEN=’|/usr/bin/lesspipe.sh %s 2>&-’ # Use this if lesspipe.sh exists
export LESS=’-i -N -w  -z-4 -g -e -M -X -F -R -P%t?f%f \
:stdin .?pb%pb\%:?lbLine %lb:?bbByte %bb:-...’
# spelling typos - highly personnal :-)
alias xs=’cd’
alias vf=’cd’
alias moer=’more’
alias moew=’more’
alias kk=’ll’
#----------------
# a few fun ones
#----------------
function xtitle ()
{
    case "$TERM" in
        *term | rxvt)
            echo -n -e "\033]0;$*\007" ;;
        *)  
            ;;
    esac
}
# aliases...
alias top=’xtitle Processes on $HOST && top’
alias make=’xtitle Making $(basename $PWD) ; make’
alias ncftp="xtitle ncFTP ; ncftp"
# .. and functions
function man ()
{
    for i ; do
        xtitle The $(basename $1|tr -d .[:digit:]) manual
        command man -F -a "$i"
    done
}
function ll(){ ls -l "$@"| egrep "^d" ; ls -lXB "$@" 2>&-| egrep -v "^d|total "; }
function te()  # wrapper around xemacs/gnuserv
{
    if [ "$(gnuclient -batch -eval t 2>&-)" == "t" ]; then
        gnuclient -q "$@";
    else
        ( xemacs "$@" &);
    fi
}
#-----------------------------------
# File & strings related functions:
#-----------------------------------
# Find a file with a pattern in name:
function ff() { find . -type f -iname ’*’$*’*’ -ls ; }
# Find a file with pattern $1 in name and Execute $2 on it:
function fe() { find . -type f -iname ’*’$1’*’ -exec "${2:-file}" {} \;  ; }
# find pattern in a set of filesand highlight them:
function fstr()
{
    OPTIND=1
    local case=""
    local usage="fstr: find string in files.
Usage: fstr [-i] \"pattern\" [\"filename pattern\"] "
    while getopts :it opt
    do
        case "$opt" in
        i) case="-i " ;;
        *) echo "$usage"; return;;
        esac
    done
    shift $(( $OPTIND - 1 ))
    if [ "$#" -lt 1 ]; then
        echo "$usage"
        return;
    fi
    local SMSO=$(tput smso)
    local RMSO=$(tput rmso)
    find . -type f -name "${2:-*}" -print0 | xargs -0 grep -sn ${case} "$1" 2>&- | \
sed "s/$1/${SMSO}\0${RMSO}/gI" | more
}
function cuttail() # cut last n lines in file, 10 by default
{
    nlines=${2:-10}
    sed -n -e :a -e "1,${nlines}!{P;N;D;};N;ba" $1
}
function lowercase()  # move filenames to lowercase
{
    for file ; do
        filename=${file##*

喜欢本文,那就收藏到:

    Del.icio.us Google书签 Digg Live Bookmark Technorati Furl Yahoo书签 Facebook 百度搜藏 新浪ViVi 365Key网摘 天极网摘 和讯网摘 博拉网 POCO网摘 添加到饭否 QQ书签 Digbuzz我挖网
相关评论  我也要评论
还没有关于此文章的相关评论!
  • 昵称: (为空则显示guest)
  • 评论分数: ★ ★ ★★★ ★★★★ ★★★★★
  • 评论内容:(不能超过250字,需审核后才会公布,请自觉遵守互联网相关政策法规。
  • 导航
    赞助商
    文章类别
    订阅