0

Here is my access location:

drwxrwsr-x 10 dara nm 4096 Jul 24 11:33 16.20
drwxrwsr-x  8 dara nm 4096 Jul 24 11:22 16.22

Here i want to change the user name instead of dara to lara without using root access.How can i do it?

Expected output:

drwxrwsr-x 10 lara nm 4096 Jul 24 11:33 16.20
drwxrwsr-x  8 lara nm 4096 Jul 24 11:22 16.22

Sample Example:
lara-vd1-341: ls -l
total 100
drwxrwsr-x  8 dara nm  4096 Jul 24 11:22 16.20
-rwxrwxrwx  1 lara nm   596 Jul 24 15:32 16.22
  • 1
    Why do you want to do it without having root access? – Yaron Jul 24 '17 at 6:35
  • Because am not having the root access permission.I had used the vnc to move the files from one user to another user.(i.e from dara to lara vnc session).Now in lara the folder have the name as dara .So i need to change the all user names from dara to lara.@Yaron – salma Jul 24 '17 at 6:38
  • are you able to execute sudo or su on this machine? do you know the root password? – Yaron Jul 24 '17 at 6:41
  • No. i dont know the root password @Yaron – salma Jul 24 '17 at 6:42
  • You can't change files owned by you, to be owned by someone else without being root, or without root grant you the permission to do so. – Yaron Jul 24 '17 at 6:42
1

Changing file ownership requires to be root in order to do so.

This is part of the security mechanism in Unix, which prevent regular user from accessing other users files.

If you will try to do it without root permission - the command will fail with error message, e.g.:

chown yourusername /etc/passwd
chown: changing ownership of '/etc/passwd': Operation not permitted
1

As dara, move the directory out of the way:

mv dir dir-old

As lara, make a copy of the original directory in the place you want it:

cp -Ra dir-old dir

This requires that you have write permissions in the parent directory in order to move it out of the way; presumably if you managed to do this in the first place then you do.

If you don't, you can get close by doing the same thing with the files and directories inside directory. User dara would still be able to delete the files later in that case. I'm not clear how you could end up in that situation in the first place though.

This is the only way to get an ownership change without involving elevated rights. It will fail to copy some special files correctly, and will break hard links.

If none of these work, better to tar the files up on dara's side, and extract them as lara instead of however you did it the first time.

1

You can't do this without root permission or its equivalent.

Since you don't have root permission, the best course at this point is to talk with the person responsible for administering the system and ask them to deal with it.

  • Even for deleting the folder also we need root permission or we dont need? @roaima – salma Jul 24 '17 at 6:52
  • @salima to delete or rename a file or directory, one must have write permission to its parent directory. – roaima Jul 24 '17 at 8:18
  • I would add that the OP needs to ask his/her system administrator. – Basile Starynkevitch Jul 24 '17 at 8:19
  • @Basile good point; that's much more positive then just saying "can't do that". Thanks – roaima Jul 24 '17 at 8:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.