To enable the sharing of resources between Windows hosts and Linux servers, the Linux operating system provides samba services, and the Samba service bridges two different operating systems, enabling communication between Linux and Windows systems.
1. Service Enquiry
By default, the Linux system already has part of the Samba service pack installed in the default installation, and in order to have a complete understanding of the process, uninstall this section first.
Command:
Rpm-qa | grep samba
Execution Result: (by default, the following two existing packages can be queried)
Samba-client-3.0.33-3.7.el5
Samba-common-3.0.33-3.7.el5
2. Uninstalling Samba
Use RPM-E to unload two packages. For Samba-common-3.0.33-3.7.el5, because there is a dependency between the other RPM packages, the parameter-F and--nodeps,-f are mandatory, and--nodeps refers to not checking for dependencies.
Command:
rpm-e samba-common-3.0.33-3.7.el5-f--nodeps
rpm-e samba-client-3.0.33-3.7.el5-f--nodeps
3. Install Samba
Command:
apt-get Install samba System-config-samba samba-client Samba-common
After the installation is complete, use the command: RPM-QA | grep Samba queries and finds that all the servers on which the Samba server is built are already installed.
4. Configuring the Smb.conf file
Samba profiles are typically placed in the/etc/samba directory, The main configuration file named Smb.conf, which records a large number of rules and shared information, is a core configuration file that is very important to samba services, and most of the major configurations that complete the Samba server Setup are in this file.
The Samba server works by initiating a request to the Samba server, requesting access to the shared directory, and the Samba server receiving the request, Query the smb.conf file, see if the shared directory exists, and the access rights of the visitor, if the visitor has the appropriate permissions, allow the client access, and finally the system information during the access process and the user Access behavior information collected in the log file.
First step: Modify the configuration file
First, backup the Samba configuration file
Command:
Cd/etc/samba
MV smb.conf Smb.confbak
Then re-create a smb.conf file
Command:
Touch smb.conf
Then write to smb.conf in the following section
[Global]
workgroup = Workgrpup
NetBIOS name = Admin
Server string = Linux Samba server TestServer
Security = Share
[Sharedir]
Path =/home/sharedir
writeable = yes
browseable = yes
Guest OK = yes
Annotations:
[Global] This is the global configuration, is required to write the paragraph. which have the following lines;
Workgroup is the workgroup that is displayed in Windows (assigned values based on your computer configuration)
NetBIOS name is the name of the computer that is displayed in Windows (according to your Computer Configuration assignment)
Server string is the Samba server description that can be defined by itself; this is not important;
Security This is the authentication and login method, here we use share; there are many kinds of authentication methods, this is one of them; another commonly used is the user authentication method, if using share, it is not necessary to set the user and password;
[Sharedir] This is displayed in Windows is a shared directory;
path can set where the directory to be shared is placed;
whether writeable can be written, here I set as writable;
whether browseable can be browsed, can be browsed means that we can see the shared folder under the workgroup. If you don't want to show it, set it to Browseable=no
Guest OK anonymous user is logged in as guest;
The second step: the establishment of the corresponding directory and authorization;
Command:
[email protected] ~]# mkdir-p/home/sharedir
[[email protected] ~]# ID nobody
uid=99 (nobody) gid=99 (nobody) groups=99 (nobody)
[email protected] ~]# chown-r nobody:nobody/home/sharedir
Comments:
regarding the authorization nobody, we first use the ID command to view the nobody user's information, discovers his user group also nobody, we must take this as the prevail. Some systems nobody user groups are not nobody;
Step three: Start SMBD and NMBD server;
[[Email protected] ~]# service SMB restart
Linux Configuration Samba Service