Debian

查看版本

$ lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description:    Debian GNU/Linux 7.8 (wheezy)
Release:        7.8
Codename:       wheezy

软件源

# 常用源
# MIRRORS=mirrors.163.com
# MIRRORS=mirrors.ustc.edu.cn
# MIRRORS=debian.cn99.com
MIRRORS=mirrors.aliyun.com
# 备份源配置
cp /etc/apt/sources.list /etc/apt/sources.list.bak
echo "deb http://${MIRRORS}/debian wheezy main contrib non-free" > /etc/apt/sources.list
echo "deb-src http://${MIRRORS}/debian wheezy main contrib non-free" >> /etc/apt/sources.list
echo "deb http://${MIRRORS}/debian wheezy-proposed-updates main contrib non-free" >> /etc/apt/sources.list
echo "deb-src http://${MIRRORS}/debian wheezy-proposed-updates main contrib non-free" >> /etc/apt/sources.list
echo "deb http://${MIRRORS}/debian wheezy-updates main contrib non-free" >> /etc/apt/sources.list
echo "deb-src http://${MIRRORS}/debian wheezy-updates main contrib non-free" >> /etc/apt/sources.list
# 更新源
apt-get update
# 安装常用软件
apt-get install -y bash-completion vim ntpdate fail2ban screen sysv-rc-conf
# 编译环境
apt-get install -y gcc make
# 更新系统时间
ntpdate-debian

移除不需要服务

/etc/init.d/rpcbind stop
update-rc.d -f rpcbind remove
/etc/init.d/nfs-common stop
update-rc.d -f nfs-common remove
/etc/init.d/cups stop
update-rc.d -f cups remove
/etc/init.d/avahi-daemon stop
update-rc.d -f avahi-daemon remove
/etc/init.d/bluetooth stop
update-rc.d -f bluetooth remove

ssh

echo "UseDNS no" >> /etc/ssh/sshd_config

bash

echo "export PS1='\[\e[33m\][\u@\h]\[\e[m\] \[\e[31m\]\w\[\e[m\] \e[33m\$(if [ -d .git ]; then echo \"\";git log --pretty=format:"%Cred%h%Creset -%C\(yellow\)%d%Creset %s %Cgreen\(%cr\)%Creset" -n 1 2>/dev/null; fi)\e[m\n$ '" >> /etc/bash.bashrc
echo "if [ 'screen' == $TERM ]; then" >> /etc/bash.bashrc
echo "    PATHTITLE='\[\ek\W\e\\\]'" >> /etc/bash.bashrc
echo "    PROGRAMTITLE='\[\ek\e\\\]'" >> /etc/bash.bashrc
echo "    PS1=\"${PROGRAMTITLE}${PATHTITLE}${PS1}\"" >> /etc/bash.bashrc
echo "fi" >> /etc/bash.bashrc
 
echo "export PROMPT_COMMAND='echo -ne \"\033]0;\${USER}@\${HOSTNAME}: \${PWD}\007\"'" >> /etc/bash.bashrc
echo "alias lh='ls -lh --color=auto --full-time --time-style=long-iso'" >> /etc/bash.bashrc
echo "alias mysql='mysql --default-character-set=utf8'" >> /etc/bash.bashrc
echo "if [ -f /etc/bash_completion ]; then" >> /etc/bash.bashrc
echo "    . /etc/bash_completion" >> /etc/bash.bashrc
echo "fi" >> /etc/bash.bashrc
echo "EDITOR=vim" >> /etc/bash.bashrc
echo "export TIME_STYLE='+%Y-%m-%d %H:%M:%S'" >> /etc/bash.bashrc

vim

echo "set nocompatible" >> /etc/vim/vimrc
echo "set backspace=2" >> /etc/vim/vimrc
echo "syntax on" >> /etc/vim/vimrc
echo "set tabstop=4" >> /etc/vim/vimrc
echo "set expandtab" >> /etc/vim/vimrc
echo "set softtabstop=4" >> /etc/vim/vimrc
echo "\"set autoindent" >> /etc/vim/vimrc
echo "\"set nu" >> /etc/vim/vimrc
echo "set hlsearch" >> /etc/vim/vimrc
echo "set incsearch" >> /etc/vim/vimrc
echo "set mouse=" >> /etc/vim/vimrc
echo "set nowrap" >> /etc/vim/vimrc
echo "set nobackup" >> /etc/vim/vimrc
echo "let &termencoding=&encoding" >> /etc/vim/vimrc
echo "set fileencodings=utf-8,gb18030,gbk,gb2312,big5" >> /etc/vim/vimrc
echo "au BufReadPost * if line(\"'\\\"\") > 0|if line(\"'\\\"\") <= line(\"$\")|exe(\"norm '\\\"\")|else|exe \"norm $\"|endif|endif" >> /etc/vim/vimrc

screen

echo "startup_message off" >> /etc/screenrc
echo "defscrollback 4096" >> /etc/screenrc
echo "caption always \"%{=u .G} %-w%<%{=ub .y}%n %t%{=u .G}%+w \"" >> /etc/screenrc
echo "bindkey \"^[\`\" select 0" >> /etc/screenrc
echo "bindkey \"^[1\" select 1" >> /etc/screenrc
echo "bindkey \"^[2\" select 2" >> /etc/screenrc
echo "bindkey \"^[3\" select 3" >> /etc/screenrc
echo "bindkey \"^[4\" select 4" >> /etc/screenrc
echo "bindkey \"^[5\" select 5" >> /etc/screenrc
echo "bindkey \"^[6\" select 6" >> /etc/screenrc
echo "bindkey \"^[7\" select 7" >> /etc/screenrc
echo "bindkey \"^[8\" select 8" >> /etc/screenrc
echo "bindkey \"^[9\" select 9" >> /etc/screenrc
echo "bindkey \"^[0\" select 10" >> /etc/screenrc
echo "bindkey \"^[-\" select 11" >> /etc/screenrc
echo "bindkey \"^[=\" select 12" >> /etc/screenrc
echo "bindkey -k k; prev" >> /etc/screenrc
echo "bindkey -k F1 windowlist -b" >> /etc/screenrc
echo "bindkey -k F2 next" >> /etc/screenrc
echo "termcapinfo xterm* ti@:te@echo" >> /etc/screenrc
echo "shelltitle '|Bash'" >> /etc/screenrc

SSH KEY

# 为方便登录使用添加SSH自动登录公钥
mkdir ~/.ssh
echo 'ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA22KMTLh//6xrz6Ch5OfYgNlQO6V/OjoNPo6QqCysT60BKIgPbqvlFEbVOYXmmRxjjE4uIa8X4lqC6eH+fI1A4knNbnN+EwjWNBg8ErIFLv2gxCbv/OSvYMerYK9OUm5EqsOYCXIPnzo+84qT0WQ3uwx6Tio1M3eeOPqIZ6liDt3iMgjCJQT7FDIwGB8z5aG41ft01qXzlMn1JxyVVoGE+fhe1Vn98WpPXQgvUkU1b6KIq2XYAfzPCi/Lzy7fVZgy33eCwZYSu9To7+ex1SrTf1z21gIYmJ8t48qc1Hd+T+7AhEzMgU2piNOaWI8eljR1LbYepD4AJQq8840dfdk6AQ== hk' >> ~/.ssh/authorized_keys
chmod -R 0700 ~/.ssh