2

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 get sudo 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 without sudo 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).

Hennes
  • 64,768
  • 7
  • 111
  • 168
Doug
  • 161
  • 2
  • 2
  • 3
  • Are there any other users on the system with sudo or root rights? Alternatively, can you boot in single user mode to fix it ? – Hennes Sep 07 '13 at 23:24
  • Oh wow, I was able to [boot into single user mode](http://www.cyberciti.biz/faq/grub-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. – Doug Sep 07 '13 at 23:40
  • Another nice command to lean is `vipw` (It does sanity checks, preventing some typos from locking you or any other user out). – Hennes Sep 07 '13 at 23:46

3 Answers3

2

You can use single user mode or append init=/bin/bash to your boot entry to login to a root shell

justbrowsing
  • 2,659
  • 16
  • 16
2

ctrl+alt+F1 and start TTY > login with your account and use sudo privileges

here is one example

IvanS
  • 21
  • 1
0

You can boot from the live-cd and chroot into your installation and then change the password. Instructions to do so can be found here.

headkase
  • 1,900
  • 2
  • 14
  • 20