salt.modules.pw_user

Manage users with the pw command

Important

If you feel that Salt should be using this module to manage users on a minion, and it is using a different module (or gives an error similar to 'user.info' is not available), see here.

salt.modules.pw_user.add(name, uid=None, gid=None, groups=None, home=None, shell=None, unique=True, fullname='', roomnumber='', workphone='', homephone='', createhome=True, loginclass=None, **kwargs)

Add a user to the minion

CLI Example:

salt '*' user.add name <uid> <gid> <groups> <home> <shell>

salt.modules.pw_user.chfullname(name, fullname)

Change the user's Full Name

CLI Example:

salt '*' user.chfullname foo "Foo Bar"

salt.modules.pw_user.chgid(name, gid)

Change the default group of the user

CLI Example:

salt '*' user.chgid foo 4376

salt.modules.pw_user.chgroups(name, groups, append=False)

Change the groups to which a user belongs

name

Username to modify

groups

List of groups to set for the user. Can be passed as a comma-separated list or a Python list.

appendFalse

Set to True to append these groups to the user's existing list of groups. Otherwise, the specified groups will replace any existing groups for the user.

CLI Example:

salt '*' user.chgroups foo wheel,root True

salt.modules.pw_user.chhome(name, home, persist=False)

Set a new home directory for an existing user

name

Username to modify

home

New home directory to set

persistFalse

Set to True to prevent configuration files in the new home directory from being overwritten by the files from the skeleton directory.

CLI Example:

salt '*' user.chhome foo /home/users/foo True

salt.modules.pw_user.chhomephone(name, homephone)

Change the user's Home Phone

CLI Example:

salt '*' user.chhomephone foo "7735551234"

salt.modules.pw_user.chloginclass(name, loginclass, root=None)

Change the default login class of the user

New in version 2016.3.5.

CLI Example:

salt '*' user.chloginclass foo staff

salt.modules.pw_user.chroomnumber(name, roomnumber)

Change the user's Room Number

CLI Example:

salt '*' user.chroomnumber foo 123

salt.modules.pw_user.chshell(name, shell)

Change the default shell of the user

CLI Example:

salt '*' user.chshell foo /bin/zsh

salt.modules.pw_user.chuid(name, uid)

Change the uid for a named user

CLI Example:

salt '*' user.chuid foo 4376

salt.modules.pw_user.chworkphone(name, workphone)

Change the user's Work Phone

CLI Example:

salt '*' user.chworkphone foo "7735550123"

salt.modules.pw_user.delete(name, remove=False, force=False)

Remove a user from the minion

CLI Example:

salt '*' user.delete name remove=True force=True

salt.modules.pw_user.get_loginclass(name)

Get the login class of the user

New in version 2016.3.0.

CLI Example:

salt '*' user.get_loginclass foo

salt.modules.pw_user.getent(refresh=False)

Return the list of all info for all users

CLI Example:

salt '*' user.getent

salt.modules.pw_user.info(name)

Return user information

CLI Example:

salt '*' user.info root

salt.modules.pw_user.list_groups(name)

Return a list of groups the named user belongs to

CLI Example:

salt '*' user.list_groups foo

salt.modules.pw_user.list_users()

Return a list of all users

CLI Example:

salt '*' user.list_users

salt.modules.pw_user.rename(name, new_name)

Change the username for a named user

CLI Example:

salt '*' user.rename name new_name

© 2021 SaltStack.
Licensed under the Apache License, Version 2.0.
https://docs.saltproject.io/en/latest/ref/modules/all/salt.modules.pw_user.html