Module Expr Str ImportFrom alias Import alias Import alias TryExcept body Import alias Assign NameStore NameLoad handlers ExceptHandler type NameLoad body Assign NameStore NameLoad Import alias identifier Import alias ImportFrom alias ImportFrom alias Assign NameStore Call AttributeLoad NameLoad attr NameLoad Assign NameStore Str FunctionDef arguments args defaults body Expr Str If BoolOpAnd NameLoad CompareIn SubscriptLoad NameLoad Index Str TupleLoad Str Str body Return NameLoad Return TupleLoad NameLoad Str decorator_list FunctionDef arguments args NameParam defaults body Expr Str TryExcept body Assign NameStore Call AttributeLoad AttributeLoad Call AttributeLoad NameLoad attr NameLoad attr attr Str Num handlers ExceptHandler type NameLoad body Raise Call NameLoad Call AttributeLoad Str attr NameLoad If UnaryOpNot NameLoad body Return Dict orelse While CompareLt Call NameLoad NameLoad Num body Expr Call AttributeLoad NameLoad attr Str Return Dict Str Str Str Str Call AttributeLoad NameLoad attr SubscriptLoad NameLoad Index Num Call AttributeLoad NameLoad attr SubscriptLoad NameLoad Index Num Call AttributeLoad NameLoad attr SubscriptLoad NameLoad Index Num Call AttributeLoad NameLoad attr SubscriptLoad NameLoad Index Num decorator_list FunctionDef arguments args NameParam defaults body Expr Str Return Call AttributeLoad Str attr Call AttributeLoad NameLoad attr Str Str Call AttributeLoad NameLoad attr Str Str Call AttributeLoad NameLoad attr Str Str Call AttributeLoad NameLoad attr Str Str decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults body Expr Str If UnaryOpNot Call NameLoad NameLoad AttributeLoad NameLoad attr body Assign NameStore Call NameLoad NameLoad Assign NameStore Call NameLoad NameLoad If UnaryOpNot NameLoad body Return NameLoad If CompareEq NameLoad SubscriptLoad NameLoad Index NameLoad body Return NameLoad Assign NameStore Call AttributeLoad NameLoad attr NameLoad Assign SubscriptStore NameLoad Index NameLoad NameLoad Assign NameStore ListLoad Str Str NameLoad Str Call NameLoad NameLoad Expr Call SubscriptLoad NameLoad Index Str NameLoad keyword NameLoad Assign NameStore Call NameLoad NameLoad Return CompareEq Call AttributeLoad Call NameLoad NameLoad attr NameLoad NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam NameParam NameParam NameParam NameParam NameParam NameParam NameParam NameParam NameParam defaults NameLoad NameLoad NameLoad NameLoad NameLoad NameLoad Str Str Str Str NameLoad NameLoad kwarg body Expr Str Assign NameStore Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad If Call AttributeLoad AttributeLoad NameLoad attr attr Call AttributeLoad NameLoad attr Str NameLoad body Expr Call AttributeLoad NameLoad attr Str If NameLoad body Expr Call AttributeLoad NameLoad attr Str If Call NameLoad NameLoad AttributeLoad NameLoad attr body Assign NameStore Call AttributeLoad NameLoad attr Str Assign NameStore ListLoad Str Str If NameLoad body Expr Call AttributeLoad NameLoad attr ListLoad Str NameLoad If NameLoad body Expr Call AttributeLoad NameLoad attr ListLoad Str NameLoad If NameLoad body Expr Call AttributeLoad NameLoad attr ListLoad Str Call AttributeLoad Str attr NameLoad If CompareIsNot NameLoad NameLoad body Expr Call AttributeLoad NameLoad attr ListLoad Str NameLoad If CompareIs NameLoad NameLoad body Expr Call AttributeLoad NameLoad attr Str If NameLoad body Expr Call AttributeLoad NameLoad attr ListLoad Str NameLoad If NameLoad body Expr Call AttributeLoad NameLoad attr ListLoad Str NameLoad If UnaryOpNot Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad body Expr Call AttributeLoad NameLoad attr Str Assign NameStore Call NameLoad Dict Str Str Str Str NameLoad NameLoad NameLoad NameLoad Expr Call AttributeLoad NameLoad attr ListLoad Str NameLoad Expr Call AttributeLoad NameLoad attr ListLoad Str NameLoad Return CompareEq Call SubscriptLoad NameLoad Index Str NameLoad keyword NameLoad Num decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults NameLoad NameLoad body Expr Str If Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad body Expr Call AttributeLoad NameLoad attr Str Assign NameStore ListLoad Str Str If NameLoad body Expr Call AttributeLoad NameLoad attr Str Expr Call AttributeLoad NameLoad attr ListLoad Str NameLoad Return CompareEq Call SubscriptLoad NameLoad Index Str NameLoad keyword NameLoad Num decorator_list FunctionDef arguments args NameParam defaults NameLoad body Expr Str If BoolOpAnd CompareIn Str NameLoad UnaryOpNot NameLoad body Return SubscriptLoad NameLoad Index Str Assign NameStore ListLoad For NameStore Call AttributeLoad NameLoad attr body Expr Call AttributeLoad NameLoad attr Call NameLoad AttributeLoad NameLoad attr Assign SubscriptStore NameLoad Index Str NameLoad Return NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str Assign NameStore Call NameLoad NameLoad If UnaryOpNot NameLoad body Raise Call NameLoad Call AttributeLoad Str attr NameLoad If CompareEq NameLoad SubscriptLoad NameLoad Index Str body Return NameLoad Assign NameStore ListLoad Str Str Str NameLoad Str NameLoad Expr Call SubscriptLoad NameLoad Index Str NameLoad keyword NameLoad Return CompareEq Call AttributeLoad Call NameLoad NameLoad attr Str NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str Assign NameStore Call NameLoad NameLoad If UnaryOpNot NameLoad body Raise Call NameLoad Call AttributeLoad Str attr NameLoad If CompareEq NameLoad SubscriptLoad NameLoad Index Str body Return NameLoad Assign NameStore ListLoad Str Str Str NameLoad Str NameLoad Expr Call SubscriptLoad NameLoad Index Str NameLoad keyword NameLoad Return CompareEq Call AttributeLoad Call NameLoad NameLoad attr Str NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str Assign NameStore Call NameLoad NameLoad If UnaryOpNot NameLoad body Raise Call NameLoad Call AttributeLoad Str attr NameLoad If CompareEq NameLoad SubscriptLoad NameLoad Index Str body Return NameLoad Assign NameStore ListLoad Str Str Str NameLoad Str NameLoad Expr Call SubscriptLoad NameLoad Index Str NameLoad keyword NameLoad Return CompareEq Call AttributeLoad Call NameLoad NameLoad attr Str NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults NameLoad body Expr Str Assign NameStore Call NameLoad NameLoad If UnaryOpNot NameLoad body Raise Call NameLoad Call AttributeLoad Str attr NameLoad If CompareEq NameLoad SubscriptLoad NameLoad Index Str body Return NameLoad Assign NameStore ListLoad Str Str NameLoad Str NameLoad If NameLoad body Expr Call AttributeLoad NameLoad attr Str Expr Call SubscriptLoad NameLoad Index Str NameLoad keyword NameLoad Return CompareEq Call AttributeLoad Call NameLoad NameLoad attr Str NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults NameLoad body Expr Str If Call NameLoad NameLoad AttributeLoad NameLoad attr body Assign NameStore Call AttributeLoad NameLoad attr Str Assign NameStore Call NameLoad Call NameLoad NameLoad If CompareEq NameLoad Call NameLoad NameLoad body Return NameLoad If NameLoad body AugAssignAdd NameStore NameLoad Assign NameStore ListLoad Str Str Str Call AttributeLoad Str attr NameLoad Str NameLoad Return CompareEq Call SubscriptLoad NameLoad Index Str NameLoad keyword NameLoad Num decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str Return Call NameLoad NameLoad Str NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str Return Call NameLoad NameLoad Str NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str Return Call NameLoad NameLoad Str NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str Return Call NameLoad NameLoad Str NameLoad decorator_list FunctionDef arguments args NameParam defaults body Expr Str Assign NameStore Dict TryExcept body Assign NameStore Call AttributeLoad NameLoad attr NameLoad Assign SubscriptStore NameLoad Index Str AttributeLoad NameLoad attr Assign SubscriptStore NameLoad Index Str Call NameLoad NameLoad Assign SubscriptStore NameLoad Index Str AttributeLoad NameLoad attr Assign SubscriptStore NameLoad Index Str AttributeLoad NameLoad attr Assign SubscriptStore NameLoad Index Str AttributeLoad NameLoad attr Assign SubscriptStore NameLoad Index Str AttributeLoad NameLoad attr Assign SubscriptStore NameLoad Index Str AttributeLoad NameLoad attr Assign NameStore Call AttributeLoad AttributeLoad NameLoad attr attr Str Num While CompareLt Call NameLoad NameLoad Num body Expr Call AttributeLoad NameLoad attr Str Assign SubscriptStore NameLoad Index Str SubscriptLoad NameLoad Index Num Assign SubscriptStore NameLoad Index Str SubscriptLoad NameLoad Index Num Assign SubscriptStore NameLoad Index Str SubscriptLoad NameLoad Index Num Assign SubscriptStore NameLoad Index Str SubscriptLoad NameLoad Index Num handlers ExceptHandler type NameLoad body Return Dict Return NameLoad decorator_list FunctionDef arguments args NameParam defaults body Expr Str Assign NameStore Call SubscriptLoad NameLoad Index Str ListLoad Str Str Str NameLoad Assign NameStore Call AttributeLoad NameLoad attr Str Return Dict Str IfExp CompareEq Call NameLoad NameLoad Num SubscriptLoad NameLoad Index Num Str decorator_list FunctionDef arguments args NameParam defaults body Expr Str Return Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad decorator_list FunctionDef arguments args defaults body Expr Str Return Call NameLoad ListComp AttributeLoad NameLoad attr comprehension NameStore Call AttributeLoad NameLoad attr decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str Assign NameStore Call NameLoad NameLoad If UnaryOpNot NameLoad body Raise Call NameLoad Call AttributeLoad Str attr NameLoad Assign NameStore Call NameLoad NameLoad If NameLoad body Raise Call NameLoad Call AttributeLoad Str attr NameLoad Assign NameStore ListLoad Str Str Str NameLoad Str NameLoad Expr Call SubscriptLoad NameLoad Index Str NameLoad Assign NameStore Call NameLoad NameLoad If CompareNotEq SubscriptLoad NameLoad Index Str SubscriptLoad NameLoad Index Str body Return CompareEq SubscriptLoad NameLoad Index Str NameLoad Return NameLoad decorator_list
N/A N/A 
Manage users with the useradd 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 :ref:`here
    <module-provider-override>`.
 __future__ absolute_import N/A copy N/A logging N/A N/A N/A pwd N/A HAS_PWD True N/A N/A N/A ImportError N/A N/A HAS_PWD False N/A salt.ext.six six N/A salt.utils salt.exceptions CommandExecutionError salt.utils locales N/A log N/A N/A logging getLogger __name__ N/A __virtualname__ user __virtual__ N/A N/A N/A N/A N/A 
    Set the user module if the kernel is FreeBSD or DragonFly
     N/A N/A HAS_PWD N/A N/A __grains__ N/A kernel N/A FreeBSD DragonFly N/A N/A __virtualname__ N/A N/A False The pw_user execution module cannot be loaded: the pwd python module is not available or the system is not FreeBSD. N/A _get_gecos N/A N/A name N/A N/A N/A 
    Retrieve GECOS field info and return it in dictionary form
     N/A N/A N/A gecos_field N/A N/A N/A N/A N/A pwd getpwnam name pw_gecos split , 3 N/A N/A N/A KeyError N/A N/A N/A CommandExecutionError N/A N/A User '{0}' does not exist format name N/A N/A gecos_field N/A N/A N/A N/A N/A N/A N/A len gecos_field 4 N/A N/A N/A N/A gecos_field append N/A N/A fullname roomnumber workphone homephone N/A N/A locales sdecode N/A gecos_field N/A 0 N/A N/A locales sdecode N/A gecos_field N/A 1 N/A N/A locales sdecode N/A gecos_field N/A 2 N/A N/A locales sdecode N/A gecos_field N/A 3 N/A _build_gecos N/A N/A gecos_dict N/A N/A N/A 
    Accepts a dictionary entry containing GECOS field names and their values,
    and returns a full GECOS comment string, to be used with pw usermod.
     N/A N/A N/A {0},{1},{2},{3} format N/A N/A gecos_dict get fullname N/A N/A gecos_dict get roomnumber N/A N/A gecos_dict get workphone N/A N/A gecos_dict get homephone N/A _update_gecos N/A N/A name key value N/A N/A N/A 
    Common code to change a user's GECOS information
     N/A N/A N/A isinstance value N/A six string_types N/A N/A value N/A str value N/A pre_info N/A _get_gecos name N/A N/A pre_info N/A N/A False N/A N/A value N/A pre_info N/A key N/A N/A True N/A gecos_data N/A N/A copy deepcopy pre_info N/A N/A gecos_data N/A key value N/A cmd N/A pw usermod name -c N/A _build_gecos gecos_data N/A N/A N/A __salt__ N/A cmd.run cmd python_shell False N/A post_info N/A info name N/A N/A N/A N/A N/A _get_gecos name get key value N/A add N/A N/A name uid gid groups home shell unique fullname roomnumber workphone homephone createhome loginclass N/A None None None None None True True None kwargs N/A N/A 
    Add a user to the minion

    CLI Example:

    .. code-block:: bash

        salt '*' user.add name <uid> <gid> <groups> <home> <shell>
     N/A kwargs N/A N/A N/A salt utils clean_kwargs kwargs N/A N/A N/A N/A salt utils is_true N/A N/A kwargs pop system False N/A N/A N/A N/A log warning pw_user module does not support the 'system' argument N/A kwargs N/A N/A N/A N/A log warning Invalid kwargs passed to user.add N/A N/A isinstance groups N/A six string_types N/A N/A groups N/A N/A groups split , N/A cmd N/A pw useradd N/A uid N/A N/A N/A N/A cmd extend N/A -u uid N/A gid N/A N/A N/A N/A cmd extend N/A -g gid N/A groups N/A N/A N/A N/A cmd extend N/A -G N/A N/A , join groups N/A N/A home None N/A N/A N/A N/A cmd extend N/A -d home N/A N/A createhome True N/A N/A N/A N/A cmd append -m N/A loginclass N/A N/A N/A N/A cmd extend N/A -L loginclass N/A shell N/A N/A N/A N/A cmd extend N/A -s shell N/A N/A N/A N/A N/A salt utils is_true unique N/A N/A N/A N/A cmd append -o N/A gecos_field N/A _build_gecos N/A fullname roomnumber workphone homephone fullname roomnumber workphone homephone N/A N/A N/A cmd extend N/A -c gecos_field N/A N/A N/A cmd extend N/A -n name N/A N/A N/A N/A __salt__ N/A cmd.retcode cmd python_shell False 0 N/A delete N/A N/A name remove force N/A False False N/A N/A 
    Remove a user from the minion

    CLI Example:

    .. code-block:: bash

        salt '*' user.delete name remove=True force=True
     N/A N/A N/A N/A salt utils is_true force N/A N/A N/A N/A log error pw userdel does not support force-deleting user while user is logged in N/A cmd N/A pw userdel N/A remove N/A N/A N/A N/A cmd append -r N/A N/A N/A cmd extend N/A -n name N/A N/A N/A N/A __salt__ N/A cmd.retcode cmd python_shell False 0 N/A getent N/A N/A refresh N/A False N/A N/A 
    Return the list of all info for all users

    CLI Example:

    .. code-block:: bash

        salt '*' user.getent
     N/A N/A N/A user.getent __context__ N/A refresh N/A N/A N/A __context__ N/A user.getent N/A ret N/A N/A data N/A N/A pwd getpwall N/A N/A N/A N/A ret append N/A info N/A data pw_name N/A N/A __context__ N/A user.getent ret N/A ret N/A chuid N/A N/A name uid N/A N/A N/A 
    Change the uid for a named user

    CLI Example:

    .. code-block:: bash

        salt '*' user.chuid foo 4376
     N/A pre_info N/A info name N/A N/A pre_info N/A N/A N/A CommandExecutionError N/A N/A User '{0}' does not exist format name N/A N/A uid N/A pre_info N/A uid N/A N/A True N/A cmd N/A pw usermod -u uid -n name N/A N/A N/A __salt__ N/A cmd.run cmd python_shell False N/A N/A N/A N/A N/A info name get uid uid N/A chgid N/A N/A name gid N/A N/A N/A 
    Change the default group of the user

    CLI Example:

    .. code-block:: bash

        salt '*' user.chgid foo 4376
     N/A pre_info N/A info name N/A N/A pre_info N/A N/A N/A CommandExecutionError N/A N/A User '{0}' does not exist format name N/A N/A gid N/A pre_info N/A gid N/A N/A True N/A cmd N/A pw usermod -g gid -n name N/A N/A N/A __salt__ N/A cmd.run cmd python_shell False N/A N/A N/A N/A N/A info name get gid gid N/A chshell N/A N/A name shell N/A N/A N/A 
    Change the default shell of the user

    CLI Example:

    .. code-block:: bash

        salt '*' user.chshell foo /bin/zsh
     N/A pre_info N/A info name N/A N/A pre_info N/A N/A N/A CommandExecutionError N/A N/A User '{0}' does not exist format name N/A N/A shell N/A pre_info N/A shell N/A N/A True N/A cmd N/A pw usermod -s shell -n name N/A N/A N/A __salt__ N/A cmd.run cmd python_shell False N/A N/A N/A N/A N/A info name get shell shell N/A chhome N/A N/A name home persist N/A False N/A N/A 
    Set a new home directory for an existing user

    name
        Username to modify

    home
        New home directory to set

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

    CLI Example:

    .. code-block:: bash

        salt '*' user.chhome foo /home/users/foo True
     N/A pre_info N/A info name N/A N/A pre_info N/A N/A N/A CommandExecutionError N/A N/A User '{0}' does not exist format name N/A N/A home N/A pre_info N/A home N/A N/A True N/A cmd N/A pw usermod name -d home N/A persist N/A N/A N/A N/A cmd append -m N/A N/A N/A __salt__ N/A cmd.run cmd python_shell False N/A N/A N/A N/A N/A info name get home home N/A chgroups N/A N/A name groups append N/A False N/A N/A 
    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.

    append : False
        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:

    .. code-block:: bash

        salt '*' user.chgroups foo wheel,root True
     N/A N/A isinstance groups N/A six string_types N/A N/A groups N/A N/A groups split , N/A ugrps N/A set N/A list_groups name N/A N/A ugrps N/A set groups N/A N/A True N/A append N/A N/A groups ugrps N/A cmd N/A pw usermod -G N/A N/A , join groups -n name N/A N/A N/A N/A __salt__ N/A cmd.retcode cmd python_shell False 0 N/A chfullname N/A N/A name fullname N/A N/A N/A 
    Change the user's Full Name

    CLI Example:

    .. code-block:: bash

        salt '*' user.chfullname foo "Foo Bar"
     N/A N/A _update_gecos name fullname fullname N/A chroomnumber N/A N/A name roomnumber N/A N/A N/A 
    Change the user's Room Number

    CLI Example:

    .. code-block:: bash

        salt '*' user.chroomnumber foo 123
     N/A N/A _update_gecos name roomnumber roomnumber N/A chworkphone N/A N/A name workphone N/A N/A N/A 
    Change the user's Work Phone

    CLI Example:

    .. code-block:: bash

        salt '*' user.chworkphone foo "7735550123"
     N/A N/A _update_gecos name workphone workphone N/A chhomephone N/A N/A name homephone N/A N/A N/A 
    Change the user's Home Phone

    CLI Example:

    .. code-block:: bash

        salt '*' user.chhomephone foo "7735551234"
     N/A N/A _update_gecos name homephone homephone N/A info N/A N/A name N/A N/A N/A 
    Return user information

    CLI Example:

    .. code-block:: bash

        salt '*' user.info root
     N/A ret N/A N/A N/A N/A data N/A N/A pwd getpwnam name N/A N/A ret N/A gid N/A data pw_gid N/A N/A ret N/A groups N/A list_groups name N/A N/A ret N/A home N/A data pw_dir N/A N/A ret N/A name N/A data pw_name N/A N/A ret N/A passwd N/A data pw_passwd N/A N/A ret N/A shell N/A data pw_shell N/A N/A ret N/A uid N/A data pw_uid N/A gecos_field N/A N/A N/A data pw_gecos split , 3 N/A N/A N/A len gecos_field 4 N/A N/A N/A N/A gecos_field append N/A N/A ret N/A fullname N/A gecos_field N/A 0 N/A N/A ret N/A roomnumber N/A gecos_field N/A 1 N/A N/A ret N/A workphone N/A gecos_field N/A 2 N/A N/A ret N/A homephone N/A gecos_field N/A 3 N/A N/A N/A KeyError N/A N/A N/A N/A ret N/A get_loginclass N/A N/A name N/A N/A N/A 
    Get the login class of the user

    .. versionadded:: 2016.3.0

    CLI Example:

    .. code-block:: bash

        salt '*' user.get_loginclass foo

     N/A userinfo N/A N/A __salt__ N/A cmd.run_stdout N/A pw usershow -n name N/A userinfo N/A N/A userinfo split : N/A N/A loginclass N/A N/A N/A len userinfo 10 N/A userinfo N/A 4 N/A list_groups N/A N/A name N/A N/A N/A 
    Return a list of groups the named user belongs to

    CLI Example:

    .. code-block:: bash

        salt '*' user.list_groups foo
     N/A N/A N/A N/A salt utils get_group_list name N/A list_users N/A N/A N/A N/A N/A 
    Return a list of all users

    CLI Example:

    .. code-block:: bash

        salt '*' user.list_users
     N/A N/A sorted N/A N/A user pw_name N/A user N/A N/A pwd getpwall N/A rename N/A N/A name new_name N/A N/A N/A 
    Change the username for a named user

    CLI Example:

    .. code-block:: bash

        salt '*' user.rename name new_name
     N/A current_info N/A info name N/A N/A current_info N/A N/A N/A CommandExecutionError N/A N/A User '{0}' does not exist format name N/A new_info N/A info new_name N/A new_info N/A N/A N/A CommandExecutionError N/A N/A User '{0}' already exists format new_name N/A cmd N/A pw usermod -l new_name -n name N/A N/A N/A __salt__ N/A cmd.run cmd N/A post_info N/A info new_name N/A N/A N/A post_info N/A name N/A current_info N/A name N/A N/A N/A N/A post_info N/A name new_name N/A False N/A