操作步骤(需root用户权限):
- 通过apt安装samba服务,命令如下:
sudo apt install samba
- 备份samba配置文件,命令如下:
sudo cp /etc/samba/smb.conf /etc/samba/smb.conf.bak
- 打开samba配置文件,修改“[homes]”段中的“read only = no”为“read only = yes”,如下所示:
[homes]
comment = Home Directories
browseable = no
# By default, the home directories are exported read-only. Change the
# next parameter to 'no' if you want to be able to write to them.
read only = yes
命令如下:
sudo sed -i '/\[homes\]/,/read only = yes/s/read only = yes/read only = no/' /etc/samba/smb.conf
- 设置samba用户密码,命令如下:
sudo smbpasswd -a pi
在“New SMB password:”提示后输入要设置的密码
命令合并如下:
sudo apt-get install samba
sudo cp /etc/samba/smb.conf /etc/samba/smb.conf.bak
sudo sed -i '/\[homes\]/,/read only = yes/s/read only = yes/read only = no/' /etc/samba/smb.conf
sudo smbpasswd -a pi
在“New SMB password:”提示后输入要设置的密码