1

I need a non-root user to do certain (safe) things. I didn't pay attention, and used useradd -ou 0 -g 0 new_user_name, which gave root permissions to the user. It also has the same UID of 0.

Before I do something stupid, can anyone help me on how to delete this user, or simply change the permissions/UID? I already discovered what happens with pkill. Hahaha.

Videonauth
  • 33,045
  • 16
  • 104
  • 120
DevOpsSauce
  • 203
  • 1
  • 3
  • 18
  • `man userdel`? --- if you want to be on the safe side (but I hope the tool will have no problem with duplicated UIDs) you can backup `/etc/passwd`, `/etc/shadow/`, and the corresponding group files. – Rmano May 31 '16 at 07:31

1 Answers1

0

userdel has an option -f to force removal. userdel would probably just delete the passwd entry and home directory, without affecting the actual root account.

To be safer, I might be inclined to hand-edit the password file to remove the entry for your new root user, then hand-remove new root user's home directory. You may have a command on your system named nano, which lets you safely edit /etc/passwd in a text editor.

Source: https://superuser.com/questions/804210/how-can-i-delete-root-users

kek
  • 490
  • 1
  • 4
  • 19
  • Now I just need to figure out how to log in as that user so I can operate as a non-root user. – DevOpsSauce May 31 '16 at 17:39
  • What exactly do you want? With sudo adduser nameoftheuser you create a user without any admin privilage. Just add it to suddoers file in /etc/sudoers to gain that privilages. Stop messinf with root accs, this is the way easier and safer. – kek May 31 '16 at 17:42
  • I added a user named "hal" just to initially try it out. After that, I type su - hal, and get "No directory, logging in with HOME=/ $ " – DevOpsSauce Jun 01 '16 at 02:11