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.
ユーザーが現在rootであるかどうかを確認するためにIPythonスクリプトをチェックさせる正しい方法は何ですか?
これがbashスクリプトでそれを行う方法です:
if [ $(id -u) != "0" ];then echo "This script must be run as root." exit 1 fi
「!id」や「!whoami」を使うより良い方法はありますか?
* nix OSではgeteuid()、osモジュールにあります。
geteuid()
os