gpt4 book ai didi

bash - 如果在 Bash 中,我该如何 sudo?

转载 作者:行者123 更新时间:2023-11-29 08:51:53 25 4
gpt4 key购买 nike

我需要检查另一个用户的主目录中的目录。通常我会 sudo 但这会 fork 另一个进程,我也会失去我的环境。

例如,我有:

if [[ -d "/home/otheruser/svn" ]];
then
echo "SVN exists"
else
echo "SVN does not exist"
fi

我需要测试条件以 root 权限运行。

最佳答案

if sudo test -d "/home/otheruser/svn"; then

关于bash - 如果在 Bash 中,我该如何 sudo?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10641233/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com