Copy with cp -a to preserve everything (archive mode)

Archive copy files and directories keeping ownership, permissions, symlinks and timestamps intact on Linux.

LinuxbackupcopypermissionsLow risk
Run cp -a SOURCE DEST to copy recursively while preserving mode, ownership, timestamps, and symbolic links.

01Command

Command
$ cp -a /var/www/site /backup/site

02What it does

Plain cp drops ownership and resets timestamps because it copies content, not metadata. The -a (archive) flag is shorthand for -dR --preserve=all: it recurses, never dereferences symlinks, and keeps every attribute that the running user is allowed to preserve. It is the standard way to back up or migrate a directory tree, and rsync -a mirrors the same semantics.

03Risk

RiskLow risk
!Warning: As a regular user you cannot preserve ownership of files you don't own; run with sudo when copying system data.

04Undo

✓No undo needed — this command does not change persistent state.

05Sources

  • cp(1) — Arch Linux manual
    Arch Linux · technical · 2026-09-17
    Evidence: -a, --archive: same as -dR --preserve=all, preserving links, mode, ownership and timestamps
  • cp(1P) — POSIX manual page
    man7.org · technical · 2026-09-17
    Evidence: POSIX documents the -a equivalent behaviors of preserve/duplicate/recurse used by cp -a

Last verified: 2026-09-17 · Category: Files & Folders

06Related solutions