MirrorNest
← すべてのガイド

Samba file sharing on Ubuntu

Samba implements the SMB/CIFS protocol, letting a Linux server share folders that appear as normal network drives to Windows, MacOS, and other Linux machines.

対象: Ubuntu 22.04 LTS / 24.04 LTSfile-sharingSMBnetworking公式ホームページ ↗公式ドキュメント ↗
このガイドは上記リンク先にあるSamba file sharing on Ubuntu公式ドキュメントをもとに作成されています。ディストリビューションやプロジェクトのバージョンは時間とともに変わるため、本番サーバーでこれらのコマンドを実行する前に、必ず公式ドキュメントで正確なパッケージ名・バージョン名を確認してください。
  1. 1Install Samba

    sudo apt update
    sudo apt install -y samba
  2. 2Define a shared folder

    Add a new section to smb.conf naming the share and pointing it at a real directory.

    sudo mkdir -p /srv/samba/shared
    sudo chmod 2775 /srv/samba/shared
    sudo nano /etc/samba/smb.conf

    Add at the bottom of smb.conf: [Shared] path = /srv/samba/shared browseable = yes read only = no guest ok = no valid users = @sambashare

  3. 3Create a Samba user and restart the service

    sudo groupadd sambashare
    sudo usermod -aG sambashare $USER
    sudo smbpasswd -a $USER
    sudo systemctl restart smbd
  4. 4Connect from a client

    On Windows, map a network drive to \\server-ip\Shared; on MacOS, use Finder > Go > Connect to Server with smb://server-ip/Shared.