How to add a new group to user root?

17,308

Solution 1

To add a particular user to a particular group use:

sudo usermod -a -G groupname username

Here a is very important because otherwise the user will be removed from all other groups

Your problem is probably because you missed the -a part in your command

Solution 2

You can add any user to any group by typing:

sudo gpasswd -a username groupname

Share:
17,308

Related videos on Youtube

IgorAlves
Author by

IgorAlves

https://www.linkedin.com/in/igoralves1/

Updated on September 18, 2022

Comments

  • IgorAlves
    IgorAlves over 1 year

    I am running a Ubuntu 16.04 as a guest for a Windows 7 host.

    I shared a folder inside Windows and I should be able to see and open the file inside the Linux.

    The issue was me, as root, could not open the file because the root is not in the vboxsf group.

    From this post, I just ran this command:

    $ usermod -G vboxsf rootusername
    

    After that I have lost the root privileges. I cannot use sudo su command, not open root files etc.

    So how can I add the rootUser to vboxsf without losing all admin privileges?

  • IgorAlves
    IgorAlves over 7 years
    Yes, that solved the problem (-aG). It is only in a test environment to grab some files from windows.