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/': Operation not permitted
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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.
howartAuthor Commented:
when the user is owner of the file on the remote system it works.
howartAuthor Commented:
it is a NFS share and it doesn't work!
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

Duncan RoeSoftware DeveloperCommented:
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.
Duncan RoeSoftware DeveloperCommented:
--remove-destination will remove the targety file before copying. This option and --preserve require a recent cp (since file-utils 4.1)

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
howartAuthor Commented:
yep works.
Any ideas how i can achieve the same with Midnight Commander?

Duncan RoeSoftware DeveloperCommented:
Sorry, no.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Linux Distributions

From novice to tech pro — start learning today.