Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I backed up some linux configuration files to a windows machine, so the file system rights were lost. Now I would like to restore my backed up configuration by overwriting the configuration currently present on the linux machine. Is there a command like "overwrite configuration.conf with backup/configuration.conf and apply the file rights of the overwritten configuration.conf to the new configuration.conf" ? Thanks for any hint :-)

share|improve this question
up vote 2 down vote accepted

You can use chmod to first copy permissions to the backup.

 chmod --reference <reference> <target>
  1. Copy backup file to linux system using a different name like file.bak

    cp /mnt/windows/FILE /etc/directory/FILE.bak

  2. apply the permissions from the original file

    chmod --reference /etc/directory/FILE /etc/directory/FILE.bak

  3. mv backup to target

    mv /etc/directory/FILE.bak /etc/directory/FILE

Put all this in a for-loop. chowncan be used similarly to copy the owner and group from a reference file.

share|improve this answer
Thank you very much for your hints! Selected as answer :-) Except someone tells em, hey there's a aprameter to cp/mv to do this all in just on step :P – stefan.at.wpf Jun 23 '12 at 11:10

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.