DirectConnect

Guides

How to transfer files between a Mac and Linux

To move files between a Mac and Linux, copy them with rsync over SSH, share a Mac folder and open it in your Linux file manager, or share a Linux folder with Samba. Each needs setup on both computers, and file sharing is slow with folders of small files.

Why this is harder than it should be

  • No shared quick-send. AirDrop is Apple-only, and Linux desktops have nothing the Mac understands.
  • Every method needs accounts and passwords. SSH and Mac File Sharing sign in with the Mac account. Samba needs its own separate password.
  • Linux doesn’t share folders with a Mac by default. You install and configure Samba and open the firewall. On Fedora and similar distributions, SELinux also has to allow the shared folder.
  • Samba needs Mac-specific settings. Without Apple compatibility options, Finder leaves extra hidden ._ files beside yours.
  • The cable link needs addresses. The Mac gives itself a 169.254 address on the cable. Linux often waits for a DHCP server that isn’t there and gets no IPv4 address at all.
  • Small files crawl. In our tests, a Mac took almost four minutes to copy 20,000 small files (331 MB) to a Samba share over a 10 Gb/s Thunderbolt link.
  • Drives don’t cross over. A Mac can’t write to Linux’s ext4 or btrfs drives, and Linux handles Mac APFS drives poorly. Only exFAT works well on both.
  • Cables can run at half speed. In our tests a Linux laptop and a Mac connected on only one 20 Gb/s lane of a 40 Gb/s cable.

Connect the cable and find each computer’s address

If both computers have Thunderbolt or USB4, a cable between them gives a direct network link. The Mac calls it Thunderbolt Bridge, and Linux names it thunderbolt0. Without those ports, use your home network and its addresses instead. See transferring files with Thunderbolt.

On the Mac

  1. Connect the cable.
  2. In System Settings, choose Network, then Thunderbolt Bridge.
  3. Click Details… and note the IP address. With nothing else on the cable, it starts with 169.254.

On the Linux computer

In a terminal, run this command. It only reads the settings:

ip -4 addr show thunderbolt0

An inet 169.254… line is the cable’s address. If there’s no inet line, NetworkManager is still waiting for DHCP. Give the cable a self-assigned address:

  1. In Settings, choose Network, then click the settings button next to the cable’s wired connection.
  2. On the IPv4 tab, choose Link-Local Only and click Apply.
  3. Turn the connection off and on again, then run the ip command again.

Always connect by the 169.254 address, not the computer’s name. A name can find the computer’s Wi-Fi address instead, and the copy then runs over Wi-Fi.

Option 1: rsync over SSH, from a terminal

rsync suits anyone comfortable in a terminal. It copies whole folders, and if a copy stops, running it again skips the files already copied. The Linux computer runs every command, so only the Mac needs setting up.

On the Mac

  1. In System Settings, choose General, then Sharing, and turn on Remote Login.
  2. Click the info button next to Remote Login and check that your account is allowed.
  3. To copy from Desktop, Documents or Downloads, turn on Allow full disk access for remote users in the same panel. Without it, macOS refuses those folders with “Operation not permitted”.

On the Linux computer

  1. In a terminal, run rsync -a --progress user@address:/Users/user/Projects/ ~/Projects/. Replace user with the Mac account’s short name (the name of its home folder) and address with the Mac’s 169.254 address.
  2. The first time, SSH asks whether to trust the Mac. Type yes.
  3. Type the Mac account’s password. rsync lists each file as it copies.

Swap the two paths to copy the other way. The trailing / matters: with it, rsync copies the folder’s contents, and without it, the folder itself. Put quotes around paths that contain spaces. There’s nothing to browse, so you need the exact paths before you start.

Option 2: share a Mac folder and open it in Linux

Mac File Sharing needs no software on Linux. GNOME Files and most other Linux file managers open SMB shares.

On the Mac

  1. In System Settings, choose General, then Sharing, and turn on File Sharing.
  2. Click the info button next to File Sharing. Under Shared Folders, click + and choose the folder.
  3. Under Users, set your account to Read & Write if Linux needs to copy files in.
  4. Click Options…, select your account under Windows File Sharing, type its password and click Done. Without this step, Linux can’t sign in.

On the Linux computer

  1. In Files, press Ctrl+L, type smb:// and the Mac’s address, for example smb://169.254.20.30, and press Enter.
  2. Choose Registered User, type the Mac account’s short name and password, and click Connect.
  3. Open the shared folder. Drag files in or out.

Large files copy well this way. Folders of small files are slow, because file sharing opens, writes and closes each file in turn.

Option 3: share a Linux folder with Samba

Share from Linux when you want to browse the Linux computer’s files in Finder. Each command below changes the system, and needs your password for sudo. Replace you with your Linux user name.

On the Linux computer

  1. Install Samba: sudo dnf install samba on Fedora, or sudo apt install samba on Ubuntu.
  2. Add the share to the end of /etc/samba/smb.conf, as shown below. The fruit line adds the Apple compatibility options.
  3. Set a Samba password for your user with sudo smbpasswd -a you. It’s separate from your login password.
  4. Open the firewall. On Fedora, run sudo firewall-cmd --permanent --add-service=samba, then sudo firewall-cmd --reload. On Ubuntu, the firewall is off unless you turned it on. If it’s on, run sudo ufw allow samba.
  5. On Fedora, let SELinux share the folder: sudo semanage fcontext -a -t samba_share_t "/home/you/Projects(/.*)?", then sudo restorecon -R /home/you/Projects.
  6. Start Samba: sudo systemctl enable --now smb on Fedora, or sudo systemctl restart smbd on Ubuntu.
[Projects]
   path = /home/you/Projects
   valid users = you
   read only = no
   vfs objects = catia fruit streams_xattr

On the Mac

  1. In Finder, choose Go > Connect to Server….
  2. Type smb:// and the Linux computer’s address, for example smb://169.254.40.50, and click Connect.
  3. Choose Registered User, type your Linux user name and Samba password, and click Connect.
  4. Choose the Projects share. It opens in Finder.

In our tests over a 10 Gb/s Thunderbolt link, a Mac copied 20,000 small files (331 MB) from a Samba share in 114 seconds, and to it in 238 seconds. A 4 GiB file copied at about 7.6 Gb/s in both directions.

After sleep, a restart or unplugging

Every option here works only while the cable link is up. When either computer sleeps or you unplug the cable, the connection drops.

  • rsync stops with a connection error. Run the same command again. It skips the files that already arrived.
  • Shared folders disconnect. Finder warns that the server connection was interrupted, and Files closes the share. Connect and sign in again.
  • The address can change. Self-assigned addresses can change after you unplug, so look them up again before reconnecting.
  • After a restart, sharing stays on. Remote Login, File Sharing and an enabled Samba service start again by themselves. You still reconnect from the other computer.

See why a network share disconnects after sleep.

Option 4: an exFAT drive

Format a drive as exFAT and copy files on and off. It needs no setup on either computer and works without Thunderbolt or USB4, but every file is copied twice and the drive needs enough free space.