#devops
- To add a user to the Linux system:
useradd devops
- setting user password:
passwd devops
If we want to add a user by making a directory use the -m flag
sudo useradd devops -m
-d dir
Set the user’s home directory to be dir.
-s shell
Set the user’s login shell to be shell.
-u uid
Set the user’s ID to be uid. Unless you know what you’re doing, omit this option and accept the default.
-g group
Set the user’s initial (default) group to group, which can either be a numeric group ID or a group name, and which must already exist.
-G group1,group2,…
Make the user a member of the additional, existing groups group1, group2, and so on.
-m
Copy all files from your system skeleton directory, /etc/skel, into the newly created home directory. The skeleton directory traditionally contains minimal (skeletal) versions of initialization files, like ~/.bash_profile, to get new users started If you prefer to copy from a different directory, add the -k option (-k your_preferred_directory).
To check whether the user added or not if the user added where it should be present:
sudo cat /etc/passwd
Adding group:
sudo groupadd DevOps
sudo groupadd QA
To check the Existing group:
1. sudo cat /etc/group
To add a user to the group
2. sudo gpasswd -a devops DevOps
-a for append
devops >> user
DevOps >> group
To create group
- sudo groupadd DevOps
Adding members(ubuntu centos) to the group (DevOps)
sudo gpasswd -M ubuntu, centos DevOps
-M flag for adding members
Difference Between -a and -m flag
-a
adding/appending the user to the group
-m
Adding a list of members to the group.
man Command is useful in Linux it is a manual page where all the flag information also command information are provided within it.
To delete user and group:
userdel -d username
gpasswd -d groupname
To make group admin:
- gpasswd -A
Three types of Linux Permission classes
User
group
other
Default permission is -rw-rw-r
chmod 777 file.txt
chmod 640 file.txt
for the user can get access from the file called sudoers file
cat /etc/sudoers
root ALL = (ALL:ALL) ALL
(ALL: ALL) >> user and group
Thank you for reading this Blog. Hope you learned something new today! If you found this blog helpful, please like, share, and follow me for more blog posts like this in the future.
I would like to connect with you at linkedin.com/in/madhuri-patil-278b19118