install samba
sudo apt-get install samba
sudo apt-get install cifs-utils
#sudo apt-get install samba-common //上面安装好,这个包就自动更新了
create share folder
mkdir /home/jxes/samba_share
sudo chmod 777 /home/jxes/samba_share/
modify samba config
sudo cp /etc/samba/smb.conf /etc/samba/smb.conf.bak
sudo vim /etc/samba/smb.conf
在smb.con里添加如下配置:
[global]
workgroup = jxes
netbios name = jxesVBox
server string = Virtual Box server
unix charset = utf8
display charset = utf8
dos charset = cp90
log file = /var/log/samba/log.%m
max log size = 500
security = share
load printers = no
[myshare] //在windows的资源管理器,输入IP/myshare可以看到ubuntu共享的目录
comment = Temporary file space
path = /home/jack/samba_share
force user = jack //如果不指user与group,默认会是nobody,nogroup
force group = jack
writable = yes
browseable = yes
guest ok = yes //允许匿名访问,即不用账号密码,如果改为no,则需要创建samba账号
create mask = 0644 //这个是指定远程传过来的文档的权限,如果不指定,默认都会是0777,这样什么文档都变有可执行权限,看着不爽
create samba user name
- sudo useradd mysmb
- 再给smba账号分配一个密码
sudo smbpasswd -a mysmb - 编辑/etc/samba/smbusers在里面添加下面这行:
mysmb= “Samba user.”
如果开启了防火墙,即ufw enable了,则需要允许samba端口
sudo ufw allow 139/tcp
sudo ufw allow 445/tcp
sudo ufw allow 137/udp
sudo ufw allow 138/udp
一切配置完后,重启smaba服务
sudo service smbd restart //在较新版本的ubuntu下可以sudo service samba restart
服务端测试命令
sudo testparm
查看samba服务状态命令
smbstatus
原文链接:https://www.f2er.com/ubuntu/352361.html