Link to home
Start Free TrialLog in
Avatar of howart
howartFlag for Netherlands

asked on

Problems copying a file with cp -p filename in Linux

On the system are 2 users which want to preserve the file modification times of a file when copying this file from a develop system to the production system. Both systems are Linux.
Both users are member of the same group.
umask for the users is 0012
When I use cp -p file /mnt/remotemachine/remotedir/file
It gives an error :
cp: setting permissions for `/mnt/10.31.0.1/xintpro/PROD/xlog/copytest3.test': Operation not permitted
Avatar of ygoutham
ygoutham
Flag of India image

you are trying to copy a file through a samba share which is mounted to your /mnt some directory.

if you use NFS to share the directory and copy and paste files with permissions (assuming the uid and gid are same across machines) then it should work.
Avatar of howart

ASKER

when the user is owner of the file on the remote system it works.
Avatar of howart

ASKER

it is a NFS share and it doesn't work!
Avatar of Duncan Roe
Only the owner of a file is allowed to change permissions. This applies to local filesystems & NFS.
However I am uncertain whether non_owner can change timestamps. Instead of using -p, try --preserve=timestamps to answer that.
Another approach: if the user has write access to the directory, he can delete the file and recreate it. Then all attributes may be preserved, including owner.
ASKER CERTIFIED SOLUTION
Avatar of Duncan Roe
Duncan Roe
Flag of Australia 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
Avatar of howart

ASKER

yep works.
Any ideas how i can achieve the same with Midnight Commander?

Sorry, no.