Search this blog

mardi 5 juillet 2011

Linux: copy file without ownership

If you are user A and want to copy a file owned by user B. Using the cp command will create a new file that you may not be able to modify because ownership remain to user B. Normally, you need to be the root user to change ownership using the command chown. An easier way is to use the cp command with the  --no-preserve=ownership option that will create a destination file owned by your user. Example:
cp --no-preserve=ownership path_to_file_from_other_user path_to_destination_file

Aucun commentaire:

Enregistrer un commentaire