Mark Ku's Blog

Step 1: Install and Configure Samba

Samba is a tool for sharing files between Linux and Windows systems.

  1. Install Samba

sudo apt update sudo apt install samba -y


2.  **Start Samba and enable it to run on boot**
 ```bash
sudo systemctl start smbd
sudo systemctl enable smbd
  1. Open the firewall to allow Samba

sudo ufw allow samba


4.  **Create a Samba User**
 - Add a new user (skip if the user already exists):
   ```bash
  sudo useradd -M -s /sbin/nologin username
  ```
 - Set the Samba password:
   ```bash
  sudo smbpasswd -a username
  sudo smbpasswd -e username
  ```

### **Step 2: Set Up a Shared Folder**
1.  **Create the shared folder**
 ```bash
mkdir -p /var/shared
sudo chmod 777 /var/shared
  1. Edit the Samba configuration file

    • Open the configuration file:

    sudo vim /etc/samba/smb.conf

    - Add the share settings to the end of the file:
    

    [shared] path = /var/shared browsable = no writable = yes read only = no guest ok = no create mask = 0777 directory mask = 0777

    P.S. It's best to set both `read only` and `guest ok` to `no`. I once had a worm drop some files into my Samba share.
    
    
  2. Save and exit the configuration file

    • Press Ctrl+O to save, and Ctrl+X to exit.
  3. Restart the Samba service

sudo systemctl restart smbd


### **Step 3: Access the Shared Folder from Windows 11**
1.  **Check your Ubuntu's IP address**
 ```bash
ip a
Take note of the IP address, which will look something like `192.168.x.x`.

2. Connect to the shared folder - Open File Explorer on Windows 11. - In the address bar, type: \\<Ubuntu_IP>\SharedFolder For example: \\192.168.1.100\SharedFolder

  1. Test the connection If everything is working correctly, you should be able to see the contents of the shared folder.

Troubleshooting Tips

  1. Manually open the required ports for Samba

sudo ufw allow proto tcp from any to any port 137,138,139,445 sudo ufw status


2.  **Check the Samba configuration file and directory permissions**
 - Confirm that the share settings in `/etc/samba/smb.conf` are correct.
 - Check the permissions of the shared folder:
   ```bash
  ls -ld /var/shared
  ```
   If necessary, adjust the permissions:
   ```bash
  sudo chmod 777 /var/shared
  ```

3.  **Check the Samba logs**
 ```bash
sudo tail -f /var/log/samba/log.smbd
  1. Use the IP address instead of the hostname Use \<IP 地址>\shared in Windows to avoid potential name resolution issues.

Author

Mark Ku

擁有 10+ 年經驗的資深軟體工程師,現為 AI 應用 Builder,專注於大型平台架構與簡化複雜系統設計,從電商系統到訂閱與收費平台,結合 AI Agent、AI 整合與自動化開發,打造高效率且可持續演進的產品技術基礎。Read More

Found this useful?

The author's free tools, daily podcasts and newsletter are all here.

Mark Ku · This article is licensed under CC BY 4.0. Credit the author and link back to the original when reusing it.

Comments

Subscribe to Newsletter

Subscribe to get new posts delivered instantly — never miss a tech share.

By submitting, you agree to receive emails. You can anytime.

Popular Posts

View all
Mark Ku
··602

Oracle Cloud Always Free Tier: Linux Host and Static IP for a $0 Cloud Solution

Oracle Cloud Always Free Tier: Linux Host and Static IP for a $0 Cloud Solution
Mark Ku
··490

Say Goodbye to Postman's Fee Trap! A Hands-on Guide to Bruno, the Open-Source Git-Native API Testing Powerhouse.

Say Goodbye to Postman's Fee Trap! A Hands-on Guide to Bruno, the Open-Source Git-Native API Testing Powerhouse.
Mark Ku
··333

A Free, Open-Source, Notion-like Knowledge Base — A Complete Guide to Deploying and Backing Up Outline Wiki

A Free, Open-Source, Notion-like Knowledge Base — A Complete Guide to Deploying and Backing Up Outline Wiki
Mark Ku
··264

Training Your Own AI Voice: Hardware Requirements, Open-Source Model Comparison, and LoRA Fine-Tuning

Training Your Own AI Voice: Hardware Requirements, Open-Source Model Comparison, and LoRA Fine-Tuning
Mark Ku
··221

Building an Efficient API Management Platform: Deploying Kong Gateway from Scratch - Part 1

Building an Efficient API Management Platform: Deploying Kong Gateway from Scratch - Part 1
Mark Ku
··215

Setting Up Samba on Ubuntu to Share Folders with Windows 11

Setting Up Samba on Ubuntu to Share Folders with Windows 11
在 Ubuntu 上設置 Samba 來共享資料夾,讓 Windows 11 用戶可以存取 - Mark Ku's Tech Notes