Solved

Problems copying a file with cp -p filename in Linux

Posted on 2007-03-30
7
378 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
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

This article will explain how to establish a SSH connection to Ubuntu through the firewall and using a different port other then 22. I have set up a Ubuntu virtual machine in Virtualbox and I am running a Windows 7 workstation. From the Ubuntu vi…
1. Introduction As many people are interested in Linux but not as many are interested or knowledgeable (enough) to install Linux on their system, here is a safe way to try out Linux on your existing (Windows) system. The idea is that you insta…
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…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

910 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now