samba == 文件共享区配置

yum install -y samba samba-client

进去配置文件

vim /etc/samba/smb.conf

修改

security = share

workgroup = WORKGROUP

最后加上

[aming]

comment = share all

path =/tmp/sambadir

browseable = yes

public = yes

writable = no

保存

启动

/etc/init.d/smb start

启动 SMB 服务:                                            [确定]

[root@mingming ~]# mkdir /tmp/sambadir

[root@mingming ~]# cp /etc/passwd /tmp/sambadir/

[root@mingming ~]# cp /etc/passwd /tmp/sambadir/1.txt

[root@mingming ~]# mkdir /tmp/sambadir/test

[root@mingming ~]# chmod 777 /tmp/sambadir/test/

Windows下访问

在真机中

打开运行

\\192.168.23.128

可以看到共享文件

虽然test文件为777 但是我们还是不能创建,因为我们在配置文件中设定了

linux下访问

smbclient //192.168.23.128/aming

WARNING: The security=share option is deprecated

Enter root's password:

Domain=[WORKGROUP] OS=[Unix] Server=[Samba 3.6.23-43.el6_9]

Server not using user level security and no password supplied.

smb: \> ls

.                                   D        0  Sun Jul  2 06:42:48 2017

..                                  D        0  Sun Jul  2 06:41:11 2017

test                                D        0  Sun Jul  2 06:42:48 2017

passwd                                    1139  Sun Jul  2 06:41:34 2017

1.txt                                     1139  Sun Jul  2 06:42:24 2017

smb: \> exit

第二种方式访问

[root@mingming ~]# yum install -y cifs-utils

挂载

[root@mingming ~]# mount -t cifs //192.168.23.128/aming /opt/

Password:

[root@mingming ~]# df -h

Filesystem              Size  Used Avail Use% Mounted on

/dev/sda3                18G  2.1G   15G  13% /

tmpfs                   504M     0  504M   0% /dev/shm

/dev/sda1                97M   26M   66M  29% /boot

//192.168.23.128/aming   18G  2.1G   15G  13% /opt

[root@mingming ~]# cd /opt/

[root@mingming opt]# ls

1.txt  passwd  test

带用户名和密码目录共享

vim /etc/samba/smb.conf

修改

security = user

增加

[aminglinux]

comment = share for users

path =/tmp/sambadir

browseable = yes

public = no

writable = yes

创建账户 用户

[root@mingming ~]# useradd smbuser1

[root@mingming ~]# pdbedit -a smbuser1

new password:

retype new password:

Unix username:        smbuser1

NT username:

Account Flags:        [U          ]

User SID:             S-1-5-21-370484250-3851866674-1558319732-1000

Primary Group SID:    S-1-5-21-370484250-3851866674-1558319732-513

Full Name:

Home Directory:       \\mingming\smbuser1

HomeDir Drive:

Logon Script:

Profile Path:         \\mingming\smbuser1\profile

Domain:               MINGMING

Account desc:

Workstations:

Munged dial:

Logon time:           0

Logoff time:          never

Kickoff time:         never

Password last set:    日, 02 7月 2017 07:06:11 CST

Password can change:  日, 02 7月 2017 07:06:11 CST

Password must change: never

Last bad password   : 0

Bad password count  : 0

Logon hours         : FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF

# pdbedit -x smbuser1 删除用户

重启

[root@mingming ~]# /etc/init.d/smb restart

关闭 SMB 服务:                                            [确定]

启动 SMB 服务:                                            [确定]

Windows下访问

在真机中

打开运行

\\192.168.23.128\aminglinux

账号:smbuser1

密码:123456

可以看到共享文件

test文件为777 但是我们是可以创建文件的,因为我们在配置文件中设定了

linux下访问

smbclient -Usmbuser1 //192.168.23.128/aminglinux

挂载

[root@mingming ~]# mount -t cifs -o username=smbuser1,password=123456  //192.168.23.128/aminglinux /opt/

[root@mingming ~]# df -h

Filesystem                   Size  Used Avail Use% Mounted on

/dev/sda3                     18G  2.1G   15G  13% /

tmpfs                        504M     0  504M   0% /dev/shm

/dev/sda1                     97M   26M   66M  29% /boot

//192.168.23.128/aming        18G  2.1G   15G  13% /opt

//192.168.23.128/aminglinux   18G  2.1G   15G  13% /opt