0

I created a new user on my server, with:

useradd newuser

Then tried to set the login shell and group for the user afterwards, but seems I did something wrong. Now when I try to switch to root user I get:

Cannot execute newuser: No such file or directory

for command:

cat /etc/passwd | grep root

I get:

root:x:0:0:root:/root:newuser

Is there a way to set things straight from here? Are the commands I ran needed to understand what the solution may be? I still have the command history in my console

2
  • 1
    Write whatever you have done, /etc/passwd last field will be your login shell, you have changed from default shell (such as /bin/bas) to newuser, since newuser doesn't exists it is giving you error.
    – asktyagi
    Jun 2, 2019 at 5:29
  • @asktyagi, Thanks for your help, but Mircea Vutcovici's answer helped me find the solution, as I wrote below.
    – Márton
    Jun 3, 2019 at 21:16

1 Answer 1

1

You need to boot from a rescue CD and mount / volume and edit /etc/passwd and change the entry for shell from newuser to /bin/bash. For more details see: https://help.ubuntu.com/community/LiveCdRecovery

2
  • Thank you for the advice, this is a virtual server on Digitalocean. I'm trying now from digitaloceans recovery iso function.
    – Márton
    Jun 1, 2019 at 22:34
  • Thank you so much @mircea-vutcovici! I was able to log in to my server with the recovery ISO possibility and modify the /etc/passwd line you brought to my attention! This was a true lifesaver, since I wasn't expecting to do anything serious, I didn't make a backup before creating the problem. My last backup was 2 months old. Thank you, thank you and thank you once more!!!
    – Márton
    Jun 1, 2019 at 22:55

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .