Linux Debian support - How to change owner and group of files.

This is Interesting: Free IT Magazines  
Home > Archive > Linux Debian support > November 2007 > How to change owner and group of files.





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author How to change owner and group of files.
Henk Oegema

2007-11-22, 7:14 am

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
Noozer

2007-11-22, 7:14 am


"Henk Oegema" <henk@oegema.com> 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.


Henk Oegema

2007-11-22, 7:14 am

Noozer wrote:

>
> "Henk Oegema" <henk@oegema.com> wrote in message
> news:RPa1j.219260$gM5.12435682@phobos.telenet-ops.be...
>
> 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.

Lew Pitcher

2007-11-22, 1:12 pm

On Nov 22, 3:10 am, Henk Oegema <h...@oegema.com> 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/*
Henk Oegema

2007-11-22, 1:12 pm

Lew Pitcher wrote:

> On Nov 22, 3:10 am, Henk Oegema <h...@oegema.com> wrote:
>
>
> chown -R henkoegema:henkoegema ~/.kde/share/apps/kmail/mail/cur/*


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

AHinMaine

2007-11-22, 1:12 pm

>
> 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
Lew Pitcher

2007-11-22, 1:12 pm

On Nov 22, 9:16 am, Henk Oegema <h...@oegema.com> wrote:
> Lew Pitcher wrote:
>
>
>
> 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...
Tony van der Hoff

2007-11-22, 1:12 pm

On 22 Nov at 16:01 Lew Pitcher <lpitcher@teksavvy.com> wrote in message
<e825bd41-eb97-428c-9bbd-257ee3fdfd2b@e1g2000hsh.googlegroups.com>

> On Nov 22, 9:16 am, Henk Oegema <h...@oegema.com> wrote:
>
> 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
Dan C

2007-11-22, 1:12 pm

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

[vbcol=seagreen]
> 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".

Fredderic

2007-11-23, 1:15 am

On Thu, 22 Nov 2007 16:43:33 +0000,
Tony van der Hoff <news@nospam.vanderhoff.org> wrote:

> On 22 Nov at 16:01 Lew Pitcher <lpitcher@teksavvy.com> wrote
> 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
Fredderic

2007-11-23, 1:15 am

On Thu, 22 Nov 2007 07:00:00 -0800 (PST),
AHinMaine <aharrison@gmail.com> wrote:

> 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
Henk Oegema

2007-11-23, 7:14 am

Fredderic wrote:

> On Thu, 22 Nov 2007 07:00:00 -0800 (PST),
> AHinMaine <aharrison@gmail.com> 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.
>
> 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


Lew Pitcher

2007-11-26, 1:12 pm

On Nov 23, 3:05 am, Henk Oegema <h...@oegema.com> wrote:
> Fredderic wrote:

[snip]
>
> 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


AHinMaine

2007-11-26, 7:12 pm

On Nov 23, 3:08 am, Fredderic <my-name-h...@excite.com> 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
Fredderic

2007-11-28, 1:12 pm

On Mon, 26 Nov 2007 11:36:19 -0800 (PST),
AHinMaine <aharrison@gmail.com> wrote:

> On Nov 23, 3:08 am, Fredderic <my-name-h...@excite.com> wrote:
>
> 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
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com