0
[root@NewHost shell]# vim sum_of_custom_user.sh
#!/bin/bash
custom_user_sum=`cat /etc/passwd|awk -F':' '$3>499'|wc -l`
echo "The number of custom user is $custom_user_sum"
#!/bin/bash
custom_user_sum=`cat /etc/passwd|awk -F':' '$3>499'|wc -l`
echo "The number of custom user is $custom_user_sum"
0
for n in `awk -F ":" '{print $3}' /etc/passwd`;do [ $n -ge 500 ] && cat /etc/passwd|grep $n|awk -F ":" '{print $1}';done
0
#!/bin/bash
count=`awk -F ':' '$3>=500 && $6~"/home.*"' /etc/passwd |wc -l`
if [ $count -eq 0 ]
then
echo "No normal user."
else
echo $count
fi
count=`awk -F ':' '$3>=500 && $6~"/home.*"' /etc/passwd |wc -l`
if [ $count -eq 0 ]
then
echo "No normal user."
else
echo $count
fi
0
#!/bin/bash
for i in `awk -F ':' '{if ($3>=500) print $1}' /etc/passwd`
do
echo $i >> 1.txt //新建文件
done
echo "系统中存在`wc -l ptu.txt |awk '{print $1}'`个普通用户"
for i in `awk -F ':' '{if ($3>=500) print $1}' /etc/passwd`
do
echo $i >> 1.txt //新建文件
done
echo "系统中存在`wc -l ptu.txt |awk '{print $1}'`个普通用户"
0
#! /bin/bash
#检测/etc/passwd中是否含有uid>500的用户
n=`awk -F ':' '$3>500 {print $1}' /etc/passwd |wc -l`
if [ -n $n ]
then
echo "There are $n general users in the system."
fi
#检测/etc/passwd中是否含有uid>500的用户
n=`awk -F ':' '$3>500 {print $1}' /etc/passwd |wc -l`
if [ -n $n ]
then
echo "There are $n general users in the system."
fi
0
#!/bin/bash
uid=`cat /etc/passwd |awk -F ':' '{print $3}'`
a=0
for i in $uid
do
if [ $i -ge 500 ]
then
usr=`cat /etc/passwd |awk -F ':' '$3>=500 {print $1}'`
fi
done
echo $usr
for b in $usr
do
let a=a+1
done
echo "This is system has $a custom users"
uid=`cat /etc/passwd |awk -F ':' '{print $3}'`
a=0
for i in $uid
do
if [ $i -ge 500 ]
then
usr=`cat /etc/passwd |awk -F ':' '$3>=500 {print $1}'`
fi
done
echo $usr
for b in $usr
do
let a=a+1
done
echo "This is system has $a custom users"
0
!/bin/bash
Description: This script is to check system if exists other users except root.
Author: Jiazhi Yang
Date: 20/11/2016
Script Name: checkuser.sh
number=`awk -F':' '($3 >=500)' /etc/passwd |wc -l`
if [ $number -ne 0 ]; then
echo -e "There are $number non-root users on your system."
else
echo -e "There are not general users on your system."
fi
0
for i in `awk -F ':' '{print $3}' /etc/passwd`
do
if [ $i -gt 499 ]
then
echo $i
fi
done
# sh filename.sh |wc -l
for i in `awk -F ':' '{print $3}' /etc/passwd`;do if [ $i -gt 500 ]; then echo $i;fi ; done |wc -l
#! /bin/bashfor i in `awk -F ':' '{print $3}' /etc/passwd`
do
if [ $i -gt 499 ]
then
echo $i
fi
done
# sh filename.sh |wc -l
编辑回复