Linux user management

==Summary== Basic user creation and account manipulation is relatively easy with a number of simple commands

{| class="wikitable" !Command !Purpose !Syntax Use |- |adduser||Creates a user account|| adduser |- |passwd||Assigns a password to a user account || passwd |- |userdel||Deletes user account. Does not delete content || userdel |- |}

==File Locations== Linux stores its user account and password hashes in two seperate files located on the file system.

The /etc/passwd file stores all of the user accounts on the system
The /etc/shadow file stores all of the hashes of the passwords to each account on the system

==Commands== ===adduser=== adduser adds a user to the system. This user account though is unaccessible as no password has been assigned to it, but can be identified as a valid user through ssh login or virtual login when logging into linux in non-gui mode. Note this step will create the user accounts home directory under /home/

Create a user by entering: adduser

Creating a user who also has sudo capabilities can be done simply by entering: adduser sudo Adding users to any group can be done in the same way. To remove a user from a group, see userdel

===passwd=== After adding a user, you should immediately add a password, thus giving access to the account

Add a user by entering: passwd

You will then be prompted to enter a password and possibly warned if it is not strong enough, you can choose to ignore this warning if you would like

===userdel=== userdel will delete the user's account but does not delete any of the user's data or content stored in their home folder. This function acts as a method of disabling the user account.

To disable/delete a user account enter: userdel Sometimes if the user is currently active or a program is using that user, userdel will prompt an error from the disable/delete. You can confirm and check this by running this command w This will list all processes that are being used by the user or using the user for executing their commands. By either killing all processes using the user, or using -f flag to force the user to be deleted, userdel will then disable the account

To fully delete an account you will need to delete the user's data folder in /home/<username

This can be done cautiously with the following command cd /home rm -rf

Note we are using the remove function but also have navigated to the /home folder. All we are doing here is forcing and recursively deleting the user's data folder from the /home folder

Alternatively, userdel can also be used to remove users from groups. You can list all groups a user is in with the following command groups Simply, remove the user from a group with the following command userdel

==Notes==

==Sources==