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

- Name
- Mehdi Akiki
Copy a file:
cp src.txt dest.txt
Copy recursively:
cp -r srcdir/ destdir/
Tip: cp -a preserves attributes and is useful for backups.
title: "Copy a file with cp" date: "2025-09-16" tags: ["bash","til"] draft: false summary: "Use cp to copy files and preserve attributes when needed."
cp source.txt dest.txt
# preserve mode, ownership and timestamps
cp -a source.txt dest_dir/
Tips:
- Use
cp -rfor directories. cp -akeeps metadata; use sudo when copying system files.
title: "Today I Learnt: Copy files with cp" date: "2025-09-16" tags: ["bash", "til"] draft: false summary: "Copy files preserving attributes."
Copy a file preserving attributes:
cp -a source.txt dest.txt
I build and scale reliable production systems. Open to full-time and freelance work with U.S.-based teams that value ownership and execution.
Got something in mind?
Book a Discovery Call