Ubuntu: Getting sudo access as guest
Solution 1
ctrl+alt+F1 and start TTY > login with your account and use sudo privileges
Solution 2
You can use single user mode or append init=/bin/bash
to your boot entry to login to a root shell
Doug
Updated on September 18, 2022Comments
-
Doug over 1 year
I installed Ubuntu Linux 12.04 a little while ago to try it out and play around with it (hence I have no idea what I'm doing). I tried changing my home directory by editing the
/etc/passwd
file, however I must have put in a bad value as I can no longer login to my account. Whenever I try it boots me out to the login screen before I can make it to the desktop. The only other account is guest (I hadn't gotten around to disabling it yet), and I can login to that just fine.Since I know which file I screwed up, I can edit it back to what it was and hopefully login again. However, since this is a system file, it requires
sudo
access to modify, which I don't have as a guest. Is there any workaround where I can somehow getsudo
access as guest so I can edit this file and login as myself again? Obviously I don't intend to leave that ability on guest, that would be silly.I remember reading somewhere that I could ssh to localhost as a user with
sudo
privileges, however I keep getting "connection refused". I believe it needs to be installed, and I hadn't gotten to that, and I can't do it now withoutsudo
anyways...I did install Linux alongside Windows 7, so if there's some way to edit it via Windows, I could do that (though from my understanding Windows can't read the file system).
-
ganesh over 10 yearsAre there any other users on the system with sudo or root rights? Alternatively, can you boot in single user mode to fix it ?
-
Doug over 10 yearsOh wow, I was able to boot into single user mode (never heard of that before) and got root access. I just did
vi /etc/passwd
and changed the file back to what it should be. Restarted and could login. Worked like a charm. -
ganesh over 10 yearsAnother nice command to lean is
vipw
(It does sanity checks, preventing some typos from locking you or any other user out).
-