Changing user groups makes data no longer accessible
Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Changing user groups makes data no longer accessible
One straight problem I faced:
I have re-installed my Linux system, keeping the partition mounted as /home directory unvaried. There I have my user account, obviously.
After re-installing, the new system correctly recognizes my user account and I can access my data as with the old one.
BUT: After I just change my user account groups (basically, I want it added to the "root" group) assignments, I cannot access my data any more... I get the message "You don't have privileges to access this folder". With root access, I have checked such files and I cannot understand: it is still my user account the owner and still it has Access/modify permissions... why does assigning it to MORE groups generate such problems? Thanx
Did you add your user to a the root group, or change groups, ie remove old group and add new group.
When you moved your data, you may have had access using the old group, but not your user, because linux uses user number, not name for permissions, same with groups.
You should check the /etc/group folder for groups your user is a member of (grep $USER /etc/group). Also check your userid number (grep $USER /etc/passwd)... if this is different to your old system, you may have problems.
Next check the owner/group of the files (ls -l) the user and group should be displayed. If the user or group do not match what is in the above files, you will not have access.
To fix your problem, as root run:
chown -R USERNAME GROUPNAME /PATH/TO/DATA
Where USERNAME is your USERNAME and GROUPNAME is a group you are a member of and /PATH/TO/DATA is where your files are (the -R means recursive, and will change permissions on all sub folders - so do not do this for / or you will change permissions on all files, which could cause problems)
I too agree, you should not make your user a member of the root group - it is good to have the protection of not worrying.
I could imagine the original poster may be setting up another user that has root privileges that they use for some administrative tasks, this would be OK.
Anyway - it is kind of sideline to the original problem, and hopefully the poster has a result.
Thank you for your explanation: I just changed group as root user and no further problem has occured with my user account accessing its /home/... directory.
OK, so I think I am supposed not to add it to the root group any more...
This will fix it, but this is because root can essentially do anything!
The problem with adding root group to your user as the solution, is you are root for daily operations. This will allow you to totally screw up your whole system if you make a mistake (e.g. running 'rm -r /' when you mean to type 'rm -r junk/' will delete all files on the whole machine - if your user did not have root permissions, you would get an error straight away - Access Denied).
The correct solution to get your files working is what I mentioned in my first reply, that is:
chown -R $USERNAME:$YOURGROUP /home/$USERNAME
as root.
Where $USERNAME and $YOURGROUP are the username and group you normally use.
after you have done this you can be safe to remove your user from the root group.
I would suggest your user on the new system has a different ID to your old, and this is causing the problem.
You can check this by typing ls -l at the command line, and if the files are owned by another user (the 3rd field), or if this field is a number (the old user ID owner) then this is the problem. Also make sure your user has rw permission (read, write) for files and rwx for directories (the x is execute, but for directories, lets you enter them).
Hope this helps - feel free to post output of the ls -l command if you want (You can change/obscure the filenames if you don't want to publish them).
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.