将 ubuntu-server 16.04 文件夹共享到 windows 主机

将 ubuntu-server 16.04 文件夹共享到 windows 主机

我已经安装了 ubuntu-server 16.04 和 VBoxLinuxadditions 和 Samba

我正在尝试将此服务器中的一个文件夹共享到我的 Windows 主机。现在我可以在我的网络上看到这个虚拟服务器,但服务器上没有共享文件夹。

在此处输入图片描述

我如何通过命令行创建一个?

答案1

所以我自己想出了这个问题,这是最简单的解决方案:

只需安装 samba

sudo apt install samba

并转到此文件:

/etc/samba/smb.conf

并在底部添加以下几行:

[share]

comment = Ubuntu File Server Share
path = /path/to/the/folder  #for example /home/user_name/public <- this comment needs to be deleted!
browsable = yes
guest ok = yes
read only = no
create mask = 0755

重新启动 samba 服务

sudo service smbd restart
sudo service nmbd restart

就这样,小菜一碟 :)

答案2


要使用 SMB 共享文件夹,您需要做的就是
根据您使用的文件管理器,确保安装了 nautilus-share 或 caja-share 或 ?-share,以便启用下一步,
右键单击文件夹并选择文件管理器应提供的 [属性 ->] 共享选项卡(
如果该步骤不建议执行此操作),请手动安装 samba,
选择正确的共享选项,然后单击共享,
参见https://help.ubuntu.com/community/Samba/SambaServerGuide#Ubuntu_Server

答案3

添加所有用户均可访问的共享。

创建用于共享文件的目录,并将所有者更改为用户组。

sudo mkdir -p /srv/samba/
sudo chown -R root:users /srv/samba/  [brusgroup][financial]
sudo chmod -R ug+rwx,o+rx-w /srv/samba/

添加和管理用户

例如对于组users和用户mattu

useradd mattu -m -G users
passwd mattu
sudo usermod -aG users mattu

为 mattu 设置密码

passwd mattu

输入新用户的密码


现在将用户添加到 Samba 用户数据库。

sudo smbpasswd -a mattu

输入新用户的密码


编辑 /etc/samba/smb.conf 文件

sudo vi /etc/samba/smb.conf

添加以下行并保存文件

[allusers]
 comment = All Users
 path = /srv/samba/allusers/
 valid users = @users
 force group = users
 create mask = 0660
 directory mask = 0771
 writable = yes

如果所有用户都可以通过 Samba 读取和写入其主目录,请编辑 /etc/samba/smb.conf 文件并删除所有行。在 vim 中:

  1. 键入gg以将光标移动到文件的第一行(如果光标尚未到达该行)。
  2. 键入dG以删除所有行。

现在您应该能够使用用户名 ruchi 和所选密码从文件资源管理器从 Windows 工作站登录,并将文件存储在 ubuntu 服务器的 ruchi 主目录或公共共享目录中。

[global] 
workgroup = WORKGROUP
#netbios name = [FRODO] 
passdb backend = tdbsam 
printcap name = cups 

add user script = /usr/sbin/useradd -m %u 
delete user script = /usr/sbin/userdel -r %u 
add group script = /usr/sbin/groupadd %g 
delete group script = /usr/sbin/groupdel %g 
add user to group script = /usr/sbin/groupmod -A %u %g 
delete user from group script = /usr/sbin/groupmod -R %u %g 
add machine script = /usr/sbin/useradd -s /bin/false -d /var/lib/nobody %u 

# Note: The following specifies the default logon script. 
# Per user logon scripts can be specified in the user account using pdbedit  
logon script = scripts\logon.bat 
# This sets the default profile path. Set per user paths with pdbedit 
logon path = \\%L\Profiles\%U 
logon drive = H: 
logon home = \\%L\%U 
domain logons = Yes 
os level = 35 
preferred master = Yes 
domain master = Yes 

#[deprecated thus change
#idmap uid = 15000-20000 
#idmap gid = 15000-20000 
#]
#[ 
idmap config * : backend = tdb
idmap config * : range = 10001-20000
idmap config DOMAIN : backend = rid
idmap config DOMAIN : range = 10000-20000
idmap config DOMAIN : base_rid = 0 
#]
printing = cups 


Example 2.8. Engineering Office smb.conf (shares and services)



[homes] 
comment = Home Directories 
valid users = %S 
read only = No 
browseable = No 
# Printing auto-share (makes printers available thru CUPS) 

[printers] 
comment = All Printers 
path = /var/spool/samba 
printer admin = root, maryo 
create mask = 0600 
guest ok = Yes 
printable = Yes 
browseable = No 

[print$] 
comment = Printer Drivers Share 
path = /var/lib/samba/drivers 
write list = maryo, root 
printer admin = maryo, root 
# Needed to support domain logons 

[netlogon] 
comment = Network Logon Service 
path = /var/lib/samba/netlogon 
admin users = root, maryo 
guest ok = Yes 
browseable = No 
# For profiles to work, create a user directory under the path 
# shown. i.e., mkdir -p /var/lib/samba/profiles/maryo 

[Profiles] 
comment = Roaming Profile Share 
path = /var/lib/samba/profiles 
read only = No 
profile acls = Yes 

相关内容