I manually edited the shell for root in /etc/passwd and I have a typo. Making it worse, I have no sudo user on the box.

So I have tried the following, with the following result:

$ su -s '/bin/bash chsh root' root
Cannot execute /usr/bin/scrrn: No such file or directory

(You see what I did, right? Ugh.)

I think it is because of this, from the man page:

If the target user has a restricted shell (i.e. the shell field of
this user's entry in /etc/passwd is not listed in /etc/shells),
then the --shell option or the $SHELL environment variable won't be
taken into account, unless su is called by root.

Maybe my question shouldn't be specifically about su -s but it's a place I can start.


A possibility is to boot your system in single user, or use a rescue boot USB key (related to your distribution) to correct the typo in /etc/passwd

On many Linux systems you could tell the GRUB boot loader to run a kernel witn init=/bin/bash argument. Once you did that you could re-edit carefully your /etc/passwd

BTW the right thing to do to change a shell is chsh but you really don't want to chsh to /usr/bin/screen for root

(you could create another account of uid 0 and shell /usr/bin/screen ; I am not sure it is a sensible thing to do ...)

At last, read carefully su(1) :

-s, --shell=shell

         Run the specified shell instead of the default.

So you should run /bin/su -s /bin/bash; notice that /bin/bash chsh root is not the path of an executable (which could be execve(2)-d as a shell), but that won't work for root if the shell is not listed in /etc/shells

you might also try /usr/bin/sudo SHELL=/bin/bash -s

| improve this answer | |
  • In reverse order: using sudo doesn't work because as my question says, I don't have sudo user on the box. I don't know what you mean about using "--shell" since my post specifically mentions that this (a) did not work and (b) can not work for the root user. Are you saying something that is going over my head? Next, you say to create another account of uid0. Okay. How do I do that if I can't access the box? I know how I should have edited the shell. But I messed up. It happens. The GRUB idea was half of an answer that worked. I'm going to answer my own question but that was helpful. – stone.212 Sep 16 '17 at 6:10

I wish I could give 50% credit to @Basile Starynkevitch or even if he wrote separate answers. Because one of his suggestions absolutely got me on the right track.

1 - As @Basile Starynkevitch says, I was able to boot the machine, and at GRUB, I hit "e" to edit the boot options. On the line that begins with "linux" I added the parameter:


This booted me into a root bash shell. Progress!

2 - As root on the filesystem you still won't be able to edit anything because the filesystem is mounted read only (even if you remove that option from GRUB I found and I did not research why) so you have to type:

# mount -o remount,rw /

Then you can proceed to:

3 - Edit the /etc/passwd file

As @Basile Starynkevitch says:

BTW the right thing to do to change a shell is chsh

He is correct. But I just did

# vi /etc/passwd

because I usually don't do the same stupid thing twice.

| improve this answer | |
  • BTW, when doing all that you need to 5. Run the sync command at last – Basile Starynkevitch Sep 16 '17 at 7:14
  • @Basile Starynkevitch What? Why? I did not run the sync command and it worked. Or did I miss something that will haunt me later? – stone.212 Sep 17 '17 at 5:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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