Creating New Users and Groups


The easiest and quickest way of adding a new user or group is to use YaST2. Of course, you can also perform these tasks through the command line, as we explain later in this chapter.

Adding and Deleting Users and Groups with YaST2

Here are the basic steps for using YaST2 to add a new user:

  1. Select K menu ® Control Center, click the YaST2 Modules icon, click Security and Users, and then click Edit and Create Users.

  2. This requires root privileges, so click the Administrator Mode button and enter your root password.

  3. You see a list of current ordinary (nonroot or system) users. To add a new user, click the relevant button at the bottom left of the screen.

  4. You see a screen virtually identical to that presented during initial installation, as shown in Figure 30-1. Enter the full name of the new user (for your own reference), the new username, and the password.

    image from book
    Figure 30-1. Creating new users is easily done via the central YaST2 configuration program.

  5. If you want to set a password expiration time, click the Password Settings button. This can be useful if you want to create a user account that is valid for a limited period.

    Note 

    Unlike under Windows NT, when a user account's password expires in SUSE Linux, the user won't then be prompted to enter a new password. The account will simply be disabled, at least until the root user steps in to reset the password. Also, the user won't be able to overcome the expiration by changing her password manually in advance. The expiration date applies to any password on the account.

  6. If you want to manually enter a UID number, or adjust the groups to which the user belongs, click the Details button. As discussed earlier, by default, the user will belong to a handful of system groups that will give her access to particular hardware resources. You can see a list of these here. However, it's not advisable to change any default group memberships, because the user account could be seriously crippled when it comes to running programs on the system.

  7. Click the Create button.

  8. You're returned to the username list. Click the Finish button to confirm the changes.

When you're finished, the new user will be set up and will have her own directory within the /home/ directory.

Adding a new group is similarly easy. Simply click Edit and Create Groups on the left side of the YaST2 program window. You can enter a group name and add members from the list of current users. You can also manually specify a GID if you wish. Perhaps surprisingly, a group can also have a password. This comes into play when a user uses the newgrp command to temporarily switch group membership. If he tries to switch to a group that is password-protected, he will be prompted for the password first.

If you want to edit any of the user or group information, from the main Edit and Create Users or Edit and Create Groups screen, select the user or group you are interested in, and then click the Edit button. You can then change any of the details you previously entered. Click Next to return to the main administration screen.

To delete a user account, from the main Edit and Create Users screen, select the user you want to remove, and then click the Delete button. You'll be asked to confirm that you really want to go through with the deletion.

If you want to delete a group, you'll first need to remove all the members from the group. From the main Edit and Create Groups screen, select the group, click Edit, and uncheck all the boxes next to the users in the list. Then you can return to the main Edit and Create Groups screen, select the group, and click the Delete button.

Adding and Deleting Users and Groups at the Command Line

Creating new users at the command-line shell is easily done using the useradd command. This command can be run only by root. When switching to the root user, use the following command in order to adopt the root user's $PATH details and thereby access root-only commands:

su -

The command to add a user is normally used in the following way:

useradd -m <username>

The -m command option tells the command to create a home directory for the user (this is created from a template, so comes ready-made with SUSE-specific folders, configuration files, and so on). Used on its own, useradd merely updates system files with the new user's details and nothing else. There are several other useful command options, which can be discovered by a quick browse of the command's man page.

Creating a new user this way will automatically add him to the Users group—the default group that most ordinary users are added to under SUSE Linux. In addition, the command uses a range of skeleton settings that are applied to the account. In this way, the user will be added to the standard system groups necessary to access various pieces of hardware, and vital hidden system files for various pieces of software will be installed in his home directory, ready for use.

Caution 

Creating a new user won't automatically apply a password to the account. Anyone will be able to log in with the username by leaving the password field blank. Because of this, the first thing you should do is to use the passwd command to assign a password to the new account, as we discuss in a minute.

Perhaps unsurprisingly, deleting a user can be achieved with the userdel command. Used on its own, this sweeps the system files, removing any mention of the user. However, the command is normally used with the -rf command options. These cause the user's home direc-tory to be removed, too, along with any files it might contain. The -f option means that the command won't stop with an error if it comes across any files in the home directory that are not owned by the user. Because of this, userdel is a powerful command and should be used with care!

Groups can be added using the groupadd command in much the same way as using the useradd command. The -p option can be added to set a password for the new group. The groupdel command removes the group.




Beginning SUSE Linux from Novice to Professional
Beginning SUSE Linux: From Novice to Professional
ISBN: 1590594584
EAN: 2147483647
Year: 2005
Pages: 293
Authors: Keir Thomas

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