How should I delete a non-root user on OpenWrt?

I was following along this document with friends: https://openwrt.org/docs/guide-user/security/sudo

We typed usermod -a -G sudo test.

I'm curious about how you would undo this command on a relatively vanilla install of OpenWrt?
Or, how do I delete a non-root user in OpenWrt?

We:

  • removed line from /etc/shadow
  • rmdir /home/test
  • removed line from /etc/shadow

A vanilla install has only the root user. Did you add other users?

we did!
Specifically with usermod -a -G sudo test.

I've never installed additional/non-root users, so I'm probably not the best person to answer...

but does userdel exist in this context? Have you tried that?

1 Like

These two questions are actually asking about two different actions. The first asked how to undo adding a user to a group. The second asked how to remove a user entirely from the system.

For the former, you can just invoke the same usermod command with -r instead of -a.

For the latter, install shadow-userdel and invoke userdel as usual.

2 Likes

Another option: With any text editor (vi if everything else fails) directly manipulate or delete the respective lines from

  • /etc/passwd for users and their cornerstone data
  • /etc/shadow for their passwords (i.e., housekeeping)
  • /etc/groups for user groups

AFAIK the dedicated tools to add and remove users are mainly for convenience and to manipulate the system at runtime (e.g., bumping logged in users off the system when they are removed).

2 Likes

Thanks for the advice! we did give that a try but it was not installed on the device

I appreciate you clarifying the actions! I'll definitely try usermod -r.

A great point. I find this highlights my joy using GNU/Linux systems.
All else fails embrace terminal and text editor.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.