User Managment

Here are some user management commands in Linux with examples:

  1. Create a new user:

    useradd john

    This command creates a new user account named "john".

  2. Set/change password for a user:

    passwd john

    This command allows you to set or change the password for the user "john".

  3. Modify user properties:

    usermod -aG sudo john

    This command adds the user "john" to the "sudo" group, granting them administrative privileges.

  4. Delete a user:

    userdel john

    This command deletes the user account "john".

  5. Display user and group information:

    id john

    This command displays the user and group information for the user "john".

  6. Switch to another user account:

    su - john

    This command allows you to switch to the user account "john".

  7. Execute a command with administrative privileges:

    sudo apt-get update

    This command executes the "apt-get update" command with root privileges.

  8. Configure password expiry information:

    chage -l john

    This command displays the password expiry information for the user "john".

  9. Lock or unlock a user account:

    usermod -L john

    This command locks the user account "john".

    usermod -U john

    This command unlocks the user account "john".

Last updated