【ubuntu 】使用samba配置共享用户home目录和其他具体路径

目录

[1 安装samba](#1 安装samba)

[2 修改Samba配置文件](#2 修改Samba配置文件)

[3 增加Rose用户的samba帐号](#3 增加Rose用户的samba帐号)

[4 重启samba](#4 重启samba)

[5 测试](#5 测试)


1 安装samba

使用如下命令安装samba

复制代码
sudo apt-get update

sudo apt-get install samba openssh-server

2 修改Samba配置文件

复制代码
sudo cp /etc/samba/smb.conf /etc/samba/smb.conf.ba

# 打开文件

sudo vim /etc/samba/smb.conf
  • 修改 ①

文件中的**[homes]项** 内容默认是注释掉的,我们取消注释,修改成如下:

复制代码
#======================= Share Definitions =======================


# Un-comment the following (and tweak the other settings below to suit)

# to enable the default home directory shares. This will share each

# user's home directory as \\server\username

[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


# File creation mask is set to 0700 for security reasons. If you want to

# create files with group=rw permissions, set next parameter to 0775.

   create mask = 0700


# Directory creation mask is set to 0700 for security reasons. If you want to

# create dirs. with group=rw permissions, set next parameter to 0775.

   directory mask = 0700


# By default, \\server\username shares can be connected to by anyone

# with access to the samba server.

# Un-comment the following parameter to make sure that only "username"

# can connect to \\server\username

# This might need tweaking when using external authentication schemes

   valid users = %S
  • 修改 ②

说明:用于指定共享的具体路径。

在文件的末尾,追加如下内容:

复制代码
[test]

   comment = Shared smb_base

   path = /home/test/

   create mask = 0755

   directory mask = 0755

   writable = yes

   valid users = Rose

   browseable = yes

如上修改完成后**++++wq++++**保存退出!

3 增加Rose用户的samba帐号

Rose为用户名,给Rose开通samba帐号的命令如下:

bash 复制代码
sudo smbpasswd -a Rose

然后根据提示设置对应的密码即可。

4 重启samba

bash 复制代码
sudo service smbd restart && service nmbd restart

5 测试

Windows下输入samba地址尝试登录:

示例如下:

bash 复制代码
\\你要连接的电脑的IP地址\test

然后,输入用户名Rose和对应的密码就可以访问共享的文件夹了。。。

至此,本文分享的内容就结束啦!遇见便是缘,感恩遇见 !!!💛 💙 💜 ❤️ 💚 💛 💙 💜 ❤️ 💚

相关推荐
Abigail_chow1 小时前
EXCEL如何快速批量给两字姓名中间加空格
windows·microsoft·excel·学习方法·政务
Sapphire~2 小时前
Linux-07 ubuntu 的 chrome 启动不了
linux·chrome·ubuntu
love530love3 小时前
【笔记】在 MSYS2(MINGW64)中正确安装 Rust
运维·开发语言·人工智能·windows·笔记·python·rust
啵啵学习3 小时前
Linux 里 su 和 sudo 命令这两个有什么不一样?
linux·运维·服务器·单片机·ubuntu·centos·嵌入式
代码搬运媛4 小时前
“packageManager“: “[email protected]“ 配置如何正确启动项目?
windows·webpack
小道士写程序5 小时前
Qt 5.12 上读取 .xlsx 文件(Windows 平台)
开发语言·windows·qt
FREEDOM_X6 小时前
新版NANO下载烧录过程
ubuntu·机器人
好多知识都想学8 小时前
Linux 文件处理器 sed 和 awk 详细讲解
linux·运维·ubuntu
异常君10 小时前
Windows 与 Linux 虚拟内存机制对比:设计理念与实现差异
java·linux·windows
搏博12 小时前
将图形可视化工具的 Python 脚本打包为 Windows 应用程序
开发语言·windows·python·matplotlib·数据可视化