Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I need to fix Ubuntu Accounts somehow but I don't really see how it could be done.

The problem is: files /etc/passwd and /etc/hostname and /etc/hosts where changed.

/etc/passwd

Before

serg:x:1000:1000:John,,,:/home/serg:/bin/bash

After

John:x:1000:1000:John,,,:/home/serg:/bin/bash

/etc/hosts

Before

127.0.0.1       localhost
127.0.1.1       serg-Protege

After

127.0.0.1       localhost
127.0.1.1       John-The-Ripper

/etc/hostname

After

John-The-Ripper

Before

serg-PORTEGE-Z835

I was trying to simply change these files but can not do this because permission denied. When I'm trying to log in as root, I got this message:

John@John-The-Ripper:~$ sudo -s
[sudo] password for John: 
John is not in the sudoers file.  This incident will be reported

The file sudoers is empty:

John@John-The-Ripper:~$  vi /etc/sudoers

When I type users in cp:

John@John-The-Ripper:~$ users
John John

When I type id, I got this:

John@John-The-Ripper:~$ id
uid=1000(John) gid=1000(serg) groups=1000(serg)

This doesn't work eather:

John@John-The-Ripper:~$ usermod -l John serg
usermod: user 'serg' does not exist
John@John-The-Ripper:~$ adduser serg
adduser: Only root may add a user or group to the system.
ater.

Then I tried to go to the GRUB menu and log in as root from there. I did this, but however When I tried to create user serg, It gave me an error that group already exists. When I tried to change /etc/passwd it said 'permission denied'

And this doesn't do the trick: John@John-The-Ripper:~$ visudo

visudo: /etc/sudoers: Permission denied
visudo: /etc/sudoers: Permission denied

Also The last thing I tried to do is to create a bootable USB and reinstall ubuntu, however I can not open USB-Creator because it asked me a root password. But it doesn't work.

HELP ME PLEASE =)))

share|improve this question

migrated from stackoverflow.com Sep 25 '12 at 16:02

This question came from our site for professional and enthusiast programmers.

    
A bit off topic, but if you add "John" to the line in /etc/group that most likely now says sudo:x:27:serg, you should be able to sudo again. Alternately, remove the line that says serg:x:1000 or similar from the same file and you should be able to once again create the serg user. When you're root again, just add John to all lines in /etc/group that now say serg and all should be back to normal. –  Joachim Isaksson Sep 25 '12 at 14:36
    
It's not working, I can not change these file because 'Error writing group: Permission denied' –  Vor Sep 25 '12 at 14:50
1  
This is not a programming question; you should ask it on a more appropriate site such as askubuntu.com or unix.stackexchange.com. –  eaj Sep 25 '12 at 14:52

1 Answer 1

The problem is that you no longer have root access, so you don't have permission to change those files. The /etc/sudoers file checks your user name, not your numeric UID; it probably still refers to user "serg" rather than user "John". And Ubuntu generally doesn't have a password for the root account, depending instead on sudo, which requires your password, not root's.

Shut down your system, then boot it into single-user mode. This will give you a shell with root privileges. From there, you can carefully edit the necessary files. (To state the obvious, be careful; it's easy to trash your system from a root shell.) Double-check that everything is back to the way you want it (no typos), then reboot into normal mode.

See here for instructions on booting into single-user mode.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.