Ask Ubuntu is a question and answer site for Ubuntu users and developers. 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'm copying files and folders over from one filesystem to another (both are ext3) via cp in the terminal. The 'date modified' on all of the files are being changed to the current time although I am not modifying the folder or the files. I'd like for them to keep their existing 'last modified date' which vary within the past 5 years.

I am not interested in changing them to a specific date as described this previous question, but to maintain the existing 'last modified' date.

I'm using 12.04.

share|improve this question
up vote 2 down vote accepted
cp --preserve=timestamps <source> <destination>

If you are recursively copying you could use:

cp -a <source> <destination>

From the cp manual page:

-a, --archive
       same as -dR --preserve=all

-d     same as --no-dereference --preserve=links

-R, -r, --recursive
       copy directories recursively

       preserve  the specified attributes (default: mode,ownership,timestamps),
       if possible additional attributes: context, links, xattr, all
share|improve this answer
Thanks, I read over the cp man page again and found it as well ! Will mark this as answer once I'm eligible to. For anyone else interested, the p parameter, a shortcut of --preserve also does this, as well as the mode and ownership. – Will. Jun 24 '13 at 16:35
'cp -p' works and is simplest. From man page: -p is same as --preserve=mode,ownership,timestamps. Also rsync -a for archive mode. – gaoithe May 24 at 11:34

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.