Anda di halaman 1dari 12

HOLY ANGEL UNIVERSITY

COLLEGE OF ENGINEERING AND ARCHITECTURE


COMPUTER ENGINEERING DEPARTMENT

Topic Managing Users and Groups


Laboratory # M5
To manage user accounts
To understand the password file
Objectives
To manage groups
To change user and group ownerships of files and directories

Name. : Date Submitted :

Grade : College Faculty : Engr. Lucky Padilla


Managing Users and Groups 1

I. INTRODUCTION

Linux is a multiuser system, so it has many user accounts. Even if you are the only user on your system, many servers require a unique
user- name and group name.

Also, users can belong to one or more groups. Typically, each username has a corresponding private group name. By default, each user
belongs to that corresponding private group. However, you can define other groups for the purpose of providing access to specific files
and directories based on group membership.

User and group ownerships of files are a way to make sure that only the right people (or the right process) can access the right files and
directories. Managing the user and group accounts is a typical system administration job. Its not that hard to do this part of the job,
given the tools that come with Linux. I show you how in this chapter.

On the other hand, much of Linux system administration deals with handling mundane day-to-day tasks. Many of these tasks relate to
users and groups: adding them, deleting them, configuring the environments, and so on.

On a small system, you might perform such tasks infrequently, but on a busy system, you might adjust accounts frequently. In any event,
you must know how to do these things.
Managing Users and Groups 2

II. PROCEDURES

Managing User Accounts

How to Add Users

1. Log into the Linux system as a normal user.


2. Then change the account into root user by issuing the below command.

3. Add the following users using adduser command.

Full Name Username Password


User Test 01 usertest01 P@$$w0rd
User Test 02 usertest02 P@$$w0rd
User Test 03 usertest03 P@$$w0rd
User Test 04 usertest04 P@$$w0rd
User Test 05 usertest05 P@$$w0rd

To verify the created users, use ls and cat command.


Managing Users and Groups 3

How to Change Password

1. User root changing the password of usertest01

2. User might wish to change their passwords at a future date. Here is how unprivileged user would change his own
password. Login as usertest02 user and use passwd command to change the password.

How to Modify a User

1. To modify Full Name, issue the below command

How to Delete a User

1. To delete a user and its home directory, use the command deluser.

To find out more about the adduser, deluser, and usermod commands, type man adduser, man deluser, or man usermod
in a terminal window.
Managing Users and Groups 4

Understanding the /etc/passwd File

1. The /etc/passwd file is a list of all user accounts. Its a text file and any user can read it no special privileges needed. Each
line in /etc/passwd has seven fields, separated by colons (:).

Here is a typical entry from the /etc/passwd file:

username usertest03
password x
user id 1003
group id 1003
user information (optional) User Test 03
home directory /home/user/usertest03
login shell /bin/bash
Managing Users and Groups 5

Parameter Description
Username An alphanumeric username, usually eight characters long and unique (Linux allows usernames to
be longer than eight characters, but some other operating system do not)
Password When present, a 13-charater encrypted password(an empty field means that no password is
required to access the account, an x means the password is stored in the /etc/shadow file, which
is more secure)
UID A unique number that serves as the user identifier (root has UUID of ) and usually the UIDs
between 1 to 100 are reserved for non-human users such as servers; keeping the UID less than
32762 is best)
GID The default group ID of the group to which the user belongs (GID 0 is for group root, other groups
are defined in /etc/group and users can be and usually are in more than one group at a time)
GECOS Optional personal information about the user (the finger command uses this field and GECOS
stands for General Electric Comprehensive Operating System, a long-forgotten operating system
thats immortalized by the name of this in /etc/passwd)
homedir The name of the users home directory
shell The command interpreter (shell), such as Bash(/bin/bash), that executes when this user logs in
Managing Users and Groups 6

Managing Groups

1. A group is something to which users belong. A group has a name and an identification number (ID). After a group is
defined, users can belong to one or more of these groups. You can find all the existing groups listed in /etc/group.

groupname sudo
password X
group id 27
membership testadmin

Parameter Description
groupname The name of the group (for example, wheel)
Password The group password (an x means that password is stored in the /etch/shadow file)
GID The numerical group ID (for example, 10)
membership A comma-separated list of usernames that below to this group (for example, root, naba)

2. Add the following groups

grouptest01
grouptest02
grouptest03

To verify the created group, issue the command cat


Managing Users and Groups 7

3. To remove a group, use the delgroup command. For example, to remove group named grouptest03, type delgroup
grouptest03.

4. To add a user usertest01 in a group namely grouptest01 and grouptest02 , use the below command

5. To add multiple users in a group use gpasswd command. For instance, to add usertest01 and usertest02 to grouptest01
use the below command:

6. Removing a user in a group, use gpasswd -d.


Managing Users and Groups 8

Changing User and Group Ownership of Files

1. In Linux, each file or directory has two types of owners a user and a group. In other words, a user and group own each
file and directory. The user and group ownerships can control who can access a file or directory.

2. To view the owner of a file or directory, use the ls -l command to see the detailed listing of a directory. For example, heres
a typical files information:

3. In this example, the first set of characters shows the files permission setting who can read, write, or execute the file.
The third and fourth fields (in this example, testadmin testadmin) indicate the user and group owner of the file. Each user
has a private group that has the same name as the username. So most files user and group ownership appear to show
the username twice. As a system administrator, you may decide to change the group ownership of a file to a common
group.

4. Change the group ownership and user owner of testfile01.txt file to the grouptest01 and usertest01 respectively. To do
that, log in as root and type the following commands:

5. In fact, chown can change both the user and group owner at the same time. For example, to change testfile01.txt user
owner to user.test02 and the group owner to grouptest02, type below command:
Managing Users and Groups 9

Changing File Permission

1. chmod command has two formats

Format Commands Description


Symbolic chmod g+w filename to add write permission on group
chmod g-w filename to remove write permission
chmod go+rwx filename to add read, write, and execute permission on group and others
chmod go-rwx filename to remove read, write, and execute permission on group and others
chmod ug=rw filename user and group will only have read and write permission
Binary chmod 754 filename user rwx(111), group r-x(101), others r--(100)
chmod 700 filename user rwx(111), group and others ---(000)

2. Directory modes

Mode Description
rwx full access
r-w limited access (enter and read)
--- no access

3. Change testfile01.txt permission : user full access, group limited access and others no access.

4. To change multiple file permissions, use the R option.


Managing Users and Groups 10

III. LABORATORY QUESTIONS

1. Summarize methods of creating and modifying user accounts.


2. Describe the function of groups in Linux.
3. Explain the purpose of the skeleton files.
4. Assuming you have existing users with their old passwords. As a linux administrator, your boss assigned you to change their
passwords. He has a list of users in a text file with their new passwords. What is the best command will help you solve this
problem?
5. What is the Linux command to show the below screenshot? __________________
Managing Users and Groups 11

IV. REMARKS AND CONCLUSIONS

Anda mungkin juga menyukai