Create user in linux :
root@test2:~# useradd test1
root@test2:~# passwd test1
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
Note : we can also create user with adduser command.
-Whenever user is created in linux the default access is assigned to user via /etc/profile file.
-Username is added to /etc/passwd file.
-Same as username one group is created in /etc/group file.
-Encrypted password save into /etc/shadow file.
Delete user in linux:
root@test2:~# userdel test1
Lock user account in linux:
root@test2:~# passwd -l test1
passwd: password expiry information changed.
Unlock user account in linux:
root@test2:~# passwd -u test1
passwd: password expiry information changed.
root@test2:~# useradd test1
root@test2:~# passwd test1
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
Note : we can also create user with adduser command.
-Whenever user is created in linux the default access is assigned to user via /etc/profile file.
-Username is added to /etc/passwd file.
-Same as username one group is created in /etc/group file.
-Encrypted password save into /etc/shadow file.
Delete user in linux:
root@test2:~# userdel test1
Lock user account in linux:
root@test2:~# passwd -l test1
passwd: password expiry information changed.
when user will try to login he will get below message.
login as: test1
test1@192.168.0.10's password:
Access denied
When the user account is locked we can see ! sign after username in /etc/shadow file.
root@test2:~# cat /etc/shadow | grep test
test1:!$6$prWdpshs$A0WNBzbHC5sEke7hatNq8lFaB/Ux.SQ3vRc1.If4joDTD/AMpsuPYT.1mCmfBDUCoh6ND7izfcT9buo1wiZ581:17066:0:99999:7:::
root@test2:~# passwd -u test1
passwd: password expiry information changed.
You can also unlock by editing /etc/sadow file. remove the ! sign from locked account.
Linux user account details :
root@test2:~# chage -l test1
Last password change : Sep 22, 2016
Password expires : never
Password inactive : never
Account expires : never
Minimum number of days between password change : 0
Maximum number of days between password change : 99999
Number of days of warning before password expires : 7
See process run by user :
root@test2:~# ps -u test1
PID TTY TIME CMD
2442 ? 00:00:00 systemd
2443 ? 00:00:00 (sd-pam)
2463 ? 00:00:00 sshd
2464 pts/0 00:00:00 sh
Root access to test1 user :
Edit the /etc/sudoers and add the below line.
%test1 ALL=(ALL:ALL) ALL
Switch to another user :
sudo su - username
root@test2:~# sudo su - test1
No directory, logging in with HOME=/
$ bash
test1@test2:/$
No comments:
Post a Comment