How to change owner and group of files. - Debian

This is a discussion on How to change owner and group of files. - Debian ; I have a directory ~/.kde/share/apps/kmail/mail/cur with hunderds of files (e-mails) of which I want to switch owner and group from root root to henkoegema henkoegema How can I do that in one command ? Rgds Henk...

+ Reply to Thread
Results 1 to 15 of 15

Thread: How to change owner and group of files.

  1. How to change owner and group of files.

    I have a directory ~/.kde/share/apps/kmail/mail/cur with hunderds of files
    (e-mails) of which I want to switch owner and group from root root to
    henkoegema henkoegema

    How can I do that in one command ?

    Rgds
    Henk

  2. Re: How to change owner and group of files.


    "Henk Oegema" wrote in message
    news:RPa1j.219260$gM5.12435682@phobos.telenet-ops.be...
    >I have a directory ~/.kde/share/apps/kmail/mail/cur with hunderds of files
    > (e-mails) of which I want to switch owner and group from root root to
    > henkoegema henkoegema
    >
    > How can I do that in one command ?


    chown henkoegema ~/.kde/share/apps/kmail/mail/cur/* ; chgrp henkoegema
    ~/.kde/share/apps/kmail/mail/cur/*


    Add a -R after the command to recurse into sub directories.



  3. Re: How to change owner and group of files.

    Noozer wrote:

    >
    > "Henk Oegema" wrote in message
    > news:RPa1j.219260$gM5.12435682@phobos.telenet-ops.be...
    >>I have a directory ~/.kde/share/apps/kmail/mail/cur with hunderds of files
    >> (e-mails) of which I want to switch owner and group from root root to
    >> henkoegema henkoegema
    >>
    >> How can I do that in one command ?

    >
    > chown henkoegema ~/.kde/share/apps/kmail/mail/cur/* ; chgrp henkoegema
    > ~/.kde/share/apps/kmail/mail/cur/*
    >
    >
    > Add a -R after the command to recurse into sub directories.


    Thanks. Specific the -R option was, what I needed.


  4. Re: How to change owner and group of files.

    On Nov 22, 3:10 am, Henk Oegema wrote:
    > I have a directory ~/.kde/share/apps/kmail/mail/cur with hunderds of files
    > (e-mails) of which I want to switch owner and group from root root to
    > henkoegema henkoegema
    >
    > How can I do that in one command ?



    chown -R henkoegema:henkoegema ~/.kde/share/apps/kmail/mail/cur/*

  5. Re: How to change owner and group of files.

    Lew Pitcher wrote:

    > On Nov 22, 3:10 am, Henk Oegema wrote:
    >> I have a directory ~/.kde/share/apps/kmail/mail/cur with hunderds of
    >> files (e-mails) of which I want to switch owner and group from root root
    >> to henkoegema henkoegema
    >>
    >> How can I do that in one command ?

    >
    >
    > chown -R henkoegema:henkoegema ~/.kde/share/apps/kmail/mail/cur/*


    Is the henkoegema:henkoegema for owner and group at the same time?


  6. Re: How to change owner and group of files.

    >
    > chown -R henkoegema:henkoegema ~/.kde/share/apps/kmail/mail/cur/*



    Note that this will not work on filenames that begin with a dot.

    A better way...

    find ~/.kde/share/apps/kmail/mail/cur | xargs chown
    henkoegema:henkoegema

  7. Re: How to change owner and group of files.

    On Nov 22, 9:16 am, Henk Oegema wrote:
    > Lew Pitcher wrote:
    > > On Nov 22, 3:10 am, Henk Oegema wrote:
    > >> I have a directory ~/.kde/share/apps/kmail/mail/cur with hunderds of
    > >> files (e-mails) of which I want to switch owner and group from root root
    > >> to henkoegema henkoegema

    >
    > >> How can I do that in one command ?

    >
    > > chown -R henkoegema:henkoegema ~/.kde/share/apps/kmail/mail/cur/*

    >
    > Is the henkoegema:henkoegema for owner and group at the same time?


    Yes...

    CHOWN(1) User Commands
    CHOWN(1)

    NAME
    chown - change file owner and group

    SYNOPSIS
    chown [OPTION]... [OWNER][:[GROUP]] FILE...

  8. Re: How to change owner and group of files.

    On 22 Nov at 16:01 Lew Pitcher wrote in message


    > On Nov 22, 9:16 am, Henk Oegema wrote:
    > > Lew Pitcher wrote:
    > > > On Nov 22, 3:10 am, Henk Oegema wrote:
    > > > > I have a directory ~/.kde/share/apps/kmail/mail/cur with hunderds of
    > > > > files (e-mails) of which I want to switch owner and group from root
    > > > > root to henkoegema henkoegema

    > >
    > > > > How can I do that in one command ?

    > >
    > > > chown -R henkoegema:henkoegema ~/.kde/share/apps/kmail/mail/cur/*

    > >
    > > Is the henkoegema:henkoegema for owner and group at the same time?

    >
    > Yes...
    >
    > CHOWN(1) User Commands CHOWN(1)
    >
    > NAME
    > chown - change file owner and group
    >
    > SYNOPSIS
    > chown [OPTION]... [OWNER][:[GROUP]] FILE...
    >


    Actually, being really pedantic, you only need
    chown -R henkoegema: ~/.kde/share/apps/kmail/mail/cur/*
    --
    Tony van der Hoff | mailto:news_0711@vanderhoff.org
    Buckinghamshire, England

  9. Re: How to change owner and group of files.

    On Thu, 22 Nov 2007 09:20:58 +0000, Henk Oegema wrote:

    >> Add a -R after the command to recurse into sub directories.


    > Thanks. Specific the -R option was, what I needed.


    I guess you've never heard of a "man page", eh?


    --
    "Ubuntu" -- an African word, meaning "Slackware is too hard for me".


  10. Re: How to change owner and group of files.

    On Thu, 22 Nov 2007 16:43:33 +0000,
    Tony van der Hoff wrote:

    > On 22 Nov at 16:01 Lew Pitcher wrote
    > > On Nov 22, 9:16 am, Henk Oegema wrote:
    > > > Lew Pitcher wrote:
    > > > > On Nov 22, 3:10 am, Henk Oegema wrote:
    > > > > > I have a directory ~/.kde/share/apps/kmail/mail/cur with
    > > > > > hunderds of files (e-mails) of which I want to switch owner
    > > > > > and group from root root to henkoegema henkoegema
    > > > > > How can I do that in one command ?
    > > > > chown -R henkoegema:henkoegema
    > > > > ~/.kde/share/apps/kmail/mail/cur/*
    > > > Is the henkoegema:henkoegema for owner and group at the same time?

    > > Yes...
    > > chown - change file owner and group
    > > chown [OPTION]... [OWNER][:[GROUP]] FILE...

    > Actually, being really pedantic, you only need
    > chown -R henkoegema: ~/.kde/share/apps/kmail/mail/cur/*


    You're assuming, of course, that the default group is also
    henkoegema... Here, for example, my default group is "users", but I'm
    also in a group with my username. I changed the default myself because
    it's actually useful, as long as you're aware of what groups do.


    Also being pedantic.


    Fredderic

  11. Re: How to change owner and group of files.

    Fredderic wrote:

    > On Thu, 22 Nov 2007 07:00:00 -0800 (PST),
    > AHinMaine wrote:
    >
    >> > chown -R henkoegema:henkoegema ~/.kde/share/apps/kmail/mail/cur/*

    >> Note that this will not work on filenames that begin with a dot.
    >> A better way...
    >> find ~/.kde/share/apps/kmail/mail/cur | xargs chown
    >> henkoegema:henkoegema

    >
    > I believe it will if you apply it recursively to the directory itself.
    >
    > chown -R henkoegema:henkoegema ~/.kde/share/apps/kmail/mail/cur
    >
    > One just needs to be aware of whether they want the directory itself to
    > be changed also.
    >
    > I haven't seen any mention in this thread of whether the directory
    > itself needed to be changed also.

    YES.
    The problem came up when I wanted to export my KMAIL mails from one computer
    to another.
    I copied the directory ~/.kde/share/apps/kmail/mail via smb:// to another
    pc into dir ~/.kde/share/apps/kmail/mail
    But then I couldn't open the mails, because most of the files had changed
    owner and group to root.
    When I changed owner and group back again to the original, eveything was
    fine again.

    So that also bring up the question:
    Hasn't KMAIL an export and import function ?
    >
    > Fredderic



  12. Re: How to change owner and group of files.

    On Thu, 22 Nov 2007 07:00:00 -0800 (PST),
    AHinMaine wrote:

    > > chown -R henkoegema:henkoegema ~/.kde/share/apps/kmail/mail/cur/*

    > Note that this will not work on filenames that begin with a dot.
    > A better way...
    > find ~/.kde/share/apps/kmail/mail/cur | xargs chown
    > henkoegema:henkoegema


    I believe it will if you apply it recursively to the directory itself.

    chown -R henkoegema:henkoegema ~/.kde/share/apps/kmail/mail/cur

    One just needs to be aware of whether they want the directory itself to
    be changed also.

    I haven't seen any mention in this thread of whether the directory
    itself needed to be changed also.


    Fredderic

  13. Re: How to change owner and group of files.

    On Nov 23, 3:05 am, Henk Oegema wrote:
    > Fredderic wrote:

    [snip]
    > > I haven't seen any mention in this thread of whether the directory
    > > itself needed to be changed also.

    >
    > YES.
    > The problem came up when I wanted to export my KMAIL mails from one computer
    > to another.
    > I copied the directory ~/.kde/share/apps/kmail/mail via smb:// to another
    > pc into dir ~/.kde/share/apps/kmail/mail
    > But then I couldn't open the mails, because most of the files had changed
    > owner and group to root.


    That is a symptom/result of your fstab setup and SMB behaviour. Like
    the Microsoft filesystems that it is supposed to substitute for, SMB
    doesn't support the Unix style metadata (owner, group, permission
    bits) that Linux filesystems require. So, the kernel (and the smb
    helper programs) substitute fixed values for this missing metadata,
    for use on the linux system (not transferred back to the SMB source
    system).

    > When I changed owner and group back again to the original, eveything was
    > fine again.
    >
    > So that also bring up the question:
    > Hasn't KMAIL an export and import function ?


    Yes, under the "File" menu, there are both export and import functions



  14. Re: How to change owner and group of files.

    On Nov 23, 3:08 am, Fredderic wrote:
    > I believe it will if you apply it recursively to the directory itself.
    >
    > chown -R henkoegema:henkoegema ~/.kde/share/apps/kmail/mail/cur
    >
    > One just needs to be aware of whether they want the directory itself to
    > be changed also.


    Correct, but find/xargs is still the better choice simply because
    chown can't handle very large lists of files. Using xargs only passes
    a list sized around 128KB so chown will never get overloaded.

    --
    Andy

  15. Re: How to change owner and group of files.

    On Mon, 26 Nov 2007 11:36:19 -0800 (PST),
    AHinMaine wrote:

    > On Nov 23, 3:08 am, Fredderic wrote:
    > > I believe it will if you apply it recursively to the directory
    > > itself.
    > >
    > > chown -R henkoegema:henkoegema ~/.kde/share/apps/kmail/mail/cur
    > >
    > > One just needs to be aware of whether they want the directory
    > > itself to be changed also.

    >
    > Correct, but find/xargs is still the better choice simply because
    > chown can't handle very large lists of files. Using xargs only passes
    > a list sized around 128KB so chown will never get overloaded.


    The command given there tells chown to do its own searching, starting
    at a single directory. Unless it's using the kernels globbing
    function, or something similar, there'll not be a list of files
    involved at all.

    So tell me again, how chown can fail to handle a list containing only
    ONE file, and yet readily handle a list sized around 128KB?


    I do agree, though, that if you do need to use find, being familiar with
    xargs is really a good idea. This can be handy when you need to be a
    little more selective in your chown'ing, and find is excellent at
    selecting the files to work on. But in this instance, recursively
    targeting the parent directory will do the job, and should quite happily
    handle every single file in your system all by itself. Even if you put
    them all in the one directory.


    Fredderic

+ Reply to Thread