How best to change the 'ownership' of a whole drive or directory via 1 or a few commands?

Xen list at xenhideout.nl
Sat May 21 09:01:56 UTC 2016


Bas Roufs schreef op 21-05-2016 10:05:
> Hello Everybody.
> 
> Recently, I apparently made a mistake I can reconstruct only roughly.
> I tried to recover a few accidently deleted folders at 2 external HD's
> via 'photorec'. The recovery attempt was not reallly successful,
> however I it is no problem to get back the lost data in other ways.
> 
> But another problem popped up. The 'ownership' of my external HD's
> have changed from #normal-user-name to #root.
> 
> Normally, I do manage to change the ownership of a whole external
> drive via kdesudo dolphin > properties. However,  this does not work
> now. Is there any commandline option to change back the ownership
> everything at /dev/sdb/ from #root to, in my case, #bas?
> 
> A single folder OR file I can 'chown' via sudo mc. However, this does
> not work for  underlying folders and files.

Mine!

Normally it can depend on the way it is mounted, but not always.

FAT32 volumes do not have any ownership, so the ownership they get is 
that which is supplied at mount time. Normally if your user is in 
Kubuntu (KDE) it would get the ID of your user.

In other volumes you may not need to do more than a recursive chown:

chown -R /root/of/tree

so:

chown -R youruser.yourgroup /root/of/tree

would do the trick (as root, because a regular user cannot change 
ownership of anything)

It does not depend on /dev/sdb btw, you need to access the mount point.

For vfat (and similar, such as remote "samba" mounts), you may need to 
supply a uid on the mount command line (or in fstab).




More information about the kubuntu-users mailing list