Administración de Usuarios y Grupos en Linux
Gestión de usuarios y grupos en Linux: passwd, shadow, permisos y manipulación de cuentas.
Users and Groups
-
users,whoandwcommands can be used to check the users logged into the system. -
/etc/passwdfile contains user info like username and home directory location. -
/etc/shadowcontains the username and hash. -
/etc/groupcontains info about groups. -
File and directory permissions can be viewed using
ls -la. -
Execute permission for a directory determines if the user can execute a command inside the directory.
-
Modifying permissions and ownership:
-
chmod g-w hello.txt- removes group-write permission -
chmod a=,u=r hello.txt- changes permission for all users to none, and adds read permission for user (file owner) -
chmod 664 hello.txt- read-write permission for user & group, and only read permissions for everyone else -
sudo chown mike hello.txt- change user ownership of file -
sudo chgrp mike hello.txt- change group ownership of file
-
-
sudo -u anotheruser cat restricted.txtallows us to read the file as another user. -
su newusercan be used to switch user. -
passwdcan be used to change the user's password;sudo passwd newuserto change another user's password.
Users manipulation
- Adding a new user
adduser <user name>
- Adding a User to the sudoers File
adduser <user name> sudo
- Switching Users
su <user name>
ACCESS
su - --------------Create New Login Session for User ROOT
su -c 'ls Desktop' ---Execute only one commands donot create login session