Site icon LCDUNG

Những lệnh linux về User và Group thường dùng

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

Create a New Sudo User

  1. Log in to your server as the root user
  2. Use the adduser command to add a new user to your system.
  3. Use the usermod command to add the user to the wheel group.usermod -aG wheel username
  4. By default, on CentOS, members of the wheel group have sudo privileges.
  5. Test sudo access on new user account
    • Use the su command to switch to the new user – 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
Exit mobile version