Solved

Problems copying a file with cp -p filename in Linux

Posted on 2007-03-30
7
380 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
Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

 
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

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

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

Suggested Solutions

SSH (Secure Shell) - Tips and Tricks As you all know SSH(Secure Shell) is a network protocol, which we use to access/transfer files securely between two networked devices. SSH was actually designed as a replacement for insecure protocols that sen…
Fine Tune your automatic Updates for Ubuntu / Debian
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 find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:

840 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