Section 4.1. Creating New Users and Groups


4.1. Creating New Users and Groups

The concepts of users and groups are important in Linux and, as an administrator, you'll surely find the need to add new users as you become more comfortable with the system, or begin to share some of your server's administrative duties. As with other tasks, you can add new users with either a graphical or text-based interface.

4.1.1. The User Manager Tool

Figure 4-1. Opening the User Manager.


In Fedora Core, user and group management tasks are handled by the User Manager tool, which you can start by selecting Desktop > System Settings > Users and Groups, as depicted in Figure 4-1.


Note: System Administration tools will often require root access. When they do, GNOME will prompt you for the root password via the dialog shown in Figure 4-2.Provided you enter the password correctly, you'll become authorized to perform system configuration actions as root without having to re-enter the root password. That authorization is signified by the badge icon in the top right panel, like that shown in Figure 4-3. Once you're done making configuration changes, you can end this authorization by clicking on the badge icon, then clicking the Forget Authorization button on the dialog that appears. The badge icon should then disappear.
4.1.2.1. Managing Users

Figure 4-4. The user listing.


The User Manager, shown in Figure 4-4, displays all the user accounts that currently exist on your system. It also displays for each user the User ID number, the group to which that user belongs, the user's full name (optional), the user's default shell, and the home directory. To add a user, click Add User. The dialog shown in Figure 4-5 will appear.

As you can see in Figure 4-5, a Fedora administrator has plenty of options to consider when adding a new user. These include defining the home directory, creating a private group for the user, manually assigning a user ID, and selecting the user's shell. While the defaults are perfectly acceptable in most cases, the process is very flexible and caters well for unusual cases.

4.1.2.2. Managing Groups

Users within a Linux system may be consolidated into groups, which can ease the management of file permissions for groups of users. You might, for example, create a "developers" group, into which you'll add all the Web developers who create code for your server. You'd give that group appropriate permissions to the files of your Web application, providing each developer the ability to edit those files without allowing ordinary users access to them.

Figure 4-5. The Create New User dialog.


Figure 4-6. The Create New Group dialog.


To add a new group, select Add Group from the User Manager window. The dialog shown in Figure 4-6 will appear.

First, you'll need to name the group. In our example, you might, for instance, name the group "Developers." You can also accept the pre-assigned group ID, or GID (500, in this case), or check the Specify group ID manually checkbox to manually assign the group a group ID.[1]

[1] You'll almost always want to accept the pre-assigned ID, because it doesn't matter what a group's ID is, except in very rare cases. If you come across one of those rare cases, you'll know why you want a specific ID; otherwise, accept the suggestion.

To view the current groups, and add a user to an existing group, select the Groups tab in the User Manager window, as illustrated in Figure 4-7.

Figure 4-7. The User Manager's Groups tab.


There are two methods by which we can add a user to a group. The first is to select a group in the User Manager and click the Properties button. In the dialog that appears, select the Group Users tab to see a list of users you can add to this group, as shown in Figure 4-8.

Ensure that you've checked all of the users you'd like to include as members of this group, and click OK.

The other way we can add a user to a group is via the User Manager's Users view. In the User Manager, click on the Users tab, select the user you'd like to add to a group, and click Properties. Clicking the Groups tab displays a list of all of the groups of which this user can become part, as shown in Figure 4-9.

Deleting a user or group within the User Manager window is as easy as creating one. Simply highlight the user or group, then click the Delete button in the User Manager window's toolbar.

Figure 4-8. Adding users to a group.


Figure 4-9. Adding a user to groups.


4.1.2. Managing Users from the Command Line

4.1.3.3. Creating Users and Groups with useradd and groupadd

To add users and groups from the command line, we use the groupadd and useradd commands .


Note: Unfortunately, you can't use groupadd or useradd as easily as you might use ls in the default installation of Fedora Core. The groupadd and useradd tools are located in the directory /usr/sbin, which isn't part of the default PATH. To add this directory to the PATH variable, enter export PATH=$PATH:/usr/sbin at the command prompt, as we discussed in Chapter 3. This will only take effect for the current shell session; as soon as you close the terminal window, this value will disappear.If you'd rather have this command run automatically every time you start the shell, you can add the command to .bashrc , a hidden file that's automatically executed every time you start up the bash shell. To open this file in gedit, select File > Open…. In the Open File… dialog, right-click in the area in which the files are listed, and click Show Hidden Files, as depicted in Figure 4-10.Locate .bashrc and open it. Add the export command to the end of the file, as shown below.The next time you open a terminal window, this command will be executed automatically. Note that this won't affect any shells you have open at the momentyou'll need to close and reopen them in order for the command to execute.

Let's look at an example of these commands, which we'll run as root.

[kermit@swinetrek ~]$ su Password: [root@swinetrek kermit]# groupadd muppets [root@swinetrek kermit]# useradd -G muppets -c "Miss Piggy" \ > misspiggy [root@swinetrek kermit]# passwd misspiggy Changing password for user misspiggy. New UNIX password: Retype new UNIX password: passwd: all authentication tokens updated successfully. [root@swinetrek kermit]# exit exit [kermit@swinetrek ~]$ 

In this example, we can see that the groupadd command has been used to create a group called "muppets." Remember that groupadd is located in /usr/sbin, so you might need to enter /usr/sbin/groupadd instead.

Next, we use the useradd command to create a user called "misspiggy," and add her to the "muppets" group (as specified by the -G option) with the full name "Miss Piggy" (as specified by the -c option). When a user is created using useradd, that user's password is locked; we need to change it in order to unlock it. To do so, we use the passwd tool.

4.1.3.4. Deleting Users and Groups with userdel and groupdel

You can delete users and groups using the userdel and groupdel commands. Note that userdel will leave the users' home directory intact; you might want to delete this directory while you're logged in as root:

[kermit@swinetrek ~]$ su Password: [root@swinetrek kermit]# groupdel muppets [root@swinetrek kermit]# userdel misspiggy [root@swinetrek kermit]# rm -rf /home/misspiggy/ [root@swinetrek kermit]# exit exit [kermit@swinetrek ~]$ 



Run Your Own Web Server Using Linux & Apache
Run Your Own Web Server Using Linux & Apache
ISBN: 0975240226
EAN: 2147483647
Year: 2006
Pages: 92

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net