[root@tom ~]# find / \( -nouser -o -nogroup \) -a -ls | wc -l
find: `/proc/21565/task/21565/fd/5': No such file or directory
find: `/proc/21565/task/21565/fd/5': No such file or directory
find: `/proc/21565/task/21565/fdinfo/5': No such file or directory
find: `/proc/21565/task/21565/fdinfo/5': No such file or directory
find: `/proc/21565/fd/5': No such file or directory
find: `/proc/21565/fd/5': No such file or directory
find: `/proc/21565/fdinfo/5': No such file or directory
find: `/proc/21565/fdinfo/5': No such file or directory
1842
Next step
[root@tom ~]# find / \( -nouser -o -nogroup \) -a -atime -3 -ls | wc -l
find: `/proc/21574/task/21574/fd/5': No such file or directory
find: `/proc/21574/task/21574/fdinfo/5': No such file or directory
find: `/proc/21574/fd/5': No such file or directory
find: `/proc/21574/fdinfo/5': No such file or directory
214
5、查找/etc目录下大于1M,且类型为普通文件的所有文件;
[root@tom ~]# find /etc -size +1M -type f -exec ls -lh {} \;
-rw-r--r--. 1 root root 8.1M Dec 16 16:43 /etc/selinux/targeted/modules/active/policy.kern
-rw-r--r--. 1 root root 8.1M Dec 16 16:43 /etc/selinux/targeted/policy/policy.24
-rw-r--r--. 1 root root 2.2M Dec 16 16:10 /etc/gconf/gconf.xml.defaults/%gconf-tree.xml
[root@tom ~]# cp /etc/rc.d/rc.sysinit /tmp
[root@tom ~]# ls -lh /tmp
total 24K
drwx------. 2 root root 4.0K Dec 11 19:18 pulse-0QUeAoK4lJM6
-rwxr-xr-x. 1 root root 20K Feb 12 17:07 rc.sysinit
[root@tom ~]# head -n 20 /tmp/rc.sysinit !/bin/bash# /etc/rc.d/rc.sysinit - run once at boot time# Taken in part from Miquel van Smoorenburg's bcheckrc.HOSTNAME=$(/bin/hostname)
set -m
if [ -f /etc/sysconfig/network ]; then
. /etc/sysconfig/network
fi
if [ -z "$HOSTNAME" -o "$HOSTNAME" = "(none)" ]; then
HOSTNAME=localhost
fi
if [ ! -e /proc/mounts ]; then
mount -n -t proc /proc /proc
[root@tom ~]# vim /tmp/rc.sysinit在末行模式下输入:
:%s@^[[:space:]]\+@#&@g
[root@tom ~]# head -n 20 /tmp/rc.sysinit !/bin/bash# /etc/rc.d/rc.sysinit - run once at boot time# Taken in part from Miquel van Smoorenburg's bcheckrc.HOSTNAME=$(/bin/hostname)
set -m
if [ -f /etc/sysconfig/network ]; then. /etc/sysconfig/network
fi
if [ -z "$HOSTNAME" -o "$HOSTNAME" = "(none)" ]; thenHOSTNAME=localhost
fi
if [ ! -e /proc/mounts ]; thenmount -n -t proc /proc /proc
[root@tom ~]# head -n 20 /tmp/rc.sysinit !/bin/bash/etc/rc.d/rc.sysinit - run once at boot timeTaken in part from Miquel van Smoorenburg's bcheckrc.HOSTNAME=$(/bin/hostname)
set -m
if [ -f /etc/sysconfig/network ]; then
. /etc/sysconfig/network
fi
if [ -z "$HOSTNAME" -o "$HOSTNAME" = "(none)" ]; then
HOSTNAME=localhost
fi
if [ ! -e /proc/mounts ]; then
mount -n -t proc /proc /proc
[root@tom ~]# head -n 20 /tmp/rc.sysinit !/bin/bash# /etc/rc.d/rc.sysinit - run once at boot time# Taken in part from Miquel van Smoorenburg's bcheckrc.HOSTNAME=$(/bin/hostname)
set -m
if [ -f /etc/sysconfig/network ]; then. /etc/sysconfig/network
fi
if [ -z "$HOSTNAME" -o "$HOSTNAME" = "(none)" ]; thenHOSTNAME=localhost
fi
if [ ! -e /proc/mounts ]; thenmount -n -t proc /proc /proc
[root@tom ~]# vim /tmp/rc.sysinit在末行模式下输入:
:%s@^#[[:space:]]\+@@g
[root@tom ~]# head -n 20 /tmp/rc.sysinit !/bin/bash/etc/rc.d/rc.sysinit - run once at boot timeTaken in part from Miquel van Smoorenburg's bcheckrc.HOSTNAME=$(/bin/hostname)
set -m
if [ -f /etc/sysconfig/network ]; then
. /etc/sysconfig/network
fi
if [ -z "$HOSTNAME" -o "$HOSTNAME" = "(none)" ]; then
HOSTNAME=localhost
fi
if [ ! -e /proc/mounts ]; then
mount -n -t proc /proc /proc
[root@tom ~]# cat /etc/yum.repos.d/CentOS-Media.repo CentOS-Media.repo# This repo can be used with mounted DVD media, verify the mount point forCentOS-6. You can use this repo and yum to install items directly off theDVD ISO that we release.# To use this repo, put in your DVD and use it with the other repos too:yum --enablerepo=c6-media [command]# or for ONLY the media repo, do this:# yum --disablerepo=\ --enablerepo=c6-media [command]
[c6-media]
name=CentOS-$releasever - Media
baseurl=file:///media/CentOS/
file:///media/cdrom/
file:///media/cdrecorder/
gpgcheck=1
enabled=0
gpgkey=
[root@tom ~]# vi /etc/yum.repos.d/CentOS-Media.repo 在末行模式下输入:
[root@tom ~]# crontab -e
no crontab for root - using an empty one
crontab: installing new crontab
[root@tom ~]# crontab -lBackup /var/log/messages to /backup/messages_logs/ at every week 2,4,6 --sam
* 2,4,6 cp /var/log/messages backup/messages_logs/messages-$(date +%Y%m%D)
[root@tom ~]# crontab -e
crontab: installing new crontab
[root@tom ~]# crontab -lBackup /var/log/messages to /backup/messages_logs/ at every week 2,4,6 --sam
* 2,4,6 cp /var/log/messages backup/messages_logs/messages-$(date +%Y%m%D)每天每两小时取当前系统/proc/meminfo文件中的所有以S开头的信息至/stats/memory.txt文件中
/2 * * cat /proc/meminfo | grep "^S" >> /stats/memory.txt
13、写一个脚本创建10用户user10-user19;密码同用户名;
[root@tom bin]# vim uadd!/bin/bashadd user10-user19.
for ((i=10;i<=19;i++));do
id user$i &> /dev/null && exit0 || useradd user$i && echo "user$i" | passwd --stdin user$i
done
[root@tom bin]# ll
total 4
-rw-r--r--. 1 root root 155 Feb 12 18:02 uadd
[root@tom bin]# chmod 755 uadd
[root@tom bin]# ll
total 4
-rwxr-xr-x. 1 root root 155 Feb 12 18:02 uadd
[root@tom bin]# uadd
Changing password for user user10.
passwd: all authentication tokens updated successfully.
Changing password for user user11.
passwd: all authentication tokens updated successfully.
Changing password for user user12.
passwd: all authentication tokens updated successfully.
Changing password for user user13.
passwd: all authentication tokens updated successfully.
Changing password for user user14.
passwd: all authentication tokens updated successfully.
Changing password for user user15.
passwd: all authentication tokens updated successfully.
Changing password for user user16.
passwd: all authentication tokens updated successfully.
Changing password for user user17.
passwd: all authentication tokens updated successfully.
Changing password for user user18.
passwd: all authentication tokens updated successfully.
Changing password for user user19.
passwd: all authentication tokens updated successfully.
[root@tom bin]# tail /etc/passwd
user10:x:3009:3009::/home/user10:/bin/bash
user11:x:3010:3010::/home/user11:/bin/bash
user12:x:3011:3011::/home/user12:/bin/bash
user13:x:3012:3012::/home/user13:/bin/bash
user14:x:3013:3013::/home/user14:/bin/bash
user15:x:3014:3014::/home/user15:/bin/bash
user16:x:3015:3015::/home/user16:/bin/bash
user17:x:3016:3016::/home/user17:/bin/bash
user18:x:3017:3017::/home/user18:/bin/bash
user19:x:3018:3018::/home/user19:/bin/bash