Create a new user and group
# Add user dev
useradd dev
# Add user group
groupadd group_dev
# Set password user dev
passwd dev
# Set password user and group
gpasswd -a user_dev group_dev
# Set owner folder user dev and group dev
chown -R user_dev:group_dev /var/www/folder/
# Set owner user
chown -R user_dev /var/www/folder
# Set owner group
chgrp -R group_dev /var/www/folder
# Set permission
chmod -R g+rw /var/www/folder
# View list user
cat /etc/passwd
# Delete/Remove user
userdel userName
userdel [options] userName
userdel -r userName
# ADD user used direct path
usermod -d /var/www/folder/ user_dev
- “/var/www/folder/”: folder path owner
- “group_dev”: Group user name
- “user_dev”: User name
Create a New Sudo User
- Log in to your server as the
root
user - Use the
adduser
command to add a new user to your system. - Use the
usermod
command to add the user to the wheel
group.usermod -aG wheel username - By default, on CentOS, members of the
wheel
group have sudo privileges. - Test sudo access on new user account
- Use the
su
command to switch to the new user account.su – username - As the new user, verify that you can use sudo by prepending “sudo” to the command that you want to run with superuser privileges.sudo command_to_run
- For example, you can list the contents of the
/root
directory, which is normally only accessible to the root user.sudo ls -la /root