How to add and delete users on Alpine Linux

Adding and deleting users on Alpine Linux can be done using the adduser and deluser commands, respectively. Here are the steps to add and delete a user on Alpine Linux:

Adding a user:

  1. Open a terminal and log in as the root user by typing su and entering the root password.
  2. To add a new user, run the command adduser followed by the username. For example, to add a user named “john”, run the command:
adduser john
  1. The command will prompt you to enter a password for the new user, and to confirm it.
  2. You can also set the user’s full name, phone number, and other information by providing additional options to the adduser command. For example, to set the full name of the user to “John Doe”, you can run the command:
adduser -g "John Doe" john
  1. Once the user is added, you can set the user permissions and groups by using the addgroup command.

Deleting a user:

  1. Open a terminal and log in as the root user by typing su and entering the root password.
  2. To delete a user, run the command deluser followed by the username. For example, to delete the user “john”, run the command:
deluser john
  1. If the user has files in the home directory, the command will prompt you to confirm if you want to remove the home directory and its contents.
  2. Once the user is deleted, you can also remove the user’s group by running the command delgroup followed by the group name.

It’s worth noting that, before deleting a user, it is a good practice to make a backup of the user’s important data. Also, pay attention to the user’s process if running, because deleting a user may cause the processes of the user to be killed. (https://www.iport.com/)

Leave a Comment