Tag Archives: linux

Linux 制作批量命令处理的脚本

当每次维护linux的VPS之类的时候,需要输入很多行命令是一件令人纠结的事情。这里通过建立脚本,让命令批量运行,解约工作的效率。 Linux下的批处理文件,基本就是shell脚本文件。 1.一个最简单的脚本书写方法为: 新建一个文件,名字为test,在里面编写 rm -fv *.o;ls -al; (可以写一些shell普通命令,命令用分号隔开) 2.执行方法 (1)在控制台输入: sh test (2)先给与脚本可执行权限: chmod 777 test 最好修改为可执行  然后直接执行: ./test

Posted in 系统 | Tagged , , | Leave a comment

使用密匙证书登录Linux,增强系统安全

在服务器或者VPS上,单独的使用密码登录SSH,很容易引起系统的不安全。这里,通过密匙,就好比给自己的家中从输入密码,变成了密码+钥匙,安全系数提高。 登录服务器,输入:ssh-keygen -t rsa 这个时候出现 Enter file in which to save the key (/root/.ssh/id_rsa): Created directory ‘/root/.ssh’. Enter passphrase (empty for no passphrase): 回车第一行后,是给证书增设密码,可以回车,或者敲入密码。 执行:cat ~/.ssh/id_rsa.pub > ~/.ssh/authorized_keys 然后,把你~/.ssh/id_rsa文件下载到自己的电脑上,下载一个puttygen程序,载入这个id_rsa文件,保存save private key,就有了一个.ppk为后缀的密匙了。 这个时候,还需要对系统进行设置,修改/etc/ssh/sshd_config,将PasswordAuthentication yes改为PasswordAuthentication no 最后重启/etc/init.d/sshd restart即可。

Posted in 系统 | Tagged , , , , | Leave a comment

Linux 防ddos脚本

能抵御一般DDOS的脚本 安装: wget http://www.inetbase.com/scripts/ddos/install.sh chmod +x install.sh ./install.sh 如需卸载则: wget http://www.inetbase.com/scripts/ddos/uninstall.shch mod +x uninstall.sh ./uninstall.sh 然后就安装成功了.对于一般的ddos应该没问题了.

Posted in 随笔 | Tagged , , | Leave a comment

Linux查看系统配置常用命令

系统 # uname -a               # 查看内核/操作系统/CPU信息 # head -n 1 /etc/issue   # 查看操作系统版本 # cat /proc/cpuinfo      # 查看CPU信息 # hostname               # 查看计算机名 # lspci -tv              # 列出所有PCI设备 # lsusb -tv              # 列出所有USB设备 # lsmod                  # 列出加载的内核模块 # env                    # 查看环境变量 … Continue reading

Posted in 系统 | Tagged , | Leave a comment

Linux下用Crontab来实现PHP的定时运行

以test.php为例 按正常的方式写PHP,然后在第一行前加一行”#!/usr/local/bin/php -q” #!/usr/local/bin/php -q <? $file = ‘/htdocs/www/b100/egspace/Bin/test/’.date(‘H’).’-’.date(‘i’).’-’.date(‘s’).’.txt’; file_put_contents($file,date(‘Y-m-d’)); ?> 把PHP文件属性改为shell文件。 chmod +x test.php 再编辑crontab crontab -e 加上一行 */1 * * * * /htdocs/www/b100/egspace/Bin/test.php

Posted in 系统 | Tagged , | 1 Comment