Solved

Problems copying a file with cp -p filename in Linux

Posted on 2007-03-30
7
379 Views
Last Modified: 2013-12-06
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
Comment
Question by:howart
  • 3
  • 3
7 Comments
 
LVL 14

Expert Comment

by:ygoutham
ID: 18822550
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
 
LVL 1

Author Comment

by:howart
ID: 18822642
when the user is owner of the file on the remote system it works.
0
 
LVL 1

Author Comment

by:howart
ID: 18822647
it is a NFS share and it doesn't work!
0
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 
LVL 34

Expert Comment

by:Duncan Roe
ID: 18827020
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
 
LVL 34

Accepted Solution

by:
Duncan Roe earned 500 total points
ID: 18827037
--remove-destination will remove the targety file before copying. This option and --preserve require a recent cp (since file-utils 4.1)
0
 
LVL 1

Author Comment

by:howart
ID: 18834848
yep works.
Any ideas how i can achieve the same with Midnight Commander?

0
 
LVL 34

Expert Comment

by:Duncan Roe
ID: 18835113
Sorry, no.
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction We as admins face situation where we need to redirect websites to another. This may be required as a part of an upgrade keeping the old URL but website should be served from new URL. This document would brief you on different ways ca…
In my business, I use the LTS (Long Term Support) versions of Linux. My workstations do real work, and so I rarely have the patience to deal with silly problems caused by an upgraded kernel that had experimental software on it to begin with from a r…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question