You are on page 1of 4

LAB 1 – MODULE1: QUẢN TRỊ USERS GROUP – PNH

1. Xem thông tin người dùng


 Xem file /etc/password
[root@localhost ~]$ cat /etc/passwd
root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin
adm:x:3:4:adm:/var/adm:/sbin/nologin
lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin
Quan sát và chỉ ra từng thành phần trong file /etc/passwd.

 Xem file /etc/shadow


[root@ localhost ~]#cat/etc/shadow
root:$6$ynfgmChLXklxFAjo$0mVOrBsDbVaC/7CcY.j/.blLUR/oofG9Ke7wb7koeqZ
aSSBP
pnh:$6$LwPhTxwhOvZ.CR8.$4Gt79dGXdmvUbLQziRE5VQHmAPJBHPbxpr45zzsr
KOy fq4SHLY/o05z4jBJD2iizVmNEFKZj5qGiskIZ2JgJx.:15517:0:99999:7:::

 Xem file /etc/group


root@localhost ~]#cat/etc/group
stapusr:x:491:
sshd:x:74:
cgred:x:490:
tcpdump:x:72:
oprofile:x: 16:
slocate:x:21:
dqtuan:x:500:
mysql:x:27:

2. Quản trị thông tin người dùng


root@localhost ~]#mand useradd
USERADD(8) System Management Commands NAME USERADD(8) useradd -
create a new user or update default new user information
SYNOPSIS
useradd.[options] LOGIN
useradd-D
useradd-D [options]
DESCRIPTION
When invoked without the -D option, the useradd command creates a new user
account
using the values specified on the command line plus the default values from the
system. Depending on command line options, the useradd command will update
system
files and may also create the new userA's home directory and copy initial fies.
By default, a group will also be created for the new user (see-g, -N, -U, and

 Tạo accoun mới


root@localhost ~]#useradd pnh

 Học viên: Thực hiện và đối chiếu với lý thuyết đã học, ý nghĩa của từng
option đối với tài khoản vừa được tạo:
o Kiểm tra tài khoản vừa tạo trong file /etc/password
o Kiểm tra tài khoản vừa tạo trong file /etc/shadow
o Kiểm tra tài khoản vừa tạo trong file /etc/group

 Thay đổi password cho người dùng


root@localhost ~]#passwd pnh

 Khóa tài khoản người dùng


root@localhost ~]#passwd –l pnh
root@localhost ~]#cat /etc/shadow |grep pnh

3. Thay đổi thông tin người dùng


root@localhost ~]#man usermod
NAME
usermod - modify a user account
SYNOPSIS
usermod [options] LOGIN
DESCRIPTION
Microsoft· Partner
The usermod command modifies the system account files to reflect the
changes that are specified on the command line. The usermod command
modifies the system account files to reflect the changes that are specified on
the command line.

Disable tài khoản pnh


root@localhost ~]# usermod -L nv2
Disable tài khoản pnh
root@localhost ~]#usermod -U nv2

4. Tạo nhóm người dùng


[root@localhost ~]#man group
NAME
group - user group file
DESCRIPTION
/etc/group is a text file which defines the groups on the system.
There is one entry per line, with the following format: group_ name:passwd:G
ID:user _list The field descriptions are:

Học viên dùng lệnh groupadd tạo nhóm: lpi1 và lpi2


[root@localhost ~]# groupadd lpi1
[root@localhost ~]# groupadd lpi2

Học viên kiểm tra nhóm trong /etc/group


[root@localhost ~]# cat /etc/group
mysql:x:27:
lpi1:x: 1002:
lpi2:x: 1003:

5. Tạo nhóm người dùng


[root@localhost~]# man groupmod
NAME
.groupmod - modify a group definition on the system
SYNOPSIS
groupmod [options] GROUP
DESCRIPTION
The groupmod command modifies the definition of the specified GROUP by
modifying the appropriate entry in the group database.
OPTIONS
The options which apply to the groupmod command are: -g, --gid GID
The group ID of the given GROUP will be changed to GID

Đổi tên nhóm lpi1, lpi2 thành lp43, lpi4


[root@localhost~]# groupmod -n lpi1 lpi3
[root@localhost~]# groupmod -n lpi2 lpi4

6. Quản trị tài khoản trong nhóm


Add users pnh vào trong nhóm lpi3 và lpi4
[root@localhost~]# usermod –G lp3 pnh
[root@localhost~]# usermod –G lp4 pnh
Xóa nhóm
[root@localhost~]# groupdel lpi3 lpi4

You might also like