Getting 'permission denied' error while accessing /root folder in Oracle Cloud Infrastructure. How to resolve?

huangapple go评论66阅读模式
英文:

Getting 'permission denied' error while accessing /root folder in Oracle Cloud Infrastructure. How to resolve?

问题

我无法访问/root文件夹。我应该怎么做才能获得访问权限?

我尝试过 su - root,但它要求密码,而我没有密码。我是使用SSH私钥连接到这台服务器的。

我想要向root文件夹写入一些内容。

感谢任何帮助。

英文:

I can't access the /root folder. What should I do to gain access?

I tried su - root but it asked for a password which I don't have. I connected to this server using SSH private key.

I want to write something to the root folder.

Any help is appreciated.

答案1

得分: 1

假设您的查询与 OCI Compute Instance 相关,那么请在使用默认用户 opc 登录计算实例后尝试以下命令:sudo su -

这是因为在 /etc/sudoers 文件中有相应的条目。

  1. [opc@ameen ~]$ pwd
  2. /home/opc
  3. [opc@ameen ~]$ ls
  4. [opc@ameen ~]$ cd /root
  5. -bash: cd: /root: 权限被拒绝
  6. [opc@ameen ~]$ sudo su -
  7. [root@ameen ~]# cd /root
  8. [root@ameen ~]# ls
  9. [root@ameen ~]# logout
  10. [opc@ameen ~]$
英文:

Assuming your query is related to OCI Compute Instance then please try the command sudo su - after you login to your compute instance using default opc user.

This works because of the entry in /etc/sudoers file.

  1. [opc@ameen ~]$ pwd
  2. /home/opc
  3. [opc@ameen ~]$ ls
  4. [opc@ameen ~]$ cd /root
  5. -bash: cd: /root: Permission denied
  6. [opc@ameen ~]$ sudo su -
  7. [root@ameen ~]# cd /root
  8. [root@ameen ~]# ls
  9. [root@ameen ~]# logout
  10. [opc@ameen ~]$

huangapple
  • 本文由 发表于 2023年6月1日 16:46:12
  • 转载请务必保留本文链接:https://go.coder-hub.com/76380132.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定