小编use*_*825的帖子

如何在没有 su 到 root 的情况下测试 /root 中的文件是否存在?

我的操作系统是 Ubuntu 14.04 LTS。我得到了一个文件/root/1.txt,并使用“yu”登录,他没有对该文件的读取权限。

当我使用代码时if [ -e /root/1.txt ],它返回false。我知道我可以su - root用来更改用户并获得正确的结果。

我的问题是:没有 ,我怎么能做到这一点su - root?有没有办法解决这种情况sudo

我已经解决了这种情况 test

sudo test -e /root/1.txt &&echo "the file is exist" ||echo "the file isn't exist"

shell root files

3
推荐指数
1
解决办法
2276
查看次数

标签 统计

files ×1

root ×1

shell ×1