在/usr目录下找出大小超过10MB的文件
find /usr -size +10M
在/home目录下找出120天之前被修改过的文件
find /home -mtime +120
查找最后创建时间是三天前,后缀是*.log的文件并删除
find . -ctime +3 -name '*.log' | rm -rf
查找最后创建时间是4天前,名称中有20181104的文件
[root@zabbix ~]# date
Fri Nov 9 19:36:22 CST 2018
[root@zabbix ~]# find / -ctime +4 -name '*20181104'
/var/log/secure-20181104
/var/log/httpd/error_log-20181104
/var/log/httpd/access_log-20181104
/var/log/messages-20181104
/var/log/samba/old/log.smbd-20181104
/var/log/zabbix/zabbix_agentd.log-20181104
/var/log/zabbix/zabbix_server.log-20181104
/var/log/cron-20181104
/var/log/spooler-20181104
/var/log/maillog-20181104
/backup/mysqldb/20181104
查看当前服务器的运行级别
[root@zabbix ~]# who -r
run-level 3 2018-10-13 19:05
[root@zabbix ~]# runlevel
N 3
查看Linux的默认网关
[root@zabbix ~]# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 172.16.0.1 0.0.0.0 UG 100 0 0 eth0
169.254.169.254 172.16.0.3 255.255.255.255 UGH 100 0 0 eth0
172.16.0.0 0.0.0.0 255.255.240.0 U 100 0 0 eth0
[root@zabbix ~]# netstat -nr
Kernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt Iface
0.0.0.0 172.16.0.1 0.0.0.0 UG 0 0 0 eth0
169.254.169.254 172.16.0.3 255.255.255.255 UGH 0 0 0 eth0
172.16.0.0 0.0.0.0 255.255.240.0 U 0 0 0 eth0
如何识别Linux系统中指定文件(如/usr/bin/mysql)的关联包
[root@zabbix ~]# rpm -qf /usr/bin/mysql
mysql-community-client-5.7.23-1.el7.x86_64
显示文件名和它的拥有者
[root@zabbix ~]# ll
total 40
drwxr-xr-x 2 root root 4096 Oct 27 10:14 logs
drwxr-xr-x 2 root root 4096 Oct 27 09:54 logs?
-rw-r--r-- 1 root root 683 Oct 13 19:39 mysql_backup.sh
drwxrwxrwx 2 root root 4096 Oct 16 19:44 share
-rwxr-xr-x 1 root root 5282 Oct 23 19:37 sys_check.sh
-rwxr-xr-x 1 root root 5418 Oct 27 10:10 sys_check.sh_bak
drwxr--r-- 3 root root 4096 Oct 15 09:15 test
-rw-r--r-- 1 root root 25 Oct 25 16:31 test.txt
[root@zabbix ~]# ll | awk '{print $3,"owns",$9}'
owns
root owns logs
root owns logs
root owns mysql_backup.sh
root owns share
root owns sys_check.sh
root owns sys_check.sh_bak
root owns test
root owns test.txt
[root@zabbix ~]#
Linux如何挂载windows下的共享目录
mount.cifs //IP地址/server /mnt/server -o user=administrator,password=123456
生成8位随机密码
[root@zabbix ~]# cat /dev/urandom | head -1 | md5sum | head -c 8 > /pass
[root@zabbix ~]# cat /pass
3228d504
批量创建6个用户,用户名为user60-65,密码是用户名(user60-65)后面加5个随机字符
[root@zabbix ~]# cat adduser.sh
#!/bin/bash
#description: useradd
for i in `seq 60 65`
do
pwd=$(cat /dev/urandom | head -1 | md5sum | head -c 5)
useradd user$i
echo "user$i$pwd" | passwd --stdin user$i
echo user$i user$i$pwd >> userinfo.txt
done
[root@zabbix ~]#
[root@zabbix ~]# cat userinfo.txt
user60 user6092168
user61 user6162cd5
user62 user628da79
user63 user63bcd61
user64 user6423c2f
user65 user65d982b
判断192.168.1.0/24网络里,当前在线的IP有哪些,能ping通则认为在线
[root@zabbix ~]# cat ping.sh
#!/bin/bash
for ip in `seq 1 255`
do
ping -c 1 192.168.1.$ip > /dev/null 2>&1
if [ $? -eq 0 ]; then
echo 192.168.1.$ip UP
else
echo 192.168.1.$ip DOWN
fi
done
wait
[root@zabbix ~]#