いますぐ実践!Linuxシステム管理テスト(f) - careerbeat/dit-ehime GitHub Wiki

≪Dさん≫

PermitRootLogin yes
PermitRootLogin no

≪Eさん≫

準備
[dojo]$ touch -t 201702060000 0206.txt 
[dojo]$ touch -t 201702050000 0205.txt
[dojo]$ touch -t 201702040000 0204.txt
[dojo]$ touch -t 201702030000 0203.txt
[dojo]$ touch -t 201702020000 0202.txt
[dojo]$ touch -t 201702010000 0201.txt
[dojo]$ touch -t 201701310000 0131.txt
[dojo]$ touch -t 201701300000 0130.txt
[dojo]$ touch -t 201701290000 0129.txt
[dojo]$ touch -t 201701280000 0128.txt
[dojo]$ find . -mtime XX -delete

≪Fさん≫

[root]# cat sample.txt
server1,1343363124,30,/video.php
server2,1343363110,20,/profile.php
server3,1343363115,7,/login.php
server1,1343363105,8,/profile.php
server2,1343363205,35,/profile.php
server2,1343363110,20,/profile.php
server3,1343363205,30,/login.php
server4,1343363225,12,/video.php
server1,1343363265,7,/video.php

≪Iさん≫

[root]# cat /etc/hosts.allow
in.telnetd : ALL : spawn (/usr/bin/logger -i -p auth.info \%d\: allow case) &

[root]# cat /etc/hosts.deny
in.telnetd : ALL : spawn (/usr/bin/logger -i -p auth.info \%d\: deny case) &

≪Jさん≫

[root]# cat /etc/hosts.allow
in.telnetd : 192.168.1.

[root]# cat /etc/hosts.deny
ALL : ALL

≪Kさん≫

[root]# tail -n 1 /etc/rsyslog.conf
*.notice /var/log/notice

[root]# logger -p ftp.crit Dive
[root]# logger -p tcp.warn Windows
[root]# logger -p rsyslog.alert Cheap
[root]# logger -p local8.alert Long
[root]# logger -p security.err ni
[root]# logger -p ftp.debug CentOS
[root]# logger -p *.warn he
[root]# logger -p security.alert Deep
[root]# logger -p ssh.warn wo
[root]# logger -p mail.warn Linux
[root]# logger -p demon.crit Drive

≪Lさん≫

[dojo]$ cat exampleLog.sh 
#!/bin/bash

infolog() {
  msg=$1
  logger $msg
}

infolog '@Tokyo'
[dojo]$ ./exampleLog.sh @Osaka

≪Mさん≫

[root]# cat /etc/rsyslog.conf
$template mytemplate,"%timegenerated% %hostname% %programname% %syslogpriority-text% %msg%\n"
#authpriv.*                                             /var/log/secure ←コメントアウト  
authpriv.*                                              /var/log/secure;mytemplate
[root]# tail -f /var/log/secure
Feb  6 09:49:52 dojo sshd 【A】  Failed password for root from ::1 port 42838 s

≪Nさん≫

mysql> SELECT facility, priority,message FROM SystemEvents;
facility priority message
【 A 】 【 B 】 Failed password for root from ::1 port 42900 ssh

≪Oさん≫

mysql> SELECT facility, priority,message FROM SystemEvents;
facility priority message
【 A 】 【 B 】 HASE Comming soon

≪Pさん≫

[root]# cat /etc/rsyslog.conf
$template template2,"%timegenerated:1:4:date-rfc3339%/%timegenerated:6:7:date-rfc3339%/%timegenerated:9:10:date-rfc3339% %timegenerated:12:19:date-rfc3339% %msg%\n"
local0.* /var/log/custom.log;template2

≪Qさん≫

[root]# cat -n ./example.sh
     1	#!/bin/sh
     2	expect -c "
     3	        spawn ssh localhost
     4	        expect \"s password:\"
     5	        send \"vagrant\n\"
     6	        expect \"~]\"
     7	        send \"echo \\\$HENSU \n\"
     8	        expect \"~]\"
     9	        send \"exit\n\"
    10	        expect \"~]\"
    11	"
[root]# export HENSU="HOGE HOGE"
[root]# ./example.sh

≪Rさん≫

[root]# cat -n ./example.sh
     1	#!/bin/sh
     2	expect -c "
     3	        spawn ssh localhost
     4	        expect \"s password:\"
     5	        send \"vagrant\n\"
     6	        expect \"~]\"
     7	        send \"HENSU=aaa \n\"
     8	        expect \"~]\"
     9	        send \"echo \\\$HENSU \n\"
    10	        expect \"~]\"
    11	        send \"exit\n\"
    12	        expect \"~]\"
    13	"
[root]# export HENSU="bbb"
[root]# ./example.sh

≪Tさん≫

[root]# cd /var/www/html
[root]# git clone https://github.com/koujinogaku/sysgraph.git

≪Uさん≫

[root]# mkdir hoge
[root]# touch hoge/sample1.txt
[root]# inotifywait -m hoge &
[root]# cd hoge
[root]# cp -p sample1.txt sample2.txt