在腳本中,判斷執行者是否為root。
判斷方法1,
#!/bin/bash if [ `whoami` != "root" ];then echo " only root can run me" exit 1 fi
判斷方法2(但是用sudo執行回報腳本有語法錯誤,不知為何,有知道的高手請回復我)。
if [ $UID == 0 ];then echo "you are root" fi
在腳本中,判斷執行者是否為root。
判斷方法1,
#!/bin/bash if [ `whoami` != "root" ];then echo " only root can run me" exit 1 fi
判斷方法2(但是用sudo執行回報腳本有語法錯誤,不知為何,有知道的高手請回復我)。
if [ $UID == 0 ];then echo "you are root" fi
本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。