How to Manage Users and Groups in Linux
There are several ways to create a users and groups in Linux that are graphical, however the standard way to create a user is through the command line.
Step one is to create the group, then create the user and place the user in the group.
In Linux when a user is created without specifying a group then a group is created by the same name as the user.
Consider a system that has 100 users if each user was created without specifying a group then there will be 100 groups.
You must be root in order to create users, groups, and users' passwords.
# groupadd executive Creates the executive group.
To verify that a group was created view the /etc/group file.
# useradd -d /home/gbush -group executive gbush Creates the directory /home/gbush, add the user gbush to the group executive group.
To verify that the user was created view the /etc/passwd file.
This file contains a record of all of the users on the system.
# passwd gbush texan texan Creates a password for the user gbush as texan.
The password of texan does not fit the necessary length and complexity, but as root you can change the password to anything you want.
# useradd -d /home/dcheney -group executive dcheney Other useful commands are userdel and groupdel for deleting users and groups.
usermod and groupmod for modifying users and groups.
Tip: Considering the current political structure of this example (executive, legislative and judicial) can help you create groups, then add the appropriate users.
New Sessions In Linux you can create login sessions by pressing Control+ALT and Function1 through Function6 keys.
This is a good way to test the new user accounts.
Identity Because it can be difficult knowing who you are logged in as you can type the following command #id This will tell you who you are and what groups you belong to.
You may also become another user by using the su command.
#su gbush This command would allow you to become gbush.
If you are not the root user then you will be asked for the password of gbush.
#su - gbush The above command says that you want to become gbush and you would like to run his startup scripts and be placed in his home directory.
You may become a member of a different group by using the newgrp command.
#newgrp executive Would place you in the executive group.
Please note that if this is not your default group as noted in the /etc/passwd file, and you are not listed as a member in the /etc/group file then you will not be allowed to become a member of the group.
As far as root is concerned, root can do anything at anytime.
HELP Help can be obtained by using the manual command.
#man ls Would give you the manual page of the ls command.
This can be quite helpful if you forget an option to a command.
If you cannot remember a command but you know what it is similar to you can use the apropos command.
# apropos who Would show you all of the command that have the word contain the world who.
The help command can be used to get help on some built in command.
#help logout If you are concerned about where in the file system a command would be run from type in the following #whereis rm Would show you where in the system the rm command would be executed, if you were to type the command.
If you know part of the command but you would like to know where it exist on the system you can use the locate command which searches a database of file name that is maintained nightly.
#locate who Would show you all of the files that have the word who in them.
This search is done through out the system.
This is good for user defined commands.
Commands In order to configure the Linux computer for different services, you should have a good understanding of standard UNIX and TCP/IP commands.
These are a few of the commands that are used in Linux: ls who cat pwd cd telnet rlogin ftp rcp traceroute login man cp bash ln passwd rm su touch startx df du rsh uptime vi pico at cron more find rmdir mkdir ping nslookup
Step one is to create the group, then create the user and place the user in the group.
In Linux when a user is created without specifying a group then a group is created by the same name as the user.
Consider a system that has 100 users if each user was created without specifying a group then there will be 100 groups.
You must be root in order to create users, groups, and users' passwords.
# groupadd executive Creates the executive group.
To verify that a group was created view the /etc/group file.
# useradd -d /home/gbush -group executive gbush Creates the directory /home/gbush, add the user gbush to the group executive group.
To verify that the user was created view the /etc/passwd file.
This file contains a record of all of the users on the system.
# passwd gbush texan texan Creates a password for the user gbush as texan.
The password of texan does not fit the necessary length and complexity, but as root you can change the password to anything you want.
# useradd -d /home/dcheney -group executive dcheney Other useful commands are userdel and groupdel for deleting users and groups.
usermod and groupmod for modifying users and groups.
Tip: Considering the current political structure of this example (executive, legislative and judicial) can help you create groups, then add the appropriate users.
New Sessions In Linux you can create login sessions by pressing Control+ALT and Function1 through Function6 keys.
This is a good way to test the new user accounts.
Identity Because it can be difficult knowing who you are logged in as you can type the following command #id This will tell you who you are and what groups you belong to.
You may also become another user by using the su command.
#su gbush This command would allow you to become gbush.
If you are not the root user then you will be asked for the password of gbush.
#su - gbush The above command says that you want to become gbush and you would like to run his startup scripts and be placed in his home directory.
You may become a member of a different group by using the newgrp command.
#newgrp executive Would place you in the executive group.
Please note that if this is not your default group as noted in the /etc/passwd file, and you are not listed as a member in the /etc/group file then you will not be allowed to become a member of the group.
As far as root is concerned, root can do anything at anytime.
HELP Help can be obtained by using the manual command.
#man ls Would give you the manual page of the ls command.
This can be quite helpful if you forget an option to a command.
If you cannot remember a command but you know what it is similar to you can use the apropos command.
# apropos who Would show you all of the command that have the word contain the world who.
The help command can be used to get help on some built in command.
#help logout If you are concerned about where in the file system a command would be run from type in the following #whereis rm Would show you where in the system the rm command would be executed, if you were to type the command.
If you know part of the command but you would like to know where it exist on the system you can use the locate command which searches a database of file name that is maintained nightly.
#locate who Would show you all of the files that have the word who in them.
This search is done through out the system.
This is good for user defined commands.
Commands In order to configure the Linux computer for different services, you should have a good understanding of standard UNIX and TCP/IP commands.
These are a few of the commands that are used in Linux: ls who cat pwd cd telnet rlogin ftp rcp traceroute login man cp bash ln passwd rm su touch startx df du rsh uptime vi pico at cron more find rmdir mkdir ping nslookup