cp -r and cp -R are not the same command on macOS, even though they are on Linux. That single divergence, confirmed below on both a BSD and a GNU cp, is the main thing worth knowing that a generic cheat sheet won’t tell you.
Table of Contents
-r vs -R: identical on Linux, different on macOS
Both copy directories recursively. The difference is what happens to symlinks found inside the tree. A directory containing one symlink, copied four ways:
$ ln -s ../target.txt srcdir/link.txt
$ cp -R srcdir out1/ && stat -f "%HT" out1/srcdir/link.txt
Symbolic Link # BSD cp -R: symlink preserved (default is -P)
$ cp -r srcdir out2/ && stat -f "%HT" out2/srcdir/link.txt
Regular File # BSD cp -r: symlink followed and copied as a file
$ gcp -R srcdir out3/ && stat -f "%HT" out3/srcdir/link.txt
Symbolic Link # GNU cp -R: symlink preserved
$ gcp -r srcdir out4/ && stat -f "%HT" out4/srcdir/link.txt
Symbolic Link # GNU cp -r: same as -R
macOS’s own cp(1) documents why: “In FreeBSD, -r is a synonym for -RL and works the same unless modified by other flags.” GNU’s manual lists -R, -r and --recursive as one option with three names, with no such split. A script written and tested on Linux that copies a tree of symlinks with -r will silently dereference every one of them the day it runs on a Mac. Use -R explicitly, and add -P (keep as symlinks) or -L (follow them) if you need to be sure which you’re getting, independent of platform.
Trailing slash on the source: another BSD-only trap
$ cp -R srcdir dest_a/ && ls dest_a/
srcdir # directory copied as itself
$ cp -R srcdir/ dest_b/ && ls dest_b/
link.txt # BSD: trailing slash copies CONTENTS, not the directory
$ gcp -R srcdir/ dest_c/ && ls dest_c/
srcdir # GNU: trailing slash changes nothing
macOS’s man page states this directly: “If the source_file ends in a /, the contents of the directory are copied rather than the directory itself.” GNU cp has no such rule: only rsync treats a trailing slash that way on Linux, not cp. If you’re moving between platforms, drop the trailing slash and be explicit about what you want copied.
Preserving metadata: what -p actually adds
macOS’s plain cp already copies extended attributes and ACLs by default; that’s not what -p is for. What it changes is timestamps, and what mode bits survive the umask:
$ chmod 777 meta.txt && umask
0022
$ cp meta.txt plain.txt && stat -f "%Sp" plain.txt
-rwxr-xr-x # umask applied: 777 became 755
$ cp -p meta.txt preserved.txt && stat -f "%Sp" preserved.txt
-rwxrwxrwx # exact mode kept, umask ignored
$ stat -f "%Sm" meta.txt plain.txt preserved.txt
Jan 1 12:00:00 2020 # source
Aug 12 00:08:21 2026 # plain copy: mtime reset to copy time
Jan 1 12:00:00 2020 # -p: original mtime kept
Without -p you lose modification time, access time, and any mode bits your umask would strip. Ownership (user/group) is also part of -p but wasn’t tested here: it silently no-ops without root, per the man page, rather than erroring.
mv across filesystems: copy-then-delete, not atomic
Same-disk mv is a rename: instant regardless of file size. Cross-filesystem mv is a real copy followed by deleting the source, and it can fail partway. A RAM-backed disk image served as the second filesystem:
$ stat -f "%d" . /Volumes/RAMDisk
16777230
16777239 # different device IDs = different filesystems
$ time mv same_disk_file.bin renamed.bin
real 0m0.002s # instant: same filesystem, pointer update only
$ mv 800MB_file.bin /Volumes/RAMDisk/file.bin &
$ kill -9 $! # interrupted mid-copy, on purpose
$ ls -la 800MB_file.bin
-rw-r--r-- 1 [user] staff 838860800 # source: untouched, full size
$ ls -la /Volumes/RAMDisk/file.bin
---------- 1 [user] staff 40239104 # destination: partial, 40MB of 800MB, wrong mode
Killed mid-transfer, the source survived intact and the destination was left as a broken, partial file with no permissions set, which shows that a cross-filesystem mv is not one atomic operation. A separate, non-interrupted test that ran the RAM disk out of space failed the same way but cleaned up its own partial file and left the source alone (exit status 1, nothing lost), so the specific failure mode changes what’s left behind, and “the source is always safe” isn’t guaranteed by anything other than what happened to fail. For same-disk moves this can’t happen: it’s a single filesystem operation, all-or-nothing.
-L vs -P for symlinks, without -r/-R ambiguity
A plain cp (no recursion) on a symlink dereferences it by default: it copies the target’s content, not the link:
$ ln -s realfile.txt linktofile.txt
$ cp linktofile.txt copy.txt && stat -f "%HT" copy.txt
Regular File
Inside a recursive copy, explicit -P (never follow) or -L (always follow) removes the platform-dependent guesswork that -r vs -R otherwise creates. The recursive-copy symlink result, the trailing-slash rule, the -p mode result and the plain cp dereference above are the checks in how-to-copy-and-move-files.sh, which relies on BSD stat -f and is therefore meant for macOS.
A plain mv silently replaces an existing file with no prompt, and this Mac’s default filesystem is case-insensitive; both are covered in Rename a File in Terminal.