開發環境常需將 Windows 共享資料夾掛載到 Linux 系統存取。本文提供臨時掛載與開機自動掛載(寫入 /etc/fstab)的完整指令,並說明權限對應(uid/gid)設定。
cifs-utils 套件(apt install cifs-utils 或 yum install cifs-utils)。mount -t cifs //Windows_IP/共享資料夾名稱 /Linux/掛載點目錄 -o username=Windows帳號,password=密碼
//Windows_IP/共享資料夾名稱 /Linux/掛載點 cifs defaults,username=Windows帳號,password=密碼 0 0
預設掛載檔案擁有者為 root。若需對應特定 Linux 使用者:
//Windows_IP/共享資料夾名稱 /Linux/掛載點 cifs defaults,username=Windows帳號,password=密碼,uid=1000,gid=1000 0 0
uid、gid 可用 id 使用者名稱 或查 /etc/passwd 取得。
注意:密碼明文寫在 fstab 有風險,生產環境建議使用 credentials=檔案路徑 方式引用含帳密的隱藏檔案。