HD permissions stay put (SOLVED)

Ian Malone ibmalone at gmail.com
Mon Jul 4 11:36:33 UTC 2011

On 4 July 2011 08:45, Johan Scheepers <johansche at telkomsa.net> wrote:
> On 03/07/2011 20:25, JD wrote:
>> On 07/03/2011 11:09 AM, Johan Scheepers wrote:
>>> On 03/07/2011 20:01, JD wrote:
>>>> On 07/03/2011 10:55 AM, Petrus de Calguarium wrote:
>>>>> Johan Scheepers wrote:

A bit late replying, but some things others may find useful.

>>>>>> I have a multiple boot internal drive (different linux
>>>>>> flavors)(excluding windows).
>>>>>> Have a external usb drive for backup between these different systems.

>>>> can you check /etc/passwd to see if the number of your uid belongs to
>>>> user johan
>>>> and check /etc/group to see if there is a group named johan and what
>>>> it's gid is?
>>> Machine one..johan 1000:1000
>>> Machine two ..johan 500:500

>> On the machine that displays numbers, you need
>> to become root and modify the uid and gid of user johan.
>> If you cannot become root, then you can have some
>> more work to do:
>> 1. On the machine where you CAN become root, then become root, and
>> execute  /usr/bin/system-config-users
> File not existing
You might not have had it installed, I think it's listed as 'user
management'. But basically just an interface to modify /etc/passwd and

>>    and in the GUI modify the UID and GID of user johan to match the
>> numbers on the other machine.
>> This means that after you finish the modification,
>> you have to be sure that the /etc/passwd and /etc/group have
>> the right numbers for UID and GID and they match the other machine.
>> 2. as root, execute the command:
>>       chmod -R johan:johan ~johan
>>       On some versions of linux, the command takes the form
>>       chmod -R johan.johan ~johan
>>       On some other linux'es both variations work.

> Then in /home/johan did....
> chown johan ~johan
> chgrp johan ~johan
> Logged out / in and was OK.

> Rebooted 5 times both ways and permissions stayed put.
I'd hope so...

> Now reading all the responses it seems there is more than one way to do this.
Actually there's only one way (line up the UIDs) and a few different
tools to achieve it. What I'm replying about is actually this:
> Then in /home/johan did....
> chown johan ~johan
> chgrp johan ~johan

What this is doing is relabelling your home dir. ~johan expands in
Bash to johan's home directory, so effectively these lines read:
chown johan /home/johan
chgrp johan /home/johan
Because of this it doesn't really matter which directory you're in
when you run it.
Strictly speaking it doesn't do what we want, which is to re-map the
UID and GID from old to new ones. And it doesn't recursively label
(unless chown/chmod are aliased to -R in your setup?). You could do
chown johan /home/johan -R
chgrp johan /home/johan -R
But this is still labelling based on location, fairly sensible for
your home directory, but you might have non-johan group files in there
for whatever reason and also might have other shared data areas with
files of different owners and groups. For this reason chown has the
--from option:

This allows you to recursively re-label paths (the entire file tree if
you want) according to current group/owner:
Change owner:
chown johan --from 1000 -R /

Change group (using chown, N.B. ':'):
chown :johan --from :1001 -R /
I've used 1001 to illustrate the user's old GID (1001) might not have
been the same as the old UID (1000), but it usually will be.

Both of these recursively do the root filesystem. N.B. symbolic links
not followed without giving -L. (Is it possible to have symbolic links
outside / in Linux? Don't think so.)


More information about the ubuntu-users mailing list