Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I edited the file /etc/passwd on my server in the following way:


Now I can not login as root. When I enter the su command, Cannot execute /sbin/nologin: No such file or directory is displayed in console.

I have no physical access to the server. I have no users in the sudoers file.

Can you please help me to log in as root?

share|improve this question
Is this an Ubuntu system at all? – guntbert Apr 5 '13 at 18:52

If you don't have any sudoers - you are screwed up :)

I'm afraid you will need to have a physical access and a Live CD/USB to fix this problem.

share|improve this answer
In addition to @Andrejs answer, if you do have a sudoer simply sudo /bin/bash and edit the /etc/passwd back to normal. – RobotHumans Apr 5 '13 at 16:33
Sadly not an option in this case. "I have not users in sudoers file" – Hennes Apr 5 '13 at 16:54

You have a few options to recover from this:

  1. Log in with another user with sufficient rights to correct this. This obviously requires a second user with sufficient rights, but that is not that uncommon if the server has multiple admins. (Each with their username and admin account).
  2. Boot from another OS (e.g. a live CD or pen drive. mount the disk and correct the shell for root. (Trivial to do if you have physical access, but you wrote that this is not the case).
  3. Boot from another OS (e.g. a live CD or pen drive. mount the disk and correct the shell for root while accessing the console remotely via DRAC, ILO, or similar. The latter is common enough for servers and you can even point to a local ISO file to act as a fake CD.
  4. Start the server with in single user mode. (e.g in GRUB add single or 1 to the kernel parameters. This will drop you into a shell. Then ask someone local to change the shell for you. (or in case of DRAC/ILO change it yourself).
  5. If you have a user with the right to shutdown the server,but no to edit /etc/passwd. shut down the server to runlevel 1. That will drop the server to single user mode and you can edit the setting from the console (once again needing HP's ILO, Dell DRAC or similar).
  6. If you have a second OS (or a rescue install) on that server, then boot that and edit the files.

Example picture of a console seen via DRAC

Regardless of what you do: Never log out when you make such changes.
Test them first (e.g. start a second connection).

share|improve this answer
Sadly none of the options has the solution in case if there are no sudoers or physical access. – Andrejs Cainikovs Apr 5 '13 at 18:27
Aye. You need real physical access (even if only a local help from a datacenter which enters two or three commands), or 'remote physical' access (You really want DRACs in remote servers. Really. But that only help you when you choose the next server), or a way to recover with a reboot (e.g. via remote power and a reboot into a know safe OS). If none of those precautions are taken or you do not have those options then there is but one option left: Go over there and fix it. :( – Hennes Apr 5 '13 at 19:27

Your Answer


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.