This guide will walk you through setting up a shared folder on your Ubuntu Desktop 24.04 machine (MacBook Pro) that can be accessed from your Mac mini using the Samba protocol.
Goal: Share a specific folder (e.g., "files") from Ubuntu machine to Mac mini (or other macOS devices), allowing a user named "mactu"(example) to read, store, and delete files within that folder.
Prerequisites:
Ubuntu Desktop 24.04 is installed and running on the old MacBook Pro (Mine is 2012).
Both the Ubuntu machine and the Mac mini are connected to the same local network (via Wi-Fi or Ethernet).
Have administrative privileges (
sudo
access) on the Ubuntu machine.
Disk Setup (Usually Not Needed)
If the folder to share (files
) is already part of the main Ubuntu installation (e.g., in the home directory), it does not need any additional disk setup. If it's on a separate drive, ensure that drive is mounted and accessible in Ubuntu.
Steps on the Ubuntu Machine (MacBook Pro)
Install Samba: Samba is the software that implements the SMB/CIFS file-sharing protocol used by Windows and macOS.
Open the Terminal on the Ubuntu machine.
First, update the package list:
sudo apt update
Then, install the Samba package:
sudo apt install samba
You may be asked to confirm the installation and potentially configure some basic workgroup settings during installation. For a home network, the default settings are usually fine.
Create or Identify the Folder to Share: Decide which folder to share. For this guide, let's assume you want to share a folder named
shared_files
located in your home directory. If your "files" folder is elsewhere, adjust the path accordingly.If the folder doesn't exist, create it:
mkdir ~/shared_files
(Replace
~/shared_files
with the actual path if your folder is elsewhere, e.g.,/path/to/your/files
).Configure Samba (
smb.conf
): You need to tell Samba about the folder you want to share and who can access it.Open the Samba configuration file (
smb.conf
) using a text editor likenano
:sudo nano /etc/samba/smb.conf
Scroll to the very end of the file and add the following section. Make sure to replace
/home/your_ubuntu_username/shared_files
with the actual path to your folder andyour_ubuntu_username
with your Ubuntu login username.[shared_files] comment = mactu's Shared Files path = /home/your_ubuntu_username/shared_files # <-- IMPORTANT: Change this to the actual path browseable = yes writable = yes create mask = 0770 directory mask = 0770 valid users = mactu force user = your_ubuntu_username # <-- IMPORTANT: Files created by 'mactu' will be owned by your Ubuntu user public = no
[shared_files]
: This is the name that will appear for the shared folder on the Mac mini. It can changed.comment
: A description of the share.path
: The absolute path to the folder on the Ubuntu machine.browseable = yes
: Allows the share to be listed when browsing the Ubuntu machine from the network.writable = yes
: Allows the user 'mactu' to create, modify, and delete files in this folder.create mask = 0770
anddirectory mask = 0770
: Set permissions for new files/folders created by Samba users (owner and group get full read/write/execute, others get nothing).valid users =
mactu: Restricts access to only the user named 'mactu'.force user = your_ubuntu_username
: Ensures that files created by 'mactu' are owned by the Ubuntu user. This helps prevent permission conflicts on the Ubuntu side.public = no
: Requires a username and password to access the share. This is a key security measure.
Save the file and exit the editor. In
nano
, pressCtrl + X
, thenY
to confirm saving, andEnter
to use the current filename.Create a Samba User for 'mactu': Samba manages its own user database for network access. You need to create a Samba user corresponding to 'mactu' and set a password for network access. This user doesn't need a separate Ubuntu login account, but using an existing system user simplifies permission handling.
If 'mactu' already has a user account on your Ubuntu machine, simply add that user to the Samba database:
sudo smbpasswd -a mactu
It will be prompted to set a password specifically for Samba access for the user 'mactu'. This password is what you will use to connect from your Mac mini.
If 'mactu' does not have a user account on your Ubuntu machine, you can create a system user specifically for Samba access (without a login shell):
sudo adduser --no-create-home --shell /usr/sbin/nologin mactu sudo smbpasswd -a mactu
Again, you'll set the Samba password for 'mactu'.
Restart the Samba Service: Apply the configuration changes by restarting the Samba services.
sudo systemctl restart smbd nmbd
Configure Firewall (if enabled): If you are using the UFW (Uncomplicated Firewall) on Ubuntu, you need to allow Samba traffic through the firewall.
Check your firewall status:
sudo ufw status
If the status is
active
, allow the Samba application profile:sudo ufw allow samba
Verify the rule was added:
sudo ufw status
Find the Ubuntu Machine's IP Address: You need the network address of the Ubuntu machine to connect from the Mac mini.
In the Terminal, run:
ip addr show
Look for the network interface corresponding to the Wi-Fi connection (often named
wlan0
). Find the line starting withinet
followed by an IP address (e.g.,192.168.1.150
). This is your Ubuntu machine's local IP address.
Steps on the Mac Mini
Connect to Server in Finder: Switch to the Mac mini.
Open Finder.
In the Finder menu bar, click Go > Connect to Server... (or press
Command + K
).Enter the Server Address: In the "Server Address:" field, type
smb://
followed by the IP address of the Ubuntu machine that you found in the previous step.smb://your_ubuntu_ip_address
Replace
your_ubuntu_ip_address
with the actual IP address (e.g.,smb://192.168.1.150
).Click Connect.
Authenticate: A window will pop up asking for authentication.
Select Registered User.
Name: Enter mactu
Password: Enter the Samba password you set for the user 'mactu' on the Ubuntu machine in Step 4.
You can optionally check "Remember this password in my keychain" if you don't want to enter the password every time.
Click Connect.
Select the Share: If prompted, select the share you want to connect to. You should see
shared_files
(or whatever name you used insmb.conf
).Click OK or Connect.
The shared folder from the Ubuntu machine should now appear in the Finder sidebar under "Locations" (it might show the Ubuntu machine's name or IP address). You can open it and work with the files inside, with the permissions (read/store/delete) you configured.
Best Practices and Security Considerations
Use Strong, Unique Passwords: Always use a strong, unique password for the Samba users.
Restrict Access with
valid users
: Only allow necessary users to access specific shares using thevalid users
option insmb.conf
.Require Authentication (
public = no
): Never setpublic = yes
for shares containing personal data on a home network. Always require a username and password.Firewall: Keep your firewall enabled on Ubuntu and only open the necessary ports/services (like Samba).
Share Specific Folders: Avoid sharing your entire home directory. Create dedicated folders for sharing with appropriate permissions.
Keep Ubuntu Updated: Regularly update your Ubuntu operating system and installed packages (including Samba) to ensure you have the latest security fixes.
Consider Static IP: If the Ubuntu machine's local IP address changes frequently (due to the router's DHCP server), consider configuring a static IP for it. This prevents you from having to update the IP address in Finder's "Connect to Server" dialog. You can usually do this in your router's settings or in Ubuntu's network configuration.
By following these steps, you can establish a secure and functional file share between your Ubuntu machine and your Mac mini.