赞
踩
前提:已经换好源,不然下载很慢或者不成功
未换执行以下命令
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
sudo vim/etc/apt/sources.list
或者 sudo gedit /etc/apt/sources.list
#zhongkeda source deb https://mirrors.ustc.edu.cn/ubuntu/ focal main restricted universe multiverse deb-src https://mirrors.ustc.edu.cn/ubuntu/ focal main restricted universe multiverse deb https://mirrors.ustc.edu.cn/ubuntu/ focal-updates main restricted universe multiverse deb-src https://mirrors.ustc.edu.cn/ubuntu/ focal-updates main restricted universe multiverse deb https://mirrors.ustc.edu.cn/ubuntu/ focal-backports main restricted universe multiverse deb-src https://mirrors.ustc.edu.cn/ubuntu/ focal-backports main restricted universe multiverse deb https://mirrors.ustc.edu.cn/ubuntu/ focal-security main restricted universe multiverse deb-src https://mirrors.ustc.edu.cn/ubuntu/ focal-security main restricted universe multiverse deb https://mirrors.ustc.edu.cn/ubuntu/ focal-proposed main restricted universe multiverse deb-src https://mirrors.ustc.edu.cn/ubuntu/ focal-proposed main restricted universe multiverse #aliyun source deb http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
sudo apt-get update
换好源的首先更新下软件sudo apt-get update
再执行sudo apt-get install samba samba-common
创建共享文件夹
mkdir share //这是在home目录下
给文件夹指定权限
sudo chmod 777 /home/share
设置账号密码
sudo smbpasswd -a graysen //graysen 是我的用户名
编辑samba的配置文件
sudo vim /etc/samba/smb.conf
在smb.conf中输入以下(记得把中文注释去掉)
[share] //共享的文件名
comment = share //文件描述
path = /home/graysen/share //文件路径
public = yes
browseable = yes
writable = yes
read only = false
valid users = graysen //用户名,ubuntu的user
create make = 0777
directory mask = 0777
force user = graysen
force group = graysen
available = yes
重启samba服务器
sudo service smbd restart
history
查看Ubuntu的ip,输入ifconfig
在win系统下,win+r输入\你的ip(例如:\192.168.77.131)回车,会出现共享目录
将Linux的共享目录映射到Windows下,选中share这个共享目录,鼠标右键选择映射网络驱动器
点击完成后,会弹出登录窗口,输入账号和密码,再点击确定即可进行映射
账号和密码是前面设置过的
查看你的虚拟机是否指定共享路径(vmware右键设置)
如果你的window连接samba server,新建文件夹,显示无权限,这种情况大概率是服务器上的文件目录权限不全
需要你给共享文件夹指定权限,chomd 777 /share更改下权限(如果你前面不是按照步骤创建的文件夹)
引https://blog.csdn.net/qq_26003101/article/details/112275297
[root@ /] # chmod 777 /share [root@ /] # ll drwxr-xr-x 2 root root 0 1月 6 14:49 share # drwxr-xr-x 并不是全权限,说明执行成功 # 需要先行移除挂载和停止samba server [root@ /]# df -h //192.168.6.101/share 20G 4.1G 16G 21% /share [root@ /]# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 352229797a86 master2011/mysamba "/sbin/tini -- /usr/…" 59 minutes ago Up 47 minutes (healthy) 0.0.0.0:139->139/tcp, 137-138/udp, 0.0.0.0:445->445/tcp samba-test # 停止 [root@ /]# docker stop samba-test [root@ /]# umount -l //192.168.6.101/share /share umount: /share:未挂载 # 赋予权限 [root@ /] # chmod 777 /share [root@ /] # ll drwxrwxrwx 3 root root 17 1月 6 14:20 share # 重新启动和挂载、在挂载命令中要加 dir_mode=0777,file_mode=0777 [root@ /]# docker start samba-test [root@ /]# mount -t cifs //192.168.6.101/share /share -o username=test,password='test@2.',domain=DOMAIN,vers=2.0,dir_mode=0777,file_mode=0777
完成!
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。