Re: Change of UID

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 19 November 2013 09:27, Joachim Backes <joachim.backes@xxxxxxxxxxxxxx> wrote:

>> On 19 November 2013 02:05, Rick Stevens <ricks@xxxxxxxxxxxxxx> wrote:
>>> On 11/18/2013 04:12 PM, Timothy Murphy issued this missive:
>>>

>>>>> edited /etc/password to change my old UID from 500 to 1000
>>>>> edited /etc/group to change my old GID from 500 to 1000
>>>>> chown -R tim:tim /home/tim/
>>>>> chown tim:tim /var/spool/mail/tim
>>>>
>>>>
>>>> Just a note to say that I followed this advice,
>>>> and it worked perfectly.
>>>> Thank you.
>>>
>>>
>>> In the future, you could also do:
>>>
>>>     # find / -uid <your-old-UID> -gid <your-old-GID> -exec chown tim:tim
>>> \{\} \;
>>>
>>> Example:
>>>
>>>     # find / -uid 500 -gid 500 -exec chown tim:tim \{\} \;
>
> Alternative:  # find / -uid 500 -gid 500 -| xargs chown tim:tim
>
> Advantage: Only 1 chown command  invocation
>

Following up on my earlier email, I tried both the xargs and find
-exec CMD '{}' '+' (N.B. difference between '+' and ';') strategies on
a directory with 134858 files (both running echo) and found both
actually ran 72 times. So they use similar strategies for combining
arguments (there's a limit to how many arguments can be passed to a
program, even without shell involvement). On the other hand, xargs
chokes on a different input directory:
":xargs: unmatched single quote; by default quotes are special to
xargs unless you use the -0 option"
because xargs reads strings (via the pipe) it can be a bit trickier to
get corner cases handled correctly, which is why I usually avoid it
for working with general file names. find exec never needs to worry
about quoting as it passes the arguments directly (though the program
it's exec-ing needs to be able to handle general file names too).
Find does have an option (action), -print0 which null terminates names
to work with xargs -0 option:
find / -uid 500 -gid 500 -print0 |xargs chown tim:tim
However unless you want the extra options xargs allows (like
interactive mode), I don't think this gains anything over '+'
terminated exec.

All this is contributes to why the chown -R --from is my preference
for this case, there's no separate program invocation at all (and less
issues about race conditions, or concerns about path).


-- 
imalone
http://ibmalone.blogspot.co.uk
-- 
users mailing list
users@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Fedora Code of Conduct: http://fedoraproject.org/code-of-conduct
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines
Have a question? Ask away: http://ask.fedoraproject.org




[Index of Archives]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [EPEL Devel]     [Fedora Magazine]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Desktop]     [Fedora Fonts]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Fedora Sparc]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux