在桌面打开终端,登录到root用户
#执行后输入开机密码
sudo su
备份samba服务配置文件
cp -a /etc/samba/smb.conf /etc/samba/smb.conf.bak
直接复制以下命令到终端然后回车, 打印机名称自行修改
cat >/etc/samba/smb.conf<<-EOF
[global] workgroup = WORKGROUP server string = %h server (Samba, Ubuntu) wins support = yes dns proxy = no log file = /var/log/samba/log.%m max log size = 1000 syslog = 0 panic action = /usr/share/samba/panic-action %d server role = standalone server passdb backend = tdbsam obey pam restrictions = yes unix password sync = yes passwd program = /usr/bin/passwd %u passwd chat = *Enter\snew\s*\spassword:* %n\n *Retype\snew\s*\spassword:* %n\n *password\supdated\ssuccessfully* . pam password change = yes map to guest = bad user usershare allow guests = yes [printers] comment = All Printers browseable = yes path = /var/spool/samba printable = yes guest ok = yes read only = yes create mask = 0700 writable = yes
#这是共享打印机的名称 my printer printer name = my printer [print$] comment = Printer Drivers path = /var/lib/samba/printers browseable = yes read only = yes guest ok = yes
EOF
重启Samba服务
/etc/init.d/samba restart
然后在控制面板-安全中心-网络保护中选择自定义配置
勾选samba,开放Samba服务的端口,让其他人可以访问
之后在其他设备上输入这台机子的IP地址就可以添加打印机了