用户权限
[root@oldboyedu59 ~]# grep oldboy /etc/sudoers
oldboy ALL=(ALL) /bin/ls, /bin/touch
[oldboy@oldboyedu59 ~]$ sudo -l
[sudo] password for oldboy:
User oldboy may run the following commands on oldboyedu59:
(ALL) /bin/ls, /bin/touch
[oldboy@oldboyedu59 ~]$ ls /root/
ls: cannot open directory /root/: Permission denied
[oldboy@oldboyedu59 ~]$ sudo ls /root/
alex anaconda-ks.cfg dir-032 dir-035 file-032 file-035 oldboydir oldboy.txt pass.txt passwd.txtdd2 sed.sed
sudo练习题 :
给oldboy配置sudo可以查看系统的日志 (思考查看日志有什么命令)
/bin/grep, /bin/head, /bin/tail, /bin/less, /bin/more, /bin/cat
[root@oldboyedu59 ~]# grep oldboy /etc/sudoers
oldboy ALL=(ALL) /bin/ls, /bin/touch
oldboy ALL=(ALL) /bin/grep, /bin/head, /bin/tail, /bin/less, /bin/more, /bin/cat
给oldboy配置可以运行/bin下面所有命令
oldboy ALL=(ALL) /bin/*
给oldboy配置可以运行/bin下面所有命令但是不能使用vi和su
oldboy ALL=(ALL) /bin/*, !/bin/vi, !/bin/su, !/bin/rm
给oldboy配置可以运行系统中所有命令并且不需要再输入oldboy密码
oldboy ALL=(ALL) NOPASSWD: ALL
排错能力:[故障集合]Linux必备故障及原因50个
https://www.jianshu.com/p/99ec5bb4183f
[root@oldboyedu59 ~]# ll /var/log/messages* /var/log/secure* /var/log/cron*
-rw------- 1 root root 8767 Apr 26 11:01 /var/log/cron
-rw-------. 1 root root 13697 Apr 22 09:36 /var/log/cron-20190422
-rw------- 1 root root 268052 Apr 26 11:01 /var/log/messages
-rw-------. 1 root root 790356 Apr 22 09:36 /var/log/messages-20190422
-rw------- 1 root root 23140 Apr 26 10:42 /var/log/secure
-rw-------. 1 root root 17169 Apr 22 08:48 /var/log/secure-20190422
定时的切割
系统定时对系统日志 进行切割(日志切割/日志轮询) 防止单个日志过大
[root@oldboyedu59 ~]# ll /etc/cron.daily/
total 8
-rwx------. 1 root root 219 Oct 31 03:12 logrotate
-rwxr-xr-x. 1 root root 618 Oct 30 22:55 man-db.cron
[root@oldboyedu59 ~]# cat /etc/logrotate.d/syslog
/var/log/cron
/var/log/maillog
/var/log/messages
/var/log/secure
/var/log/spooler
{
missingok
sharedscripts
postrotate
/bin/kill -HUP `cat /var/run/syslogd.pid 2> /dev/null` 2> /dev/null || true
endscript
}
每天8:30 开始上课(go to school)
30 08 * * * go to school
每天晚上12点带远导去 dbj
每个月的1号晚上11点带guoav去看av (kan)
0 2 * * 1 /data/postmall/shell/a.sh表示什么含义?
每天晚上12点带远导去 dbj
- 00 * * * dbj #半夜12点00到半夜12点59分 每分钟一次
00 00 * * * dbj #每天的半夜12点整
每个月的1号晚上11点带guoav去看av (kan)
00 23 01 * * kan
0 2 * * 1 /data/postmall/shell/a.sh表示什么含义?
每周1的凌晨2点整 执行脚本
定时任务特殊符号:
- 每
- /
- echo oldboy >>/tmp/oldboy.txt
*/1 * * * * echo oldboy >>/tmp/oldboy.txt
- echo oldboy >>/tmp/oldboy.txt
日志中只能显示 定时任务是否运行 无法查看是否出错
Apr 26 12:32:01 oldboyedu59 CROND[7921]: (root) CMD (date >>/tmp/time.log)
Apr 26 12:34:01 oldboyedu59 CROND[7926]: (root) CMD (date >>/tmp/time.log)
Apr 26 12:36:01 oldboyedu59 CROND[7930]: (root) CMD (date >>/tmp/time.log)
Apr 26 12:38:01 oldboyedu59 CROND[7935]: (root) CMD (date >>/tmp/time.log)
Apr 26 12:40:01 oldboyedu59 CROND[7950]: (root) CMD (date >>/tmp/time.log)
什么时间 root用户的定时任务 CMD 执行的命令或脚本
今日提示集合:
"/etc/sudoers.tmp" 125L, 4588C written
>>> /etc/sudoers: syntax error near line 105 <<<
语法错误 在105行
[sudo] password for oldboy:
Sorry, user oldboy may not run sudo on oldboyedu59.
[root@oldboyedu59 ~]# crontab -l
no crontab for root
root用户没有定时任务
2.no crontab for root - using an empty one
root用户没有定时任务 创建1个空的文件
3.crontab: installing new crontab
更新定时任务规则
mei liangfenzhong xianshi xitong shijian zhuijiadao /tmp/oldboy.txt
* /1 * * * date >>/tmp/oldboy.txt
"/tmp/crontab.5UZIdI" 3L, 115C written
crontab: installing new crontab
"/tmp/crontab.5UZIdI":3: bad hour
errors in crontab file, can't install.
Do you want to retry the same edit?
*/1 * * * * date >>/tmp/oldboy.txt
网友评论