Windows XP Windows 7 Windows 2003 Windows Vista Windows 綜合教學 Linux 系統教學
Windows 10 Windows 8 Windows 2008 Windows NT Windows Server 電腦軟體教學
您现在的位置: Windows教程網 >> Windows教程 >  >> Windows 綜合教學 >> 關於 Windows

如何將 Windows 資料夾掛載到 Linux?CIFS/SMB 掛載完整指令教學

編輯:關於 Windows

開發環境常需將 Windows 共享資料夾掛載到 Linux 系統存取。本文提供臨時掛載與開機自動掛載(寫入 /etc/fstab)的完整指令,並說明權限對應(uid/gid)設定。

前置條件

  • Windows 端已共享目標資料夾,並設定讀寫權限。
  • Linux 與 Windows 在同一區域網路,可互通 IP。
  • Linux 已安裝 cifs-utils 套件(apt install cifs-utils 或 yum install cifs-utils)。

臨時掛載(重啟失效)

mount -t cifs //Windows_IP/共享資料夾名稱 /Linux/掛載點目錄 -o username=Windows帳號,password=密碼

永久掛載(寫入 /etc/fstab,需 root 權限編輯)

//Windows_IP/共享資料夾名稱 /Linux/掛載點 cifs defaults,username=Windows帳號,password=密碼 0 0

指定掛載後的檔案擁有者(uid/gid)

預設掛載檔案擁有者為 root。若需對應特定 Linux 使用者:

//Windows_IP/共享資料夾名稱 /Linux/掛載點 cifs defaults,username=Windows帳號,password=密碼,uid=1000,gid=1000 0 0

uid、gid 可用 id 使用者名稱 或查 /etc/passwd 取得。

注意:密碼明文寫在 fstab 有風險,生產環境建議使用 credentials=檔案路徑 方式引用含帳密的隱藏檔案。

Copyright © Windows教程網 All Rights Reserved