More Linux Server Topics - Network Diagram - About This Site

 

Chapter 1

Adding Linux Users

 

= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =

In This Chapter

Chapter 1

Adding Linux Users

Who Is The Super User?

How To Add Users

How To Delete Users

How To Tell The Groups To Which A User Belongs

How To Change Your Password

 

© Peter Harrison, www.linuxhomenetworking.com

 

= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =

One of the most important activities in administering a Linux box is the addition of users. I have included some simple examples to provide a foundation for future chapters. A more detailed description of the process is beyond the focus of this book. You may use the command “man useradd” to get the help pages on adding users with the useradd command or the “man usermod” to become more familiar with modifying users with the usermod command.

Who Is The Super User?

The super user with unrestricted access to all system resources and files is the user named "root". You will need to log in as user root to add new users to your Linux box 

How To Add Users

Adding users takes some planning, read through the steps below before starting:

·        Arrange your list of users into groups by function. In this example there are three groups "parents", "children" and "soho".


 

Parents    Children    Soho

 

Paul       Alice       Accounts

Jane       Derek       Sales

 

·        Add the Linux groups to your server:

 

[root@bigboy tmp]# groupadd parents

[root@bigboy tmp]# groupadd children

[root@bigboy tmp]# groupadd soho

 

·        Add the Linux users, assign them to their respective groups

 

[root@bigboy tmp]# useradd -g parents  paul

[root@bigboy tmp]# useradd -g parents  jane

[root@bigboy tmp]# useradd -g children derek

[root@bigboy tmp]# useradd -g children alice

[root@bigboy tmp]# useradd -g soho     accounts

[root@bigboy tmp]# useradd -g soho     sales

 

If you don't specify the group with the "-g", RedHat Linux will create a group with the same name as the user you just created. When each new user first logs in, they will be prompted for their new permanent password.

 

·        Each user's personal directory will be placed in the /home directory. The directory name will be the same as their user name.

 

[root@bigboy tmp]# ll /home 

drwxr-xr-x    2 root     root        12288 Jul 24 20:04 lost+found
drwx------    2 accounts soho         1024 Jul 24 20:33 accounts
drwx------    2 alice    children     1024 Jul 24 20:33 alice
drwx------    2 derek    children     1024 Jul 24 20:33 derek
drwx------    2 jane     parents      1024 Jul 24 20:33 jane
drwx------    2 paul     parents      1024 Jul 24 20:33 paul
drwx------    2 sales    soho         1024 Jul 24 20:33 sales

[root@bigboy tmp]# ll /home 

How To Change Passwords

You’ll need to create passwords for each account. This is done with the "passwd" command. You will be prompted once for your old password and twice for the new one. 

 

·        User "root" changing the password for user "paul"

 

[root@bigboy root]# passwd paul
Changing password for user paul.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.
[root@bigboy root]#

 

 

·        Users may wish to change their passwords at a future date. Here is how unprivileged user "paul" would change his own password.

 

[paul@bigboy paul]$ passwd

Changing password for paul
Old password: your current password
Enter the new password (minimum of 5, maximum of 8 characters)
Please use a combination of upper and lower case letters and numbers.
New password: your new password

Re-enter new password: your new password
Password changed.
[paul@bigboy paul]$

How To Delete Users

·        The userdel command is used. The "-r" flag removes all the contents of the user's home directory

 

[root@bigboy tmp]# userdel -r paul

 

How To Tell The Groups To Which A User Belongs

·        Use the "groups" command with the username as the argument

 

[root@bigboy root]# groups paul
paul : parents
[root@bigboy root]#