414 417




Using Linux:Managing Users and Groups






-->















Previous
Table of Contents
Next




Modifying Users with the usermod Command

The usermod command allows you to change all the parameters you set for a user when adding him or her to the system. Note that the user cannot be logged in when you are changing his or her login, UID, GID, or home directory because the system will get very confused.
To change a user’s configuration information, log in as the root user and enter the following command:


[root@insoc]# usermod -c “New Name” -d homedir -m -g
groupname -s shell -l newlogin currentlogin


where New Name is the user’s new real name (for example, if a user named Kurt Valaquen wanted to change his name to Kurt Harland), homedir is the new home directory for the user, groupname is the name of the default user group he will belong to, shell is the desired shell of the user, newlogin is the new login name the user wants, and finally currentlogin is the login name of the user you want to change.
For example, if a user wants to set his name to “Kurt Harland” with a home directory of /home/vector, a default group setting to ittf, using the shell /bin/bash and using the login name vector, you would use the following command:


[root@insoc /root]# usermod --o “Kurt Harland” --d /home/
vector --m --q ittf --s /bin/bash --l vector vector


See the man page regarding usermod for a list of all the available command-line options.


What am I typing?
If the preceding command appears cryptic to you, don’t worry. Its design was geared toward functionality over readability. Let’s dissect the preceding command to see what it is doing.
The usermod portion simply specifies the command we are running. This program will interpret the remainder of the line.
The first thing that will be interpreted is the string -o ”Kurt Harland“. The -o tells the program that we want to change the comment field of the password entry to ”Kurt Harland“. Quotation marks are placed around his name so that the program doesn’t get confused and think the string “Harland” is the next parameter.
Each of the parameters works in a similar way where strings that start with a dash character tell usermod that we want to change an aspect of the user’s settings and the string that immediately follows is the desired value. The last parameter is the user’s login, which is required for this command.


Deleting Users with the userdel Command

To remove a user from your system, use the userdel command. Note that the user must be logged out of the system before removing him. To use userdel, log in as the root user and enter the following command:


[root@insoc /root]# userdel --r login


where login is the login name of the user you want to remove.
For example, if you want to remove the user vector, you would use userdel as follows:


[root@insoc /root]# userdel --r vector


See the man page for userdel of a list of all the command-line options.
Adding, Editing, and Deleting Groups
Similar to the user commands, there are commands for controlling groups as well. They are


groupadd
Add groups

groupmod
Modify groups

groupdel
Delete groups

Adding Groups with the groupadd Command

The groupadd command allows you to add groups to the system from the command line. To do so, log in as the root user and enter the following command:


[root@insoc /root]# groupadd groupname


where groupname is the name of the group you want to add to the system.
For example, to add the group www to your system, you would use the command:


[root@insoc /root]# groupadd www


See the man page regarding groupadd for a full list of all the command-line options available.
Modifying Groups with the groupmod Command

To modify the name of a group after it has been created, use the groupmod command. To make the change, log in as the root user and enter the following command:


[root@insoc /root]# groupmod --n newgroup currentgroup


where newgroup is the new name you want to give the group, and currentgroup is the current name of the group.
For example, to change a group name from admin to sysadmin, you would use the following command:


[root@insoc /root]# groupmod --n sysadmin admin


See the man page regarding groupmod for a full list of all the command-line options available.
Deleting Groups with the groupdel Command

To remove an existing group, use the groupdel command as described here. Log in as the root user and enter the following command:


[root@insoc /root]# groupdel groupname


where groupname is the group you want to delete. There is one catch, however. You cannot delete a group if it is the primary group of any users. You either need to remove the users or change their primary group using the usermod command first.
For example, to remove the group ittf, you would use the command:


[root@insoc /root]# groupdel ittf


Changing User and Group Ownership
Linux provides two programs to help you manage user and group ownership from the command line. The first, gpasswd, allows you to administer a group with relative ease. chgrp, the second program, allows users to change the group of particular files.



Previous
Table of Contents
Next














Wyszukiwarka

Podobne podstrony:
414 (B2007) Rezewy na zobowiązania w bilansie
417 420
01aff02a1cb3ae2b1d5a37b1d85453f7 zip (417 60 kB)
417 419
417 (B2007) Koszty na przełomie roku
413 417
rozwoj2003id 414
417 ac
README (417)
Setra S 417

więcej podobnych podstron