• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 391
  • Last Modified:

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
0
howart
Asked:
howart
  • 3
  • 3
1 Solution
 
ygouthamCommented:
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.
0
 
howartAuthor Commented:
when the user is owner of the file on the remote system it works.
0
 
howartAuthor Commented:
it is a NFS share and it doesn't work!
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
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.
0
 
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)
0
 
howartAuthor Commented:
yep works.
Any ideas how i can achieve the same with Midnight Commander?

0
 
Duncan RoeSoftware DeveloperCommented:
Sorry, no.
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now