[root@Rsync day1]# vi checkroot.sh
#!/bin/bash
#检查是否是root用户
if [ $UID -ne 0 ];then
ehco Non root user. Please run as root.
else
echo "Root user"
fi
保存退出
[root@Rsync day1]# bash checkroot.sh
Root user
[root@Rsync day1]#
来源:oschina
链接:https://my.oschina.net/u/4399905/blog/4841631