Table of Contents

Server access maintenance

Users

How can I see a list of my users? The list of users of your server is found in your /etc/password file. To see this list simply type:

cat /etc/passwd 

You will then see a list such as:

eric:x:1006:1006::/home/eric:/bin/sh
john:x:1007:1007::/home/john:/bin/sh
sibelius:x:1007:1007::/home/sibelius:/bin/sh

Changing your password

To change your password, log into your server using your account (for example, root) and type the following at the prompt:

passwd

you will then be asked for your password. Enter it after the prompt:

Enter new UNIX password:

…followed by a confirmation:

Retype new UNIX password:

If you typed the same password twice, you will see the following message:

passwd: password updated successfully

Changing a user's password as root

If you are logged in as 'root' and you want to change the password of one of your users, simply type (where billy is the name of the user):

passwd billy

you will then be asked to enter the new password and confirm it:

Enter new UNIX password:
Retype new UNIX password:

If successful, you will see:

passwd: password updated successfully

Creating additional users

To allow someone else to have access to your server, you need to make a user account for them. To do this simply type the following at the command prompt (where you replace johnny with the name of the new user):

adduser freya

You will then be asked a series of questions - simply answer them as applicable:

Adding user `freya' ...
Adding new group `freya' (1004) ...
Adding new user `freya' (1005) with group `freya' ...
Creating home directory `/home/freya' ...
Copying files from `/etc/skel' ...
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
Changing the user information for freya
Enter the new value, or press ENTER for the default
      Full Name []: freya freyasson
      Room Number []:
      Work Phone []:
      Home Phone []:
      Other []: my cat
Is the information correct? [y/N] y

Deleting users

To delete a user from your user list, simply type the following at the prompt (where 'phil' is replaced by the user to be deleted):

userdel -r phil

Note: the -r option will remove files from the user's home directory, including the directory itself and the user's main spool.

Groups

Creating groups

To create a Group, type the following at the command prompt (where you replace 'friends' by the name of your new group):

groupadd friends

Managing Group users

Adding users to a group

During the creation of a user

To add a user to a group during the creation of the user account, type the following command at the prompt (where you replace 'friends' by the group where you add the user, and 'eric' by the name of the user:

useradd -g friends eric

(for more options refer to man useradd)

For an existing user

usermod -g friends eric

(for more options refer to man usermod)