martes, 8 de marzo de 2016

LINUX-CENTOS-LAB-ejercicios combinando comando useradd,usermod,groupadd,chage,chgrp,id,

En el siguiente lab revisaremos requerimientos complejos que pueden ser resueltos combinando los comandos examinados en los post anteriores.

Create two users: john with uid/gid equal to 2000, password 12345678 and davis with uid/gid equal to 3000, password 87654321. Make davis‘ account validity stopping in one month.

crea el user john con UID/GID 2000, password 12345678
[root@localhost ~]# /sbin/useradd -u 2000 john
[root@localhost ~]# /bin/id john
uid=2000(john) gid=2000(john) groups=2000(john)
[root@localhost ~]# /bin/passwd john 
Changing password for user john.
New password: 
BAD PASSWORD: The password fails the dictionary check - it is too simplistic/systematic
Retype new password: 
passwd: all authentication tokens updated successfully.
[root@localhost ~]# 


crea user davis con UID/GID 3000 con passwd 87654321
[root@localhost ~]# /sbin/useradd -u 3000 davis
[root@localhost ~]# 
[root@localhost ~]# /bin/id davis
uid=3000(davis) gid=3000(davis) groups=3000(davis)
[root@localhost ~]# 
[root@localhost ~]# /bin/passwd davis
Changing password for user davis.
New password: 
BAD PASSWORD: The password fails the dictionary check - it is too simplistic/systematic
Retype new password: 
passwd: all authentication tokens updated successfully.
[root@localhost ~]# 

obtiene la fecha de expiración de la passwd tal como queda después de la creación.
[root@localhost ~]# /bin/chage -l davis
Last password change : mar 08, 2016
Password expires : never
Password inactive : never
Account expires : abr 11, 1970
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
[root@localhost ~]# 

obtiene la fecha actual y la correspondiente al próximo mes. 
[root@localhost ~]# /bin/date 
mar mar  8 17:48:04 CLT 2016
[root@localhost ~]# /bin/date -d +"1 month"
vie abr  8 17:48:15 CLT 2016
[root@localhost ~]# 

Modifica la fecha de expiración de la cuenta davis
[root@localhost ~]# /bin/chage -E 2016-04-08 davis
[root@localhost ~]# 

obtiene la fecha de expiración de la passwd de la cuenta davis después de la modificación. 
[root@localhost ~]# /bin/chage -l davis
Last password change : mar 08, 2016
Password expires : never
Password inactive : never
Account expires : abr 08, 2016
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
[root@localhost ~]#

Create a directory named /common. Allow john and davis to share documents in the /commondirectory using a group called team. Both of them can read, write and remove documents from the other in this directory but any user not member of the group can’t.


crea el directorio "/common" y el grupo "team"  
[root@localhost ~]# mkdir /common
[root@localhost ~]# /sbin/groupadd team 
[root@localhost ~]# cat /etc/group | grep team
team:x:10503:

asigna el grupo "team" como owner al directorio "/common".
[root@localhost ~]# /bin/chgrp team /common


[root@localhost ~]# ls -ltr /  | grep common
drwxr-xr-x    2 root team  4096 mar  8 18:02 common
[root@localhost ~]# 

cambia los atributos de ejecución del directorio para el grupo "team"
[root@localhost ~]# ls -ltr /  | grep common
drwxr-xr-x    2 root root  4096 mar  8 18:02 common
[root@localhost ~]# 
[root@localhost ~]# chmod 770 /common/
[root@localhost ~]# ls -ltr / | grep common
drwxrwx---    2 root team  4096 mar  8 18:02 common
[root@localhost ~]# 


asigna el grupo "team" a los usarios "john" y "davis"
[root@localhost ~]# /sbin/usermod -aG 10503 john
[root@localhost ~]# /sbin/usermod -aG 10503 davis
[root@localhost ~]# 
[root@localhost ~]# /bin/groups john
john : john team
[root@localhost ~]# /bin/groups davis
davis : davis team
[root@localhost ~]# 

Comprueba que los usuarios "john" y "davis" puedan escribir sobre el directorio "/common"
[root@localhost ~]# su - john
Last login: mié mar  9 10:26:19 CLT 2016 on pts/1
[john@localhost ~]$ touch /common/john.txt
[john@localhost ~]$ ls -ltr /common/john.txt 
-rw-rw-r-- 1 john john 0 Mar  9 10:37 /common/john.txt

[root@localhost ~]# su - davis
[davis@localhost ~]$ touch /common/davis.txt
[davis@localhost ~]$ ls -ltr /common/davis.txt 
-rw-rw-r-- 1 davis davis 0 Mar  9 10:38 /common/davis.txt

[root@localhost ~]# touch /common/root.txt
[root@localhost ~]# ls -ltr /common/root.txt 
-rw-r--r-- 1 root root 0 mar  9 10:38 /common/root.txt
[davis@localhost ~]$ 

Comprueba que cualquier otro usuario no pueda escribir sobre el directorio "/common"
[root@localhost ~]# su - user102
[user101@localhost ~]$ touch /common/user102.txt
touch: cannot touch ‘/common/user102.txt’: Permission denied
[user101@localhost ~]$ 


No hay comentarios:

Publicar un comentario