ubuntu 下创建和访问共享文件夹

1.创建共享文件夹:

1.ubuntu12.04 版本:
$ sudo apt-get install samba4  
$ sudo mkdir -p /home/share //创建共享文件夹 
$ sudo chmod 777 /home/share  
$ sudo cp /etc/samba/smb.conf /etc/samba/smb-bk.conf  
$ sudo vim /etc/samba/smb.conf  //编辑samba配置文件,添加如下代码
....
# ----------------------- Standalone Server Options ------------------------
#
# Scurity can be set to user, share(deprecated) or server(deprecated)
#
# Backend to store user information in. New installations should
# use either tdbsam or ldapsam. smbpasswd is available for backwards
# compatibility. tdbsam requires no further configuration.
#       security = user
#免密码访问
        security = share
....
 [share]
       path = /home/android8/Documents
       available = yes
       browseable = yes
       public = yes
       writable = yes

 [zhanglei_share]
       path = /home/zhanglei/share
       available = yes
       browseable = yes
       public = yes
       writable = yes
 $ sudo /etc/init.d/smbd restart
 
 2.ubuntu14.04版本:
 $ sudo apt-get install samba samba-common
 $ mkdir -p share
 $ sudo chown nobody:nogroup ./share
 $ sudo cp /etc/samba/smb.conf /etc/samba/smb.conf.bk
 $ sudo vim /etc/samba/smb.conf

[Anonymous]
       comment = Anonymous share access
       path = /shares/anonymous
       browsable = yes
       writable = yes
       guest ok = yes
       read only = no
       force user = nobody
       force group = nogroup
 $ sudo service smbd restart

2:访问共享文件夹
ubuntu 12.04LTS已经不支持smbfs文件系统,所以不能用mount -smbfs 来映射windows共享文件夹。

常见有两种方法

1.terminal下

mount //192.168.0.88/share  -o user=DOMIAN\\xxx,pass=xxx /mnt/share

注:其中192.168.0.88是windows主机名称,share是其共享文件夹名。domain是windows主机域名,必须大写。 

2. GUI方式

主文件夹下,按Ctrl+l,输入smb://192.168.0.88,按提示输入登陆账户,然后就可以访问了。

2.ubuntu 16.04设置

1.安装samba服务
sudo apt-get install samba
sudo smbpasswd -a $USER
sudo service smbd restart
2.设置共享文件夹
打开文件管理器,选择需要共享的文件夹,右键,选择“Local Network Share”,点击“Create Share”,完成
3.测试
点击文件管理器“Connect to Server”
输入网址“smb://127.0.0.1”
选择“Registered User”
输入用户名,密码,点击"Connect"
完成

你可能感兴趣的:(Linux技巧)