How to Share Files Between Mac and Linux


Summary

  • Easy and secure file sharing between Mac and Linux using SMB protocol simplifies collaboration and backups.
  • Preparing Mac for file sharing involves verifying network connections, configuring settings, and enabling file sharing.
  • Linux users can share files using Samba in the Terminal, accessing shared folders on Mac from Linux, and vice versa.

Sharing files between a Mac and a Linux machine isn’t complicated. You can do it easily and securely, using practical tools and methods designed for seamless cross-platform sharing.

Using the SMB Protocol for File Sharing

The SMB (Server Message Block) protocol is a widely used standard for sharing files and network resources, including printers using CUPS. It enables seamless communication between different operating systems, making it ideal for mixed OS environments.

To use SMB, you’ll need to enable file sharing on macOS, configure which folders you want to share, and assign permissions to users. On Linux, you’ll install Samba, add a network user, and configure Samba to share folders.

Once set up, SMB ensures a smooth and efficient file transfer experience between your Mac and Linux systems. Unlike cloud services, SMB operates entirely within your local network, ensuring faster transfer speeds, greater data privacy, and eliminating subscription fees. Similarly, it eliminates the need to physically transport files on USB drives.

Prepare Your Mac for File Sharing

Before you can share files between your Mac and Linux machine, you must configure your devices, verify network connections, and set up file sharing on macOS.

Checking System and Network Requirements

To begin, ensure both your Mac and Linux machines are on the same network, connected either via Wi-Fi or Ethernet.

On Mac, check the Wi-Fi status in the menu bar or confirm connectivity under System Settings > Network.

You can verify how you're connected via the Network pane in the System Settings.

On Linux, use the network manager to check connectivity, or open the terminal and run the “ip addr” command.

Use ip addr to check your Linux machine network status and connections.

The ip command has many different functions, which you can use to change how Linux handles IP addresses, network interface controllers, and routing rules.

Enable File Sharing on macOS

When you enable file sharing on macOS, your Mac can share files with other devices, including Linux machines.

Head to System Settings > General > Sharing. In the Sharing menu, enable “File Sharing”, then select the icon to the right to open the Shared Folders configuration window.

In the Shared Folders configuration window, select “Options”. Verify that SMB File Sharing is on and enable your account for Windows File Sharing.

Finally, select “Done” to return to the Shared Folders window.

Add Shared Folders, New Users, and Configure Access

You can also add folders you want to share, new users to access these shares, and configure how they access them while you’re here.

To add a new shared folder, click the “+” below the Shared Folder pane, select the folder, and select “Open”. To configure access, select a folder, then select a user and set access permissions (“Read Only” for viewing or “Read & Write” for editing).

To add or remove users, click the “+” or “–” buttons at the bottom of the Users pane.

Access macOS Shared Folders on Linux

To access your Mac’s shared folders, open your file manager. On Ubuntu the default is usually Files (Nautilus), so we’ll use that.

Select “Network” from the left pane, then double-click the Mac that is sharing folders.

Enable File Sharing from Linux

I have some good news and bad news. You can easily share files from Linux using Samba, but the easiest and most reliable way to do this is via the Terminal.

This involves installing Samba on your version of Linux, adding yourself as a Samba user, then creating a Samba configuration file (smb.conf) and adding your shares.

First Install Samba on Linux

To install Samba on Ubuntu, open the terminal and enter the following:

sudo apt update

sudo apt install samba

On Fedora:

sudo dnf install samba

On Arch:

sudo pacman -S samba

Adding Samba Users and Shares on Linux

To add yourself as a Samba user:

sudo smbpasswd -a 

Create a blank smb.conf (I use vim as my text editor):

sudo cp /etc/samba/smb.conf /etc/samba/smb.conf.bak

sudo vim /etc/samba/smb.conf

Type or copy the following simple smb.conf into the new file and then save it:

[global]

workgroup = WORKGROUP

server string = %h server (Samba)

log file = /var/log/samba/log.%m

max log size = 1000

server role = standalone server

usershare path = /var/lib/samba/usershares

usershare allow guests = yes

[homes]

comment = Home Directories

browseable = no

read only = no

create mask = 0700

directory mask = 0700

Then restart Samba to make sure the changes to the smb.conf are applied:

sudo systemctl restart smbd

Now validate your configuration:

testparm

The only way to truly test this out is to try to connect to your Linux machine from your Mac, so let’s do that next.

Access Linux Shared Folders on macOS

You should now be able to access your Linux machine’s shared home folder from your Mac.

Open Finder, then select “Network” in the left pane. In the Network window, open your Linux machine, which will fail to connect.

Select “Connect As” in the upper-right corner of the network window, then enter your Samba credentials.

You should now be able to access your Home folder on your Linux machine with read/write privileges.

Congratulations! You’ve successfully set up file sharing between your Mac and Linux machine. By connecting these two platforms, you now have the ability to share files seamlessly, enabling smooth workflows and efficient collaboration in a mixed OS environment.

You can now enjoy the convenience of cross-platform file sharing and focus on what matters most—your work, projects, and creativity.


File sharing between macOS and Linux is essential if you want to create a smooth workflow in a mixed OS environment. Whether you need this setup for personal or professional purposes, this simplifies collaboration, backups, and development tasks.

Whether transferring files to a Linux-based server for storage or accessing media on a Linux machine from your Mac, these scenarios highlight the versatility and necessity of efficient file-sharing methods.



Source link

Previous articleWindows 11’s Start menu recommendations are being improved – but I’m still not impressed, Microsoft