Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
How to copy files / folders off a Mac from the command line (optionally using Single User Mode)

Mac File Transfer via Single User Mode / Command Line

  • Start in Single User Mode by holding down Command-S when starting the Mac.
  • Commands can also be typed via Terminal app when OS X is running.

See also: https://support.apple.com/en-us/HT201573
More tips: http://www.tekrevue.com/tip/mac-startup-options/

Terminal Command Workflow

  1. Type diskutil list to view available drives
  2. Type diskutil mount /dev/disk1s2 (Disk 1, Partition Scheme 2 - may be different on your Mac) to gain read/write access on that disk.
  3. Type cd /Volumes to switch current folder to Volumes where Mac OS lists all mounted drives.
  4. Type ls to list contents of Volumes folder.
  5. Type mkdir to create a new folder (on the USB drive)
  6. The cp -a command copies files/folders from one path to another.

Walkthrough

Start in Single-User Mode by holding Command-S as mentioned above You type -> diskutil list

/dev/disk0 (Physical Disk #1: Macintosh HD)

TYPE  NAME  SIZE  IDENTIFIER
0: GUID_partition_scheme *121.3 GB disk0
1: EFI 209.7 MB disk0s1
2: Apple_HFS Macintosh HD 120.5 GB disk0s2
3: Apple_Boot Recovery HD 650.0 MB disk0s3

/dev/disk1 (Physical Disk #2: PIZZA_PIZZA_256GB)

#: TYPE  NAME  SIZE  IDENTIFIER
0: GUID_partition_scheme *256.0 GB disk1
1: EFI 209.7 MB disk1s1
2: Apple_HFS PIZZA_PIZZA_256GB 255.7 GB disk1s

You type -> diskutil mount /dev/disk1s2

Volume PIZZA_PIZZA_256GB on disk1 mounted

You type -> cd /Volumes

/Volumes 13:05:47

You type -> ls

Macintosh HD            PIZZA_PIZZA_256GB                 Recovery Disk Assistant

You type -> cd /Volumes/PIZZA_PIZZA_256GB
You type -> mkdir RecoveredFiles
You type -> cd RecoveredFiles
You type -> cp -a ~/Photos Photos

/Volumes/PIZZA_PIZZA_256GB/RecoveredFiles 13:07:20

Which should copy the entire Mac Photos folder to /Volumes/PIZZA_PIZZA_256GB/RecoveredFiles/Photos

  1. An empty line after running the cp command indicates success
  2. Copy folder and contained files together using cp -a /Source/FolderName /Destination/FolderName
  3. Copy single files without the -a using cp /Source/file.jpg /Destination/file.jpg
  4. ~/Photos is the same as /Users/alex/Photos

More copying examples

You type -> cp ~/Photos/myphoto.jpg Photos/myphoto.jpg
You type -> cp -a ~/Documents /Volumes/PIZZA_PIZZA_256GB/RecoveredFiles/Documents
You type -> cp -a ~/Desktop /Volumes/PIZZA_PIZZA_256GB/RecoveredFiles/Desktop

Exit Single User Mode

You type -> reboot

Mac will reboot normally

@Flipp3rrr

This comment has been minimized.

Copy link

@Flipp3rrr Flipp3rrr commented Nov 9, 2018

This is great to know! Thanks!
I need to backup a Mac that failed to update from the terminal in Recovery mode (cmd+R) and now I know how to do it!

@dayfuaim

This comment has been minimized.

Copy link

@dayfuaim dayfuaim commented Oct 3, 2019

Thank you so much!
It would save me my Mini.

@AngDrew

This comment has been minimized.

Copy link

@AngDrew AngDrew commented Apr 13, 2021

thank you! works fine even in 2021

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment