0

I accidentally messed up the permissions of the file system, which shows the message sudo: /usr/local/bin/sudo must be owned by uid 0 and have the setuid bit set when attempting to use sudo, such as read protected files, etc.

Response from this answer (https://askubuntu.com/a/471503) suggest to login as root to do so, however I didn't setup a root password before and this answer (https://stackoverflow.com/a/35017164/4343317) suggest me to use sudo passwd. Obviously I am stuck in an infinite loop from the two answers above.

How can I read/get the files from Google Cloud Compute Engine's disk without logging in into the VM (I have full control of the VM instance and the disk as well)? Is there another "higher" way to login as root (such as from gcloud tool or the Google Cloud interface) to access the VM disk externally?

Thanks.

Jamie Phan
  • 796
  • 1
  • 7
  • 26
  • Since you have messed up the file system, your only practical option is to attach the persistent disk to another VM instance and copy off your files. Linux is very sensitive to file system permissions. You have trashed your system. – John Hanley Jun 11 '19 at 01:14

1 Answers1

1

It looks like the following recipe may be of value:

https://cloud.google.com/compute/docs/disks/detach-reattach-boot-disk

What this article says is that you can shutdown your VM, detach its boot disk and then attach it as a data disk to a second VM. In that second VM you will have the ability to make changes. However, if you don't know what changes you need to make to restore the system to sanity, then as @John Hanley says, we might want to use this mounting technique to copy of your work and then destroy your tainted VM and recreate a new one fresh and copy back in your work and start from there.

Kolban
  • 13,794
  • 3
  • 38
  • 60