Chmod and chown


#1

Hi guys.
My linux shell is a little bit rusty.
So here is the problem:
two users using FTP/SSH on the same group. I’m trying to change the the owner from one user to the other, using chown -R user2 *
but every time I try, I get an error. any ideas? isnt this permitted on DH?


BUGabundo :o)
(``-_-´´)
http://BrinKadeiraS.BUGabundo.net
at http://www.dreamhost.com/r.cgi?249195
50$ discount with promo code “BUG50” on ALL plans


#2

You are doing it correctly, but it won’t work on Dreamhost. an excerpt from the Dreamhost Wiki article on Unix File Permissions says:

[quote]Every file in Unix is assigned a user. This user is the owner of the file. This user has permission to change the group and mode of the file. No one else (but the administrators) is able to make these changes. Only the administrators can change the owner of a file (there is a work around to this too, though).

This doesn’t make much difference on DreamHost, but if you happen to have administrative access elsewhere, this can be useful knowledge. The command to modify the owner is chown.

$ chown bob file.txt

The user named “bob” now owns “file.txt” (that is, if you’re the superuser, otherwise, this will fail).

The “work-around” to change file owner for non-superusers is to copy the file(s) to a new location as the user you want to own the files. The files will be owned by this user in the new location. It’s not much of a work-around, but it’s occasionally useful. [/quote]
So, without being superuser, you can’t run chown on Dreamhost. Maybe the suggested “workaround” will do in a pinch? :wink:

–rlparker


#3

guess i’ll have to copy them with user2 and then delete them form user1.
thanks!!!
I was going mad, 'cause I new that had to be right

EDIT: what can i do to just find and copy files from user2?

BUGabundo :o)
(``-_-´´)
http://BrinKadeiraS.BUGabundo.net
at http://www.dreamhost.com/r.cgi?249195
50$ discount with promo code “BUG50” on ALL plans


#4

The linux “find” command has a “-user” option. General format is:

[quote]find [pathnames] [conditions]

An extremely useful command for finding particular groups of files (numerous examples follow this description). find descends the directory tree beginning at each pathname and locates files that meet the specified conditions. The default pathname is the current directory. The most useful conditions include -name and -type (for general use), -exec and -size (for advanced use), and -mtime and -user (for administrators).

Conditions may be grouped by enclosing them in ( ) (escaped parentheses), negated with !, given as alternatives by separating them with -o, or repeated (adding restrictions to the match; usually only for -name, -type, or -perm). Note that “modification” refers to editing of a file’s contents, whereas “change” means a modification, or permission or ownership changes. In other words, -ctime is more inclusive than -atime or -mtime.

(… many other options listed -----)

-user user

Find files belonging to user (name or ID).

–from http://www.oreillynet.com/linux/cmd/cmd.csp?path=f/find[/quote]
You can also just type “find --help” or “man find” from the shell prompt for more info.

–rlparker


#5

that I knew. but can I pass the results of find to copy?


BUGabundo :o)
(``-_-´´)
http://BrinKadeiraS.BUGabundo.net
at http://www.dreamhost.com/r.cgi?249195
50$ discount with promo code “BUG50” on ALL plans


#6

Couldn’t you use find’s -exec option to cp the files as they are found?

–rlparker