Samba can implement file sharing between Linux and Windows, primarily including server-side software samba, client software samba-client, and common component Samba-common for providing server and client programs. Most of the packages in CentOS are already installed by default. Samba Server provides SMBD, NMBD two service programs, respectively, to complete different functions. Where SMBD is responsible for providing clients with access to shared resources (directories and files, etc.) on the server, and NMBD is responsible for providing host name resolution based on the NetBIOS protocol for querying services for hosts in a Windows network.
Example:
ABC is a website design company, the company below has the design department, the development Department, the operation and maintenance department and so on several departments, the company decided to deploy a samba server, satisfies each department quickly to share the data the demand.
Design Department share directory:/abc/design
Development Department Share directory:/abc/develop
Operation and Maintenance Department share directory:/abc/ops
Public Share directory:/abc/share
Two users per directory, Department supervisor with read and write permissions, others only have read permissions, take the operations department as an example: the supervisor's user name is: opsadmin (password and user name consistent), others: Ops1 (password and user name consistent). Public Shared directory: Administrator (password and user name consistent) have read and write permissions, and everyone else has Read permission only.
1 Turn off firewall and SELinux:
[[Email protected] ~]# service iptables stop
[Email protected] ~]# Vim/etc/selinux/config
Selinux=disabled
[Email protected] ~]# Setenforce 0
2 Configuring the Samba server:
Installation program Components
[Email protected] ~]# Rpm-qa | grep ' Samba '
Samba-common-3.6.23-33.el6.i686
samba-client-3.6.23-33.el6.i686
samba-winbind-3.6.23-33.el6.i686
samba4-libs-4.2.10-6.el6_7.i686
samba-winbind-clients-3.6.23-33.el6.i686
[[email protected] ~]# yum-y install Samba
Creating Shared directories and test files
[[email protected] ~]# Mkdir-pv/abc/{design,develop,ops,share}
[Email protected] abc]# echo "This is design" >>/abc/design/de.txt
[Email protected] abc]# echo "This is develop" >>/abc/develop/deve.txt
[[email protected] abc]# echo "This is Ops" >>/abc/ops/ops.txt
[Email protected] abc]# echo "This is share" >>/abc/share/share.txt
[Email protected] abc]# tree/abc/
/abc/
├──design
│└──de.txt
├──develop
│└──deve.txt
├──ops
│└──ops.txt
└──share
└──share.txt
4 Directories, 4 files
Set up an account: The Samba server uses a separate shared account database file, where the account must correspond to a system user with the same name, so that the host can control read and write access to the shared access, but the shared user's password is additional, and may not be the same as the password for the system user.
[Email protected] ~]# useradd-s/sbin/nologin opsadmin #先增加系统用户
[Email protected] ~]# pdbedit-a-u opsadmin #再添加共享用户
[Email protected] ~]# useradd-s/sbin/nologin ops1
[Email protected] ~]# pdbedit-a-u ops1
[Email protected] ~]# useradd-s/sbin/nologin Administrator
[Email protected] ~]# pdbedit-a-u Administrator
[Email protected] ~]# pdbedit-l #列出所有用户
opsadmin:501:
administrator:503:
ops1:502:
[Email protected] ~]# pdbedit-x-u vina #删除某个用户
[Email protected] ~]# PDBEDIT-VL ops1 #显示用户详细信息
Unix USERNAME:OPS1
NT Username:
Account Flags: [U]
User sid:s-1-5-21-2138872188-2142312678-3225965792-1001
Primary Group sid:s-1-5-21-2138872188-2142312678-3225965792-513
Full Name:
Home Directory: \\localhost\ops1
Homedir Drive:
Logon Script:
Profile Path: \\localhost\ops1\profile
Domain:localhost
Account desc:
Workstations:
Munged Dial:
Logon time:0
Logoff Time:never
Kickoff Time:never
Password last Set:tue, 12:04:49 CST
Password can change:tue, 12:04:49 CST
Password must Change:never
Last Bad password:0
Bad password count:0
Logon HOURS:FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
Modifying a configuration file
[Email protected] abc]# vim/etc/samba/smb.conf
[Global]
Security = User
[Share]
Path =/abc/share
Public = yes
browseable = yes
Read Only = yes
Write list = Administrator
[OPS]
Path =/abc/ops
browseable = yes
public = No
Write list = Opsadmin
Valid users = Ops1,opsadmin
[Email protected] abc]# Testparm #检查配置文件
[[email protected] abc]# chmod-r 777/abc/{design,develop,ops,share}
Open service
[[Email protected] abc]# service SMB start
[[Email protected] abc]# service NMB start
After modifying the configuration file, the configuration file needs to be re-loaded
[[Email protected] abc]# service SMB Reload
Attached: Samba profiles commonly used parameters are detailed:
1) Security = user | Share
Share: You do not need to provide user name and password;
User: The shared directory can only be accessed by authorized users, and verify the correctness of the account and password;
2) Path =/abc/ops: The path of the shared directory;
3) browseable = no | Yes: whether the directory can be browsed, no means to hide the directory;
4) Valid users = Ops1,opsadmin: Allows access to the shared user;
5) Invalid users = **,**: Disable access to the shared user;
6) Write list = Ops1: Allows the user to write to the share;
7) public = No | Yes: Allow anonymous access, with guest OK
8) Directory mask = 0755: The default permission to upload directories;
9) Create mask = 0644: The default permission to upload files;
This article from "10,000 years too long, seize" blog, please be sure to keep this source http://zengwj1949.blog.51cto.com/10747365/1930733
Samba file sharing for Linux