0% found this document useful (0 votes)
15 views4 pages

Lap 3 User Management

Uploaded by

mtv.maxamed
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views4 pages

Lap 3 User Management

Uploaded by

mtv.maxamed
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

User management with CLI

======================

Create a new user


==================
[root@localhost ~]# useradd Osman //create a new user called Osman

User id
========
[root@localhost ~]# id Osman

User delete
============
[root@localhost ~]# userdel Osman // delete from /etc/password
[root@localhost ~]# cd /home/
[root@localhost home]# rm -rf Osman // delete from home directory

User delete from home directory


===================
[root@localhost ~]# userdel –rf Osman

How to know that user has been created


==============================
[root@localhost ~]# cat /etc/passwd // check it that user has been created
osman:x:1003:1004::/home/osman:/bin/bash

Print only the last two user by using tail


==================================
[root@localhost ~]# tail -n 2 /etc/passwd
muxiiska:x:1002:1002::/home/muxiiska:/bin/bash
osman:x:1003:1004::/home/osman:/bin/bash

Print only the first two user by using head


==================================
[root@localhost ~]# head -n 2 /etc/passwd
root:x:0:0:/root/root:/bin/bash
bin:x:1:1:/bin:/sbin/nologin
User’s password details
===================
[root@localhost ~]# useradd casha
[root@localhost ~]# Passwd –S casha // to know that use have a passwd or not
[root@localhost ~]# tail –n /etc/shadow // another way to know passwd infor….

Creating passwd two ways


============================================

Change the passwd by the user


==============================
[caasha@localhost ~]$ passwd
Changing password for user caasha.
Changing password for caasha.
(current) UNIX password:
New password:
Retype new password

Change passwd by the root


===========================
[root@localhost ~]# passwd caasha
Changing password for user caasha.
New password:
Retype new password

Remove the passwd


===================
[root@localhost ~]# passwd –d caasha // remove passowd’s caasha

Note: if you create user account without passwd u can’t del that user u must make a passwd to del

Make the account locked


=============================
[root@localhost ~]# usermod -L caasha //that user account has locked
[root@localhost ~]# tail –n 1 /etc/shadow // this sample (!) is identify by lock

How to unlock the account


=======================
[root@localhost ~]# usermod –U caasha // make unlock the account

Make comment or second name the user


=-=-=================================
[root@localhost ~]# usermod –c fadxi caasha
[root@localhost ~]# tail –n 1 /etc/passwd
Change user’s UID
======================
[root@localhost ~]# usermod u 1200 khaliif
[root@localhost ~]# grep Mahdi /etc/passwd

Change user’s Name


==================
[root@localhost ~]# usemod –l Mahdi Obsiyeh
[root@localhost ~]# grep Mahdi /etc/passwd

User’s password information

Set last password change


=======================
[root@localhost ~]# chage –d 2020-12-16 Mahdi // last password changed//
[root@localhost ~]# chage –list Mahdi

Change account expire date


=======================
[root@localhost ~]# chage –E 2022-04-20 Mahdi // expire date has changed//
[root@localhost ~]# chage –list Mahdi // to verify //

Password inactive
=======================
[root@localhost ~]# chage –I 30 // the account will be work within 30 in active//
[root@localhost ~]# chage –list Mahdi // to verify //
Minimum number of days between password change
================================================
[root@localhost ~]# chage –m 4 Mahdi // user Mahdi will change his password after 4 days //
[root@localhost ~]# chage –list Mahdi

Maximum number of days between password change


================================================
[root@localhost ~]# chage –M 320 Mahdi // this section is related “password expires” //
[root@localhost ~]# chage –list Mahdi

Warning days before password expire


================================================
[root@localhost ~]# chage –W 6 Mahdi /the user will receive a warning days before the password expire/
[root@localhost ~]# chage –list Mahdi

You might also like