5

ubuntu_samba部署

 9 months ago
source link: https://jasonxqh.github.io/2023/04/16/ubuntu-samba%E9%83%A8%E7%BD%B2/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

ubuntu_samba部署

2023-04-16

539

|

2

由于之前装过samba但是被我稀里糊涂一顿操作给卸载了,显然也没有卸干净,于是打算重装一下。把能踩的坑基本都踩了。

首先我由于之前手动删除了 /etc/samba文件夹,导致重新下载以后这个文件夹不会自动生成。因此我需要删除samba所依赖的所有相关包:

sudo apt-get remove samba*

重新安装后还是会出现错误:dpkg:处理 samba-common (--configure)时出错:

因此要这样操作:

sudo` `mv` `/var/lib/dpkg/info` `/var/lib/dpkg/info_old
sudo` `mkdir` `/var/lib/dpkg/info
sudo` `apt-get update, apt-get -f ``install
sudo` `mv` `/var/lib/dpkg/info/``* ``/var/lib/dpkg/info_old
sudo` `rm` `-rf ``/var/lib/dpkg/info
sudo` `mv` `/var/lib/dpkg/info_old` `/var/lib/dpkg/info

然后就有/etc/samba 文件夹,但是smb.conf文件仍然需要自己配置:
其中,[share] 是自定义的,里面的path指向我需要共享的文件夹。

# Global parameters
[global]
log file = /var/log/samba/log.%m
logging = file
map to guest = Bad User
max log size = 1000
obey pam restrictions = Yes
pam password change = Yes
panic action = /usr/share/samba/panic-action %d
passwd chat = *Enter\snew\s*\spassword:* %n\n *Retype\snew\s*\spassword:* %n\n *password\supdated\ssuccessfully* .
passwd program = /usr/bin/passwd %u
server role = standalone server
server string = %h server (Samba, Ubuntu)
unix password sync = Yes
usershare allow guests = Yes
idmap config * : backend = tdb


[printers]
browseable = No
comment = All Printers
create mask = 0700
path = /var/spool/samba
printable = Yes


[print$]
comment = Printer Drivers
path = /var/lib/samba/printers


[share]
comment = this is Linux share directory
guest ok = Yes
path = /home/jason/sharefile

然后,要运行

smbpasswd -a root

来设置root用户,否则samba无法启动

设置完以后,我尝试启动samba服务:sudo system restart smbd.service ,结果失败:Failed to restart smbd.service: Unit smbd.service is masked

需要如下配置:

sudo systemctl unmask smbd.service
sudo systemctl enable smbd.service
sudo systemctl restart smbd.service

成功启动samba服务


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK