Hey there
I have a problem and i was hoping that you guys could help me out
I want to copy a user privileges to a group and i need to copy all privileges(Recursively) every directory with all its sub directories and I tried some solution and it did not work. I used the following command:-
find $1 -exec /bin/sh -c 'chmod g+`ls -ld "{}" | cut -c2-4` "{}"'
I used this one and I'm new to AIX, and I don't know where does the group name supposed to go or the initial directory and I'm in a huge mess.
so could you please tell me what went wrong or give me another solution that would be great
Thanks in Advance
You are missing the final semi-colon:
find $1 -exec /bin/sh -c 'chmod g+`ls -ld "{}" | cut -c2-4` "{}"' \;
thanks but i still having the same error I have logged in with the owner of the folder then directly typed the exact command above and i keep getting the same error:-
Usage:find Path-list [Expression-list]
so if any one have any suggestions that would be great
Thanks for your cooperation
What is the value of $1? If it may be empty, try this:
find ${1:-.} -exec /bin/sh -c 'chmod g+`ls -ld "{}" | cut -c2-4` "{}"' \;
cfajohnson:
What is the value of $1? If it may be empty, try this:
find ${1:-.} -exec /bin/sh -c 'chmod g+`ls -ld "{}" | cut -c2-4` "{}"' \;
I tried it and i got this error
ls: 0653-341 The file {} does not exist.
chmod: {}: A file or directory in the path name does not exist.
it seems that i should specify the initial directory but I'm not sure
What you think?
I also tried the command
find ${1:-.} -exec /bin/sh -c 'chmod g+`ls -ld "/home/username/" | cut -c2-4` "/home/username"' \;
and it worked with no problem but the permissions did not change a bit.
otheus
October 15, 2008, 3:52am
7
I didn't understand what you meant by "copy user privileges to a group" associated with the above code. Are you trying to make sure that a particular user's group owns all the files in a directory tree (not change the user-owner)?
this is exactly what i want and i want it to go recursively(all directories and all files inside those directories)
also I tried the following command :-
find ${1:-.} -exec /bin/sh -c 'chmod g+`ls -ld "/home/username" | cut -c2-4` "/home/username" | tr -d "-"` "/home/username" ' \;
and i got like a million of
: 0403-006 Execute permission denied.
/bin/sh: /home/username: 0403-006 Execute permission denied.
/bin/sh: /home/username: 0403-006 Execute permission denied.
/bin/sh: /home/username: 0403-006 Execute permission denied.
/bin/sh: /home/username: 0403-006 Execute permission denied.
/bin/sh: /home/username: 0403-006 Execute permission denied.
please help me because I'm a beginner at AIX
Thanks in Advance
otheus
October 15, 2008, 4:04am
9
I got the recursive part.
So let's say that inside my home directory, /home/otheus, I have a file owned by root. Do you want that file to be group-owned by my group?
otheus:
I got the recursive part.
So let's say that inside my home directory, /home/otheus, I have a file owned by root. Do you want that file to be group-owned by my group?
It does not matter at all
otheus
October 15, 2008, 4:21am
11
So I take it AIX's chgrp doesn't have a -R option like Solaris and GNU do?
No it does have -R option
I'm not an expert so i need specific solution
otheus
October 15, 2008, 4:28am
13
Would this work?
# you must be root
cd /home
for m in *; do
gid=`getent group $m | cut -d: -f4`
find $m -exec echo chgrp $gid "{}" ";"
done
Remove the "echo" when you think it's going to work.
I used it like this exactly
cd /home
for m in *; do
gid=`getent group $m | cut -d: -f4`
find $m -exec chgrp $gid "/home/username" ";"
done
and i got a infinite list of :-
Usage: chgrp [-fhR] {GroupName | GroupID} File ...
chgrp -R [-H | -L | -P] [-f] {GroupName | GroupID} File ...
Usage: chgrp [-fhR] {GroupName | GroupID} File ...
chgrp -R [-H | -L | -P] [-f] {GroupName | GroupID} File ...
Usage: chgrp [-fhR] {GroupName | GroupID} File ...
chgrp -R [-H | -L | -P] [-f] {GroupName | GroupID} File ...
Usage: chgrp [-fhR] {GroupName | GroupID} File ...
chgrp -R [-H | -L | -P] [-f] {GroupName | GroupID} File ...
Usage: chgrp [-fhR] {GroupName | GroupID} File ...
chgrp -R [-H | -L | -P] [-f] {GroupName | GroupID} File ...
Usage: chgrp [-fhR] {GroupName | GroupID} File ...
chgrp -R [-H | -L | -P] [-f] {GroupName | GroupID} File ...
Usage: chgrp [-fhR] {GroupName | GroupID} File ...
chgrp -R [-H | -L | -P] [-f] {GroupName | GroupID} File ...
otheus
October 15, 2008, 4:57am
15
wait, chgrp has a -R option !!! That's recursive. You wouldn't need find.
The problem might be with getent. Try
getent group root