User and Group Management Flashcards
How can you add a user using the command?
useradd username or adduser username
How to create the user manually?
there are seven steps to creating a user manually:
1. Backup /etc/passwd, /etc/group, /etc/shadow.
2. Make entries in /etc/passwd and /etc/group respectively through vi or vim editor.
3. Create a home directory for the new user. mkdir /home/user
4. Change the permissions of the home directory to 700. chmod 700 /home/user
5. Copy the environmental files to the new home directory. cp /etc/skel/.* /home/user
6. Change the ownership of the home directory. chown user:user /home/user
7. Set password for the new user and test the login. passwd user then su - user
What files are modified while you create a user?
/etc/passwd for user information,
/etc/group for group information and /etc/shadow contains encrypted passwords
If you want to create a user manually on your local machine, in which file will you define
the user?
/etc/passwd
Name the fields of the /etc/passwd file.
username:password:UID:GID:comments:home
directory:shell
How can you get the ID number of a user and the username?
id username, cat /etc/passwd
What would happen if UID "0" is assigned to the user "marshal"?
security measures will be
bypassed for marshal, and the user marshal will have root level privileges since the UID 0 is reserved
for root. Audit trails, recovery difficulties, system security and integrity, security risks, accidental
system changes, user privileges, package management, elevated privileges.
Granting root-level access to another user should only be done under exceptional circumstances and
with a clear understanding of the potential consequences. If you need to provide administrative
access to other users, it's better to use mechanisms like sudo, which allow users to execute specific
commands with elevated privileges while maintaining a separation of privileges.
marshal will have root privileges.
What is a Primary group vs. Supplementary/secondary group?
Primary is automatically assigned upon user creation with useradd. To change primary group usermod -g <groupname> <user>.</user></groupname>
Secondary group is attached later to manage accessibility to certain directories that may have SGID. To append secondary Group, use: usermod -aG <secondary> <user></user></secondary>
What is the importance of "skel" files (found under /etc/skel)?
create default settings in a
new user’s home directory, has the environmental and initialization files.
environmental files
How would you check if there were any errors in /etc/password and /etc/group files?
pwck to check /etc/passwd, grpck to check /etc/group
How would you lock/unlock a user account, and what are some hints to know if one's account is locked or not?
“usermod -L username to lock, usermod -U username to unlock.
We can also use passwd -l username to lock and passwd -u username to unlock.
In /etc/shadow, a locked account will have a !! infront of the second (password) column if passwd -l is used, but only a single ! in front of the second (password) column if usermod -L is used.”
How can we create a group called "prod"?
groupadd prod
How to make the user "max" a part of the "prod" group?
usermod -aG prod max.