Group
Ubuntu Privilege: Group
Add group: groupadd
You can create a whole new system group and control the user’s privileges by using the group.
groupadd <group-name>
Check user group
groups user1
user1 : <other-groups> www-data
getent group www-data
www-data:x:33:kejyun,group1
getent group www-data | awk -F: '{print $4}'
kejyun,group1
Add user to a specific group
Using command to add user to a group
sudo adduser $USER www-data
Edit group file to add user to a group
sudo vim /etc/group
There is di
Add the specific user to the group at end of group. Seperated each user by commas.
www-data:x:33:kejyun,group1,group2
Add user with sudo root privileges
sudo adduser 帳號名稱 sudo
Change file group
No one can change the file owner to another user except root account
. So if you want to change the file group. You must add the sudo
in front of your command.
Non-privileged users (not root) cannot chown files to other user names. To use chown, a user must have the privileges of the target user. In other words, only root can give a file to another user.
sudo chown -R root:root ./folder