最新内核+BBR支持
wget --no-check-certificate https://github.com/teddysun/across/raw/master/bbr.sh && chmod +x bbr.sh && ./bbr.sh
- ==在syslog内增加用户操作日志==
cat >>/etc/bashrc <<EOF
export PROMPT_COMMAND='{ msg=\\$(history 1 | { read x y; echo \\$y; });logger "[uid=\\$(whoami)]":\\$(who am i):[\\`pwd\\`]"\\$msg"; }'
EOF
export PROMPT_COMMAND='{ msg=$(history 1 | { read x y; echo $y; });logger "[uid=$(whoami)]":$(who am i):[`pwd`]"$msg"; }'
- ==vi命令状态下可以用上下键找过去用过的命令==
vi ~/.bashrc
#set -o vi
export PS1="\\[\\e[32;1m\\][\\[\\e[35;1m\\]\\u\\[\\e[m\\]@\\[\\e[36;1m\\]\\h \\[\\e[31;1m\\]\\W\\[\\e[32;1m\\]]\\[\\e[36;1m\\]\\\\$\\[\\e[m\\]"
export PS1="\\[\\e[37;1m\\][\\[\\e[35;1m\\]\\u\\[\\e[32;1m\\]@\\[\\e[34;1m\\]\\h \\[\\e[31;1m\\]\\w \\[\\e[33;1m\\]\\t\\[\\e[37;1m\\]]\\[\\e[32;1m\\]\\$\\[\\e[m\\]"
- ==grep颜色,vi=vim(代码有颜色)==
vi /etc/bashrc
#vim:ts=4:sw=4
alias vi='vim'
alias ls='ls --color=auto --time-style=long-iso'
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
- ==时区修改==
timedatectl set-timezone Brazil/West
timedatectl set-timezone Asia/Shanghai # 设置系统时区为上海
timedatectl set-local-rtc 1 # 将硬件时钟调整为与本地时钟一致, 0 为设置为 UTC 时间
cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime # 底层修改
- ==修改一些profile里面的设置==
vi /etc/profile
export TMOUT = 300 # 超时自动断开SSH连接
export HISTTIMEFORMAT="%Y-%m-%d %H:%M:%S " #history显示时间(export HISTTIMEFORMAT="[%Y-%m-%d %H:%M:%S] ")
USER_IP=`who -u am i 2>/dev/null| awk '{print $NF}'|sed -e 's/[()]//g'`
export HISTTIMEFORMAT="[%F %T][`whoami`][${USER_IP}] "
PROMPT_COMMAND=" history -a" #环境变量PROMPT_COMMAND会保存一条将被优先执行的命令,意思是说”history -a”命令将在用户执行命令前被优先执行,这将保证不管当前命令前一条是执行的什么,它将立即被追加进$HISTFILE,而不用等待整个会话结束再将历史命令从内存记录至硬盘。
shopt -s histappend #在shell中执行这个命令可以使shell保存历史命令的时候使用追加的方式,因为默认是覆盖,在多终端的情况下,最后退出的终端灰覆盖以前的历史记录
source /etc/profile
- ==禁用IPV6==
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
- ==增加第三方yum源== > EPEL是由Fedora社区打造,为RHEL及衍生发行版如CentOS、Scientific Linux等提供高质量软件包的项目。有了EPEL,就像在Fedora上一样,可以通过yum随意安装软件。很多源添加前也都要求添加这个算是“官方”的源。
rpm -ivh http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6
Remi源对于不想编译最新版的linux使用者,Remi源中的软件几乎都是最新稳定版,这些都是Linux骨灰级的玩家编译好放进源里的。包含最新版本 PHP 和 MySQL 包的 Linux 源 (需要安装epel源,安装说明)
https://rpms.remirepo.net/enterprise/remi-release-7.rpm
CentALT是俄罗斯的一个源,推荐它的主要目的是主要是能够下载最新版的apache、nginx和postfix,而且这个源只有不到100个RPM包,很少与别的源存在依赖冲突。
rpm -ivh http://centos.alt.ru/repository/centos/6/x86_64/centalt-release-6-1.noarch.rpm
如果您现在正在使用Fedora,对RPMFusion一定不陌生吧,各种音频软件如MPlayer在标准源中是没有的,一般先安装RPMFusion源,CentOS官方说RPMFusion软件库里面的软件稳定性不如rpmforge
rpm -ivh http://download1.rpmfusion.org/free/el/updates/6/x86_64/rpmfusion-free-release-6-1.noarch.rpm
rpm -ivh http://download1.rpmfusion.org/nonfree/el/updates/6/x86_64/rpmfusion-nonfree-release-6-1.noarch.rpm
Atomic Yum Repository 更新速度快 php,mysql,apache
wget -q -O - http://www.atomicorp.com/installers/atomic | sh
utterramblings Repository
这个yum源的安装方法也很简单,首先
vi /etc/yum.repos.d/utterramblings.repo,加入如下内容
[utterramblings]
name=Jason's Utter Ramblings Repo
baseurl=http://www.jasonlitka.com/media/EL$releasever/$basearch/
enabled=1
gpgcheck=1
gpgkey=http://www.jasonlitka.com/media/RPM-GPG-KEY-jlitka
保存退出后即可使用了。
注意有些源(rpmforge.repo )安装后需要vi /etc/yum.repos.d/remi.repo 将[remi] 中的 enabled=0 改成 enabled=1 来启用remi 源。全部安装完成后yum update一次
- ==实用插件==
yum install vim wget unzip net-tools iptraf bash-c* epel-release lrzsz -y
yum install bash-c* -y
#安装第三方源优先级插件(详见yum标签下文章)
yum install yum-plugin-priorities
#安装yum插件:卸载同时删除依赖(详见yum标签下文章)
yum install yum-remove-with-leaves
#centos的命令行的补全功能加强
yum install bash-completion
#centos检查提示不存在的命令
yum install PackageKit-command-not-found
#安装远程控制windows程序
yum install tsclient
md5-d9e228c180769645c5f031f4ab094550
systemctl disable libvirtd
service ip6tables stop
service postfix stop
service ntpd stop
service cups stop
service rpcbind stop
service rpcidmapd stop
service nfslock stop
chkconfig ip6tables off
chkconfig postfix off
chkconfig ntpd off
chkconfig cups off
chkconfig rpcbind off
chkconfig rpcidmapd off
chkconfig nfslock off
yum remove -y PackageKit mariadb* ekiga evolution brasero abrt* cups avahi libreoffice-* empathy* rhythmbox* cheese totem.x86_64 chrony
md5-26b50d57aa5a9c8a3b3f9e98ddd560f8
#!/bin/bash
#关闭selinux
setenforce 0
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
#history和bash的一些优化
cat >>/etc/profile <<EOF
#USER_IP=`who -u am i 2>/dev/null| awk '{print $NF}'|sed -e 's/[()]//g'`
#export HISTTIMEFORMAT="[%F %T][`whoami`][${USER_IP}][`pwd`] "
export HISTTIMEFORMAT="%Y-%m-%d %H:%M:%S "
PROMPT_COMMAND=" history -a"
shopt -s histappend
EOF
cat >>/etc/bashrc <<EOF
export PS1="\\[\\e[32;1m\\][\\[\\e[35;1m\\]\\u\\[\\e[m\\]@\\[\\e[36;1m\\]\\h \\[\\e[31;1m\\]\\W\\[\\e[32;1m\\]]\\[\\e[36;1m\\]\\\\$\\[\\e[m\\]"
alias vi='vim'
alias ls='ls --color=auto --time-style=long-iso'
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
EOF
rm -rf /etc/security/limits.d/20-nproc.conf
cat >>/etc/security/limits.conf <<EOF
* soft nproc 1048576
* hard nproc 1048576
* soft nofile 1048576
* hard nofile 1048576
root soft nofile 1048576
root hard nofile 1048576
root soft nproc 1048576
root hard nproc 1048576
EOF
#关闭IPV6
chmod +x /etc/rc.d/rc.local
#echo "NETWORKING_IPV6=no" >>/etc/sysconfig/network
sed -i '/localhost6/d' /etc/hosts
#cat > /etc/modprobe.d/ipv6.conf << EOF
#alias net-pf-10 off
#options ipv6 disable=1
#EOF
echo "net.ipv6.conf.all.disable_ipv6 = 1" >>/etc/sysctl.conf
echo "net.ipv6.conf.default.disable_ipv6 = 1" >>/etc/sysctl.conf
yum -y install epel-release
yum -y install python2-pip lrzsz bash-completion bash-completion-extras telnet wget rsync vim-enhanced zip unzip chrony crontabs lsof gcc gcc-c++ glibc libpcap-devel ncurses-devel psmisc net-tools iptables-services
yum update -y
### delete useless users
userdel adm
userdel ftp
userdel lp
userdel sync
userdel shutdown
userdel halt
userdel news
userdel uucp
userdel operator
userdel games
userdel gopher
groupdel adm
groupdel lp
groupdel news
groupdel uucp
groupdel games
groupdel dip
groupdel pppusers
### turn-off useless service
systemctl stop cups
systemctl stop postfix
systemctl stop sendmail
systemctl stop firewalld
systemctl disable cups
systemctl disable postfix
systemctl disable sendmail
systemctl disable firewalld