寻觅生命中的那一片浅草......

文章带标签 Linux

What is Firewall Builder?

Firewall Builder helps you write and manage configuration for your firewalls. It writes iptables commands, pf.conf file, Cisco router access lists or PIX configuration for you. You can then copy and paste configuration generated by Firewall Builder, copy the file manually or using your own scripts, or use built-in function to configure the firewall. Firewall Builder provides change control and search functions. It allows you to reuse the same address and service objects in rules of many firewalls. It simplifies coordinated changes of the rules in multi-vendor environments and helps avoid errors in generated configurations.

Firewall Builder comes with all versions of Debian Linux and Ubuntu (in “Universe”). It is also available in “extras” in Fedora Core Linux and in FreeBSD and OpenBSD ports. Packages for these OS are supported by corresponding maintainers. We build test packages for all these OS and distributions as well. Binary packages are available for Windows and Mac OS X

使用pushme.to做手机报警

下个手机客户端,然后注册个pushme.to的帐号,比如:ourlinux,然后就可以通过pushme的接口进行发消息了。

HTML代码如下:

linux下简单的执行如下:

curl -o /dev/null -d “nickname=ourlinux&signature=OWL&submit=%20OK%20&&message=test” http://pushme.to/ourlinux/

记得将ourlinux改成自己的接收的账号!

这样就可以将报警的信息通过pushme来发送了!

其他的不说了,很简单,一看就明白了!

感谢joe推荐使用pushme!

转载自:http://www.ourlinux.net/operation-tips/use-pushmeto/

统计几个目录大小的sh

#!/bin/bash
#目录名类似于20100315,20100315long,20100316,20100316zhong,20100317等
#用法 sh count_dir_size.sh 日期最小数,日期最大数
#如果是2010-03-15到2010-03-17,则sh count_dir_size.sh 2010-03-15 2010-03-17
#Author johncan,2010-03-22
#COUNT_DATE=`date “+%Y%m%d” |cut -c1-5`
if [ -z “$1” ]
then
echo “please use $0 start_day end_day”
exit 1
fi

#将开始时间转换成时间戳
STA_TIME=`date -d “$1” +%s`
#将结束时间转换成时间戳
END_TIME=`date -d “$2” +%s`

cd /dir_which_files_are_stored

DR_TIME=${STA_TIME}
while [ “${DR_TIME}” -le “${END_TIME}” ]
do
#将时间戳转换为目录名的格式
STAND_DR_TIME=`date -d “1970-01-01 UTC ${DR_TIME} seconds” +%Y%m%d`
for DR in ${STAND_DR_TIME}*
do
#统计目录大小
DR_SIZE=`du -s ${DR} | awk ‘{print $1}’`
let “COUNT_DR_SIZE=${COUNT_DR_SIZE}+${DR_SIZE}”
done
let “DR_TIME=${DR_TIME}+86400”
done
echo ${COUNT_DR_SIZE}KB

禁止通过IP访问Jboss

cd /your_install_dir/jbossweb-tomcat50.sar/
/bin/cp server.xml server.xml.100323
vi server.xml

先修改默认的8080端口

<Service name=”jboss.web”
className=”org.jboss.web.tomcat.tc5.StandardService”>

<!– A HTTP/1.1 Connector on port 8080 –>
<!– The compression parameters are taken from the default Tomcat server.xml–>
<Connector port=”8080″ address=”${jboss.bind.address}”

将port=”8080″修改为port=”8888″

禁止通过IP访问,只允许通过域名访问

在<Host name=”localhost”
autoDeploy=”false” deployOnStartup=”false” deployXML=”false”>
前添加一个IP命名的virtual host

假如服务器IP是192.168.0.100,则添加的host如下

<Host name=”192.168.0.100″>
<Valve className=”org.apache.catalina.valves.RemoteAddrValve” deny=”0.0.0.0″/>
</Host>

现在启动Jboss,就不能通过IP访问了,只能通过域名,但任何解析到192.168.0.100的域名都可以访问
有机会再研究下只绑定一个域名的情况

参考:http://xuliangyong.javaeye.com/blog/410148

shell字符串的截取

shell字符串的截取的问题:
一、Linux shell 截取字符变量的前8位,有方法如下:
1.expr substr “$a” 1 8
2.echo $a|awk ‘{print substr(,1,8)}’
3.echo $a|cut -c1-8
4.echo $
5.expr $a : ‘\(.\\).*’
6.echo $a|dd bs=1 count=8 2>/dev/null

二、按指定的字符串截取
1、第一种方法:
${varible##*string} 从左向右截取最后一个string后的字符串
${varible#*string}从左向右截取第一个string后的字符串
${varible%%string*}从右向左截取最后一个string后的字符串
${varible%string*}从右向左截取第一个string后的字符串
“*”只是一个通配符可以不要

例子:
$ MYVAR=foodforthought.jpg
$ echo ${MYVAR##*fo}
rthought.jpg
$ echo ${MYVAR#*fo}
odforthought.jpg

2、第二种方法:${varible:n1:n2}:截取变量varible从n1到n2之间的字符串。

可以根据特定字符偏移和长度,使用另一种形式的变量扩展,来选择特定子字符串。试着在 bash 中输入以下行:
$ EXCLAIM=cowabunga
$ echo ${EXCLAIM:0:3}
cow
$ echo ${EXCLAIM:3:7}
abunga

这种形式的字符串截断非常简便,只需用冒号分开来指定起始字符和子字符串长度。

三、按照指定要求分割:
比如获取后缀名
ls -al | cut -d “.” -f2
转载自:http://tech.foolpig.com/2008/07/09/linux-shell-char/

2025年五月
« 5月    
 1234
567891011
12131415161718
19202122232425
262728293031