如何获取sudo的密码 [英] How to get password for sudo
问题描述
我正在尝试对PostgreSQL使用命令sudo -i -u postgres
,而Google Compute Engine VM要求我提供我的帐户密码(不是root).
I'm trying to use the command sudo -i -u postgres
for PostgreSQL, and the Google Compute Engine VM is asking me for my password for my account (not root).
由于我从未发出过密码,而且我总是通过SSH密钥登录服务器,因此我不确定该密码是什么,如何重设密码或在何处可以找到密码.
As I never issued a password, and I always login to my server via SSH key, I'm not sure what the password is, how I can reset it, or where it can be found.
请告诉我在哪里可以获取密码?
Please tell me where I can get my password?
推荐答案
要成为GCE VM上的另一个非root用户,请首先通过无密码的sudo
成为root
(因为这是配置sudo
的方式)在GCE VM映像上):
To become another non-root user on a GCE VM, first become root
via password-less sudo
(since that's how sudo
is configured on GCE VM images):
sudo su -
,然后切换到您要成为的用户或将命令作为另一种用途使用,例如,在您的情况下,是:
and then switch to the user you want to become or run a command as another use, e.g., in your case, that's:
sudo -i -u postgres
这篇关于如何获取sudo的密码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!