好啦。从今天开始我们转入shell编程的行列。从鸟哥私房菜中,已经学到了一些shell编程的皮毛,这两个月打算系统的学习,学会,学熟练。加油吧

bash shell

 

[root@localhost shellscript]# chmod +x hello.sh
[root@localhost shellscript]# sh hello.sh
hello world
[root@localhost shellscript]# vim hello.sh
#!bin/bash
#这是第一个shell
#echo "hello world"

cp /dev/null /var/log/apache/access.log    利用/dev/null来清空 apache2的日志文件    /dev/null我们再鸟哥的书中看到过。我也查过,就是个黑洞,垃圾箱

做一个每天凌晨6点清空日志文件的shell

[root@localhost shellscript]# cp hello.sh clearlog.sh
[root@localhost shellscript]# chmod +x clearlog.sh
[root@localhost shellscript]# cat chearlog.sh
cat: chearlog.sh: 没有那个文件或目录
[root@localhost shellscript]# cat clearlog.sh
#!bin/bash
#这是第一个shell
#echo "hello world"

cp /dev/null /var/log/apache/access.log
[root@localhost shellscript]# crontab -u root -e
0 6 * * * /root/shellscript/cleanlog.sh
~

 

 

 

第三章

 

登录远程主机

shh -l 用户名+IP

shh 用户名@+IP

ssh +IP 默认root登录

 文件+目录

在鸟哥的书中已经有介绍。不多讲,其中有关管道的还有点嚼头

 

 

查看文档类型

ls -la   列出所有文件all

 ls-ld   列出目录文件 d 

file 查找

file +路径

查找当前的工作路径 

pwd 命令

 

posted on 2019-09-19 16:12  孤独斗士  阅读(157)  评论(0编辑  收藏  举报