Warning: Undefined array key "cperpage" in /www/wwwroot/www.now163.com/wp-content/themes/typology/functions.php on line 230

Warning: Undefined variable $output in /www/wwwroot/www.now163.com/wp-content/themes/typology/functions.php on line 300

Warning: Undefined variable $fixed_tags in /www/wwwroot/www.now163.com/wp-content/themes/typology/functions.php on line 301

Warning: Undefined variable $isshowdots in /www/wwwroot/www.now163.com/wp-content/themes/typology/functions.php on line 302

Warning: Undefined variable $tag_aditional in /www/wwwroot/www.now163.com/wp-content/themes/typology/functions.php on line 305

Warning: Undefined variable $tag_aditional in /www/wwwroot/www.now163.com/wp-content/themes/typology/functions.php on line 308

Warning: Undefined variable $tag_aditional in /www/wwwroot/www.now163.com/wp-content/themes/typology/functions.php on line 311

Warning: Undefined variable $post in /www/wwwroot/www.now163.com/wp-content/themes/typology/functions.php on line 320

Warning: Attempt to read property "ID" on null in /www/wwwroot/www.now163.com/wp-content/themes/typology/functions.php on line 320

Warning: Undefined variable $post in /www/wwwroot/www.now163.com/wp-content/themes/typology/functions.php on line 320

Warning: Attempt to read property "ID" on null in /www/wwwroot/www.now163.com/wp-content/themes/typology/functions.php on line 320

Warning: Undefined variable $more_text_link in /www/wwwroot/www.now163.com/wp-content/themes/typology/functions.php on line 320
Shell – 理想社会

CategoryShell

批量设置用户quota磁盘配额

1、先给一个已存在的用户建好配额: a:修改/etc/fstab文件(如:LABEL=/     /  ext3  defaults,usrquota,grquota    1   1) b:重新启动系统使设置生效:reboot c:创建配额文件:quotacheck -cmug / (查看已建立的配额文件:ls /aquota.*) d:设置配额:edquota -u 用户名 使用quota -u 用户名查询配额 repquota -u /  显示配额 quotaoff |on -auvg关闭或开启配额 2、#users=`awk ‘BEGIN {FS=”:”} {if ($3>500) print $1}’ /etc/passwd`(第一个和最后一个符号是 `反撇号即esc下面的键) 3、显示上面的赋值:echo $users...

Linux下批量创建删除账号

L

1、批量创建用户 cat adduser.sh #!/bin/bash # for username in $(more users.list) do if [ -n $username ] then useradd $username -g student -d /pub/home/$username echo echo $username"xyz" | passwd --stdin $username chage -d 0 $username echo $username "has been created!" else echo "The username is null!" fi done 2、批量删除用户 cat deluser.sh #!/bin/bash # for username in $(more users.list) do if [ -n $username ]...

L2TP 一键安装包

L

这是 L2TP over IPSec Server 一键安装包的发布页,此安装包首发于 VPSYou.com
当前版本:1.2

发行版
版本
兼容性

CentOS
5.2 32/64bit
测试通过

CentOS
5.3 32/64bit
测试通过

CentOS
5.4 32/64bit
测试通过

CentOS
5.5 32/64bit
测试通过

Ubuntu
9.10 Karmic 32/64bit
测试通过

Ubuntu
10.04 Lucid 32/64bit
测试通过

Debian
5.0 Lenny 32/64bit
测试通过

Fedora
13 32/64bit
测试通过

VPS自动备份数据到Dropbox

V

一 设置Dropbox
由于Dropbox强大的API,在不使用客户端的同时,可以使用第三方脚本直接上传文件。对比官方客户端运行起来上百M的内存占用,这个小小的脚本完全可以满足我们的需求。
Dropbox-Uploader
将脚本下载到使用目录,运行,此时根据提示设置自己的Dropbox应用API(就像申请Twitter API一样简单),然后按照步骤设置,然后就可以使用其命令上传/下载文件了

自动备份网站文件和数据库上传到FTP空间

#!/bin/bash #你要修改的地方从这里开始 MYSQL_USER=root #mysql用户名 MYSQL_PASS=123456 #mysql密码 MAIL_TO=cat@hostloc.com #数据库发送到的邮箱 FTP_USER=cat #ftp用户名 FTP_PASS=123456 #ftp密码 FTP_IP=imcat.in #ftp地址 FTP_backup=backup #ftp上存放备份文件的目录,这个要自己得ftp上面建的 WEB_DATA=/home/www #要备份的网站数据 #你要修改的地方从这里结束 #定义数据库的名字和旧数据库的名字 DataBakName=Data_$(date +"%Y%m%d").tar.gz WebBakName=Web_$(date +%Y%m%d).tar.gz OldData=Data_$(date -d -5day...

iptables开启ftp规则

i

设置了iptables的禁止所有的端口,只容许可能访问了策略后大部分情况下会出现ftp不能正常访问的问题,因为ftp有主动和被动连接两种模式,少添加一些策略就会出问题。 首先要加载ftp模块 modprobe ip_conntrack_ftp modprobe ip_nat_ftp 然后加载策略 iptables -A OUTPUT -m state --state RELATED,ESTABLISHED -j ACCEPT iptables -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT iptables -I INPUT -p tcp --dport 21 -j ACCEPT iptables -I OUTPUT -p tcp --dport 21 -j ACCEPT 要是不想每次都加载模块的话...

用awk统计正在连接的ip

方法一
netstat -antp | awk -F"[ :]+" '/80/{a[$6]}END{for(i in a)print i|"sort -n"}'
方法二
netstat -antp | grep 80 | awk '{print $5}' | cut -d":" -f1 | sort -n | awk -F'.' '!a[$NF]++'
netstat -antp | grep 80 | awk '{print $5}' | cut -d":" -f1 | sort -n | awk -F'.' '!a[$NF]++' | wc -l

Netstat命令详解 如何关闭TIME_WAIT连接 如何查看nginx的访问流量

N

做计算机管理员,我们都必要了解一下netstat这个命令,它是一个查看网络连接状态的工具,在windows下也默认有这个工具。
Netstat命令详解 netstat命令怎样使用 如何关闭TIME_WAIT连接 如何统计web服务器的访问量 如果查看nginx的访问流量?
下面我们来看看它主要的用法和详解!
(netstat -na 命令),本文主要是说Linux下的netstat工具,然后详细说明一下各种网络连接状态。
netstat -nat |awk ‘{print $6}’|sort|uniq -c|sort -nr
1.netstat命令详解
其实我常用的是 netstat -tnl | grep 443 (查看443端口是否被占用),如果有当前是root用户,我喜欢用netstat -pnl | grep 443 (还可显示出占用本机443端口的进程PID)。

特殊的shell变量

特殊的shell变量:
$0 获取当前执行的shell脚本的文件名
$n 获取当前执行的shell脚本的第n个参数值,n=1..9
$* 获取当前shell的所有参数 “$1 $2 $3 …注意与$#的区别
$# 获取当前shell命令行中参数的总个数
$$ 获取当前shell的进程号(PID)
$! 执行上一个指令的PID
$? 获取执行的上一个指令的返回值(0 为成功, 非零为失败)
$@ 这个程序的所有参数 “$1″ “$2″ “$3″ “…”

《SED单行脚本快速参考》的awk实现

sed和awk都是linux下常用的流编辑器,他们各有各的特色,本文并不是要做什么对比,而是权当好玩,把《SED单行脚本快速参考》这文章,用awk做了一遍~
至于孰好孰坏,那真是很难评论了。一般来说,sed的命令会更短小一些,同时也更难读懂;而awk稍微长点,但是if、while这样的,逻辑性比较强,更加像“程序”。到底喜欢用哪个,就让各位看官自己决定吧!
PS: 貌似这个配色,单行的代码多了以后,拖动的时候会有点眼花的感觉,将就下吧,呵呵。
文本间隔:
——–
# 在每一行后面增加一空行
sed G
awk '{printf("%snn",$0)}'
# 将原来的所有空行删除并在每一行后面增加一空行。
# 这样在输出的文本中每一行后面将有且只有一空行。

Your sidebar area is currently empty. Hurry up and add some widgets.