Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
让 IPython 脚本检查用户当前是否为 root 的正确方法是什么?
以下是我在 bash 脚本中的操作方式:
if [ $(id -u) != "0" ];then echo "This script must be run as root." exit 1 fi
有没有比使用“!id”或“!whoami”更好的方法?
在 *nix 操作系统上geteuid(),os模块中有.
geteuid()
os