Sharename Type Comment --------- ---- ------- IPC$ IPC IPC Service (Samba Server Version 3.6.9-164.el6) student Disk Home Directories Domain=[MYGROUP] OS=[Unix] Server=[Samba 3.6.9-164.el6]
Server Comment --------- ------- RHEL6 Samba Server Version 3.6.9-164.el6
49584 blocks of size 8192. 45708 blocks available smb: \> exit ------------------------------------------------------------- # 客户端windows 打开浏览器输入\\172.25.0.11\ 输入student和uplooking密码后就可以进入服务器中的用户家目录,创建目录aa,以及文件aa下的dd.txt -------------------------------------------------------------- # 客户端linux [root@rhel7 ~]# smbclient //172.25.0.11/student -U student Enter student\'s password: Domain=[MYGROUP] OS=[Unix] Server=[Samba 3.6.9-164.el6] smb: \> ls . D 0 Thu Aug 4 04:30:31 2016 .. D 0 Thu Jul 2 03:57:30 2015 .ssh DH 0 Thu Jul 2 04:01:07 2015 aa D 0 Thu Aug 4 04:30:28 2016 .bashrc H 124 Tue Jul 9 09:24:50 2013 .bash_logout H 18 Tue Jul 9 09:24:50 2013 .mozilla DH 0 Thu Jul 2 03:36:20 2015 .bash_history H 5 Thu Jul 2 04:01:16 2015 .gnome2 DH 0 Wed Jul 14 11:55:40 2010 .bash_profile H 176 Tue Jul 9 09:24:50 2013
49584 blocks of size 8192. 45707 blocks available smb: \> get aa NT_STATUS_FILE_IS_A_DIRECTORY opening remote file \aa smb: \> cd aa smb: \aa\> ls . D 0 Thu Aug 4 04:30:28 2016 .. D 0 Thu Aug 4 04:30:31 2016 dd.txt A 2 Thu Aug 4 04:31:01 2016
49584 blocks of size 8192. 45707 blocks available smb: \aa\> get dd.txt getting file \aa\dd.txt of size 2 as dd.txt (1.0 KiloBytes/sec) (average 1.0 KiloBytes/sec) 可以查看到了。
1.创建共享目录/var/lib/samba/share [root@rhel6 ~]# mkdir /var/lib/samba/share 2.修改配置文件 [root@rhel6 ~]# vim /etc/samba/smb.conf [public] comment = Public Stuff path = /var/lib/samba/share public = yes writable = yes 3.重启服务 [root@rhel6 ~]# service smb restart Shutting down SMB services: [ OK ] Starting SMB services: [ OK ] [root@rhel6 ~]# service nmb restart Shutting down NMB services: [ OK ] Starting NMB services: [ OK ] 4.修改共享目录的UGO权限 [root@rhel6 ~]# ll -d /var/lib/samba/share drwxr-xr-x. 2 root root 4096 Aug 5 10:27 /var/lib/samba/share [root@rhel6 ~]# grep nobody /etc/passwd nobody:x:99:99:Nobody:/:/sbin/nologin nfsnobody:x:65534:65534:Anonymous NFS User:/var/lib/nfs:/sbin/nologin [root@rhel6 ~]# chown nobody. /var/lib/samba/share [root@rhel6 ~]# ll -d /var/lib/samba/share drwxr-xr-x. 2 nobody nobody 4096 Aug 5 10:27 /var/lib/samba/share [root@rhel6 ~]# touch /var/lib/samba/share [root@rhel6 ~]# touch /var/lib/samba/share/smb-file{1..5} [root@rhel6 ~]# chown nobody. /var/lib/samba/share -R
[root@rhel6 ~]# service smb stop Shutting down SMB services: [ OK ] [root@rhel6 ~]# service smb start Starting SMB services: [ OK ] ############ 客户端rhel7 ############ [root@rhel7 ~]# smbclient -L 172.25.0.11 Enter root\'s password: Anonymous login successful Domain=[MYGROUP] OS=[Unix] Server=[Samba 3.6.9-164.el6]
Sharename Type Comment --------- ---- ------- public Disk Public Stuff IPC$ IPC IPC Service (Samba Server Version 3.6.9-164.el6) Anonymous login successful Domain=[MYGROUP] OS=[Unix] Server=[Samba 3.6.9-164.el6]
Server Comment --------- ------- RHEL6 Samba Server Version 3.6.9-164.el6
Workgroup Master --------- ------- MYGROUP RHEL6 [root@rhel7 ~]# smbclient //172.25.0.11/public Enter root\'s password: Anonymous login successful Domain=[MYGROUP] OS=[Unix] Server=[Samba 3.6.9-164.el6] smb: \> ls . D 0 Thu Aug 4 22:32:12 2016 .. D 0 Thu Aug 4 22:30:52 2016 smb-file4 N 0 Thu Aug 4 22:32:12 2016 smb-file2 N 0 Thu Aug 4 22:32:12 2016 smb-file5 N 0 Thu Aug 4 22:32:12 2016 smb-file1 N 0 Thu Aug 4 22:32:12 2016 smb-file3 N 0 Thu Aug 4 22:32:12 2016
34505 blocks of size 524288. 26941 blocks available smb: \> get smb-file1 getting file \smb-file1 of size 0 as smb-file1 (0.0 KiloBytes/sec) (average 0.0 KiloBytes/sec) smb: \> put rhel7 putting file rhel7 as \rhel7 (0.0 kb/s) (average 0.0 kb/s) smb: \> ls . D 0 Thu Aug 4 22:34:46 2016 .. D 0 Thu Aug 4 22:30:52 2016 smb-file4 N 0 Thu Aug 4 22:32:12 2016 rhel7 A 0 Thu Aug 4 22:34:46 2016 smb-file2 N 0 Thu Aug 4 22:32:12 2016 smb-file5 N 0 Thu Aug 4 22:32:12 2016 smb-file1 N 0 Thu Aug 4 22:32:12 2016 smb-file3 N 0 Thu Aug 4 22:32:12 2016
34505 blocks of size 524288. 26941 blocks available smb: \> exit ############ 客户端windows ############ 打开浏览器输入\\172.25.0.11\ 就能看到public了