- Published on
Short engineering note
Today I Learnt: Copy files with cp
- Authors

- Name
- Mehdi Akiki
Note · Engineering notes
Copy a file:
cp src.txt dest.txt
Copy a directory recursively:
cp -r srcdir/ destdir/
Use archive mode when permissions, timestamps, symbolic links, and other attributes must be preserved:
cp -a source.txt dest_dir/
Use cp -i to ask before overwriting an existing destination.