我常用的Linux设置
1. 修改shell提示信息
PS1="[\u@\[\033[1;34m\w/\]\[\033[00m\]]\$ "
或
PS1='[\u@$PWD\]'
或
PS1='\[\e[37;40m\][\[\e[32;40m\]\u\[\e[37;40m\]@\h \[\e[35;40m\]\W\[\e[0m\]]\$ '
#2.ls风格设置
alias ls="ls -Alh --time-style='+%Y-%m-%d %H:%M:%S'"
#or
alias ls="ls -Alh --time-style=long-iso"
3.iptables
alias ipt='iptables -nL`
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A INPUT -p icmp -j ACCEPT
iptables -A INPUT -i lo -j ACCEPT
iptables -A INPUT -p tcp -m tcp --dport 22-j ACCEPT
iptables -A INPUT -p tcp -m tcp --dport 80 -j ACCEPT
iptables -A INPUT -p tcp -m tcp --dport 443 -j ACCEPT
4.history历史记录保存日期时间用户
HISTTIMEFORMAT="%F %T `whoami` "
输出 2017-01-13 23:20:29 root history
5. 讨厌的的英国中部时间
yum install -y msgunfmt
msgunfmt /usr/share/locale/zh_CN/LC_MESSAGES/wget.mo -o - | sed 's/eta(英国中部时间)/ETA/' | msgfmt - -o /usr/share/locale/zh_CN/LC_MESSAGES/wget.mo
6.nginx切割日志 auto_split_nginx_log.sh
#!/bin/bash
logs_path="/home/wwwlogs/"
mv ${logs_path}xxx.com.log ${logs_path}/xxx.com-$(date -d "yesterday" +"%Y%m%d").log
kill -USR1 `cat /usr/local/nginx/logs/nginx.pid`
7.每小时记录流量
logfile=`date +"%Y%m%d"`.log
echo `date` >> $logfile
ifconfig eth0 |grep 'RX p' >>$logfile
8.XShell 设置好看的背景
文件->默认回话属性->外观->配色方案编辑->背景->其他->规定自定义颜色->红绿蓝分别设为0,50,100
9.history文件记录时间
#写入/etc/bashrc
export HISTTIMEFORMAT="%F %T `whoami` "
export HISTFILESIZE=20000
附录
- 远程密令通过iptables临时开启ssh端口_不懂博客
- iptables防火墙recent模块使用方法示例详解_不懂博客