-- 方法一
[root@node06 day02]# [ $USER = "root" ] && echo yes || echo no
yes
[tom@node06 ~]$ [ $USER = "root" ] && echo yes || echo no
no
-- 方法二
[root@node06 day02]# [ $UID -eq 0 ] && echo yes || echo no
yes
[tom@node06 ~]$ [ $UID -eq 0 ] && echo yes || echo no
no
-- 方法三
[root@node06 day02]# [ `id -u` -eq 0 ] && echo yes || echo no
yes
[tom@node06 ~]$ [ `id -u` -eq 0 ] && echo yes || echo no
no
-- 方法四
[root@node06 day02]# [ `whoami` = "root" ] && echo yes || echo no
yes
[tom@node06 ~]$ [ `whoami` = "root" ] && echo yes || echo no
no
10-12
1369
07-03
913
08-16
695