Link to home
Start Free TrialLog in
Avatar of gudii9
gudii9Flag for United States of America

asked on

change owner in unix

Hi,

I see some folders( say folder_A which contains folder_C and folder_B which contains folder_D which again contains folder_#))  has xyz as owner. I want to change owner to abc to those folders and sub folders. How can i do it. How do same thing on some files say File_A and file_B etc preoperty files.please advise
SOLUTION
Avatar of n2fc
n2fc
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of gudii9

ASKER

chown -R cfg
chown: missing operand after `cfg'
getting above error?

i basically sudo as crm and then went to
/crm/home/XYZ3ABC/opt/company/bea_domains/12/xyz3abc
now cfg is under this

please advise
Avatar of gudii9

ASKER

i tried your command now i see error as
/crm/home/XYZ3ABC/opt/company/bea_domains/12/xyz3abc/cfg/123.cfg': Operation not permitted
You need privilege to change ownership if you are not the original owner.

Either "su -" or "sudo su -" to root and try again.
Avatar of gudii9

ASKER

hmm i logged in as root only not sure.
let me sudo again

what is chmod and how that is different from chown
chmod changes the file type.
Avatar of gudii9

ASKER

chown -R  crm /crm/home/XYZ3ABC/opt/company/bea_domains/12/xyz3abc/cfg
says operation not permited though
Run "whoami".  What does it say?

Is this a valid path:

ls -l /crm/home/XYZ3ABC/opt/company/bea_domains/12/xyz3abc/cfg

Usually home directories are in /home (i.e., /home/crm not the other way around).
Avatar of gudii9

ASKER

it says crm
that path is bit weird to me also
Avatar of gudii9

ASKER

under home there are different users like XYZ3ABC
and under 12 all web logic server instances are there
Avatar of gudii9

ASKER

i have to login as xyz3abc not crm to chown
when i give chown command like
chown -R crm /crm/home/XYZ3ABC/opt/company/bea_domains/12/xyz3abc
it seems worked except few tmp files where it said cannot change owner etc
now when i go to /crm/home/XYZ3ABC/opt/company/bea_domains/12
i see xyz3abc whose owner is crm which is good but under xyz3abc  i still see some folders owned by xyz3abc one owned by crm though
ls -l /crm/home/XYZ3ABC/opt/company/bea_domains/12/xyz3abc/cfg

getenforce
Like I said.  "su -" or "sudo su -" to root.
Avatar of gudii9

ASKER

getenforce??
Avatar of gudii9

ASKER

crm itself is root here which is weird thing
No, the user "root".
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
"sudo su -" works just fine when sudo'ing to root.  your way, my way, it all depends upon preference.
Avatar of gudii9

ASKER

$ sudo -i                                                                                   [sudo] password for xyz3abc:
xyz3abc is not in the sudoers file.  This incident will be reported.


sudo -i asked me for password which i gave and it says above weird message. what it means?
That means your account is not allowed to run sudo.
Avatar of gudii9

ASKER

That means your account is not allowed to run sudo.
who decide which account allowed to run sudo or not? how to add that privilege?
That privilege is determined by /etc/sudoers

Depending on which linux you use, you may just need to add the user to the group sudoers, admin, or wheel.