Meniu

How to add user in Alpine Linux

Alpine Linux is a multitasking and multi-user operating system. You can create a user for different tasks. For example, the www user for static web pages and another user for system management. Adding and removing users is an essential task for developers and sysadmins. This tutorial explains how to add and remove users in Alpine Linux.

How to add user in Alpine Linux

To create a new Alpine user account, use the adduser command. The syntax is as follows to add a user to Alpine:

adduser {user-name} 
adduser [options] {user-name}
$ adduser gnulinux 
## or if you are sudo ## 
$ sudo adduser gnulinux

The adduser command could make it / home / gnulinux / the home directory for the gnulinux user:

Check first if it is associated:

# ls -ld / home / 
# ls -ld / gnulinux /

If not:

drwxr-sr-x 2 gnulinux gnulinux 2 mai 2 21:20 / home / gnulinux

Alpine Linux uses / etc / passwdto store all usernames and encrypted passwords stored in / etc / shadow

We can set the path to the home directory (default is / home / $ USER /) and adding the -h / path / to / home / dir option:

# adduser -h / efs / home / gnulinux gnulinux

By default / bin / ash is set as the login shell for all new users and / bin / sh for system users. We will set / bin / bash (or any other shell in the / etc / shells file) as a shell:

# adduser -h / efs / home / gnulinux -s / bin / bash gnulinux

To list all shells, use the cat command:

# cat / etc / shells

Use the id command or query the file directly / etc / passwdusing the command grepto verify the user account created in Alpine Linux:

# id {username} 
# grep '^ username' / etc / passwd 
# id wendy 
# grep '^ gnulinux' / etc / passwd

To remove users from Alpine use the deluser command:

# deluser [--remove-home] {USER}

To delete a user named "gnulinux" from your system, run:

# deluser gnulinux

You can delete the user and the directory at home:

# deluser --remove-home gnulinux

Source: cyberciti.biz

FlorinM

Utilizator Linux - Solus OS, pasionat de calatorii.
  • | 2708 articole

Nici un comentariu inca. Fii primul!
  • powered by Verysign