Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

This question already has an answer here:

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

root:x:0:0:root:/root:/sbin/nologin

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 not physical access to server. I have not users in sudoers file.

OS: Linux 2.6.24-23-server

Can you please help me to login as root?

share|improve this question

marked as duplicate by Michael Hampton, mdpc, Grant, James O'Gorman, Ward Apr 6 '13 at 4:10

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

add comment

2 Answers

Boot the system from a Live CD, from which you can mount the filesystem and edit the etc/passwd file.

share|improve this answer
add comment

or via grub, add to the end of the kernel line:

init=/bin/bash

That should do it too. You may need to mount the filesystem read-write before the edit:

mount -o rw,remount /
share|improve this answer
add comment

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