1

Ubuntu 安装 samba server 作为局域网里的文件共享服务器

 2 years ago
source link: https://hellodk.cn/post/174
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 程序很简单

sudo apt install samba

安装 samba 即可,我没有安装 samba-common 亦正常使用

samba-common 是 samba 的支持文件

二、编辑配置文件 /etc/samba/smb.conf

修改 smb.conf 文件前建议备份下该文件的原始版本:

sudo cp /etc/samba/smb.conf /etc/samba/smb.conf.backup

然后修改该文件,在 smb.conf 文件末尾追加:

[thinkpad-samba-server]
comment = samba server in thinkpad t400
path = /home/你的用户名/Downloads/
public = yes
browseable = yes
read only = no
valid users = 你的用户名
create mask = 0755
directory mask = 0755
force user = nobody
force group = nogroup
available = yes
[FIVE00-thinkpad]
comment = FIVE00 disk samba server in thinkpad t400
path = /media/某某文件夹/
public = yes
browseable = yes
read only = no
valid users = 你的用户名
create mask = 0755
directory mask = 0755
force user = 你的用户名
force group = nogroup
available = yes

每一个中括号都代表一个配置项,指向不同的目录时可以创建多个这样的 profile

三、设置用户名和密码

用户名上面已经设置,就是 valid user 选项的值 输入 sudo smbpasswd -a 用户名 然后输入密码 即可完成设置

四、重载 samba 服务并重启

sudo systemctl reload smbd.service
sudo systemctl restart smbd.service

Linux 的设计哲学之一就包含了你执行了一些命令后,如果没有任何提示,说明输入的命令无误、程序的运行很完美。可以通过 sudo systemctl status smbd.service 查看 当前程序运行状态

ps: 有的系统、有的版本上,samba 服务还是通过 /etc/init.d/samba 或者 service samba start 这样的风格来管理的,其实都一样,殊途同归

为什么我的 FIVE00-thinkpad 配置项里 force user 的值是 用户名呢?因为这个路径下的文件夹 是 Windows 的 NTFS 格式的文件系统,经过我的测试如果这里指定 nobody 的话会无法正常访问


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK