Configure Samba in RedHat5 to implement file exchange between Windows and Linux

Source: Internet
Author: User
Tags pkill
1 Samba introduction Samba (SMB) is a network server used for sharing files between Linux and Windows. Samba can be used for sharing files between Windows and Linux, it is also used for file sharing between Linux and Linux. However, for file sharing between Linux and Linux, the Network File System NFS is better, and NFS also needs to set up servers; we all know that each machine in the Windows network can be a file sharing server or 1 Samba Introduction

Samba (SMB) is a network server used for sharing files between Linux and Windows. Samba can be used for sharing files between Windows and Linux, it is also used for file sharing between Linux and Linux. However, for file sharing between Linux and Linux, the Network File System NFS is better, and NFS also needs to set up servers;
Everyone knows that each machine in the Windows network can be a file sharing server or a client;

Samba works the same way. For example, if a Linux machine is installed with the Samba Server, it can act as a shared Server and can also be used as a client to Access Windows shared file systems in other networks, or other Linux Sabmba servers;

In Windows network, we can see the shared file function, we can directly use the shared folder as a local hard disk. In Linux, Samba is used to provide a shared file system to machines on the network. It can also be used to mount the sharing of other machines on the local machine; in a sense, this is different from FTP. Samba uses the netbios protocol. If Samba fails to be used, Linux and Windows, Linux, and Linux.

2 Samba functions and application scope
Samba should be mainly used in networks where Windows and Linux systems coexist. If a network environment is a Linux or Unix system, it is better to use NFS if Samba is not necessary; so what services does Samba provide for us? Sharing Files and printers;

3. samba Installation
3.1 check whether the samba function component is installed in the system
# Rpm-qa | grep samba
Samba-common-3.0.10-1.4E.Array
Samba-client-3.0.10-1.4E.Array
Samba-3.0.10-1.4E.Array
System-config-samba-1.2.21-1
If no installation is available, you can download it at the following link.
Download http://download.Fedora.RedHat.com/pub/fedora/linux/core/development/i386/Fedora/RPMS/
Samba-3.0.3-5.i386.rpm, samba-client-3.0.3-5.i386.rpm and samba-common-3.0.3-5.i386.rpm
Three rpm packages.
NOTE: If samba is successfully installed, a "smb" shell script file will be installed in the "/etc/rc. d/init. d" directory.

Run the "chkconfig -- list" command to check whether the smb service is in the system service list.

If not, use "chkconfig -- add smb" to add the smb service.

Use the "chkconfig -- level 35 smb on" command to open the samba service at the third and fifth running levels (it does not matter if you do not know the specific details ). In this way, the samba service is automatically enabled every time the system restarts.
Prepare your/etc/samba/smb. conf file. Here is my smb. conf example:
[Global]

Workgroup = WORKGROUP. View it by yourself)

Server string = My-Serv

Netbios name = My-Serv

Max log size = 50

Security = share

[Chinafu]
Path = chinafu // note that a chinafu folder must be created under the root directory.

Comment = This is my samba server (This is a comment line and can be left empty)

Writeable = yes

Browseable = yes

Guest OK = yes

Read only = yes

Create mode = 0664 (this is the File Permission)

Directory mode = 0777 (this is the directory permission)

Note:
[Global] This section is a global configuration and is required. There are the following rows;
Workgroup is the working group displayed in Windows. Here I set WORKGROUP (in upper case );
Netbios name is the name of the computer displayed in Windows;
Server string is the description of the Samba server, which can be defined by yourself. This is not important;
Security is the authentication and login method. Here we use share. There are many authentication methods, one of which is also commonly used as the user authentication method. If share is used, you do not need to set the user and password;
[Chinafu] the shared directory is displayed in Windows;
Path = You can set where the directory to be shared is stored;
Whether writeable can be written. Here I set it to writable;
Whether browseable can be viewed or not. If browsed, we can see shared folders under the Working Group. If you do not want to display it, set it to browseable = no.
Guest OK anonymous users log on as guest;

3.2 run "testparm" to check whether the smb. conf file is incorrect.

3.3 view the port and firewall of the Samba server;
Make sure that the system's Firewall does not prohibit samba file sharing.
How can this be used? Sometimes your firewall may block the port of the smbd server, so we should use the port occupied by the smbd server. In the following view, we know that the ports occupied by smbd are 13Array and 445;
[Root @ localhost ~] # Netstat-tlnp | grep smb
Tcp 0 0 0.0.0.0: 13 Array 0.0.0.0: * LISTEN 1063 Array/smbd
Tcp 0 0 0.0.0.0: 445 0.0.0.0: * LISTEN 1063 Array/smbd
If you have a firewall, you must open these two ports. If you do not know how to open it. Maybe you are a newbie like me, or clear firewall rules;
[Root @ localhost ~] # Iptables-F
Or
[Root @ localhost ~] #/Sbin/iptables-F

3.4 run "service smb restart" to restart samba.

3.5WINDOWS access

First, your PC must be in the "Workgroup" group.Workgroup = WORKGROUPDetermined.
Open My Network Places under My Computer. Under "Workgroup", you should find My-Serv.
Map "L:" drive
[Url = file: // % 5c % 5cmy-serv % 5 chomes/]\ My-Serv \ chinafu[/Url]
[Url = file: // % 5c % 5cmy-serv % 5 chomes/] from now on, you will be able to share files between Linux and Windows. [/Url]
[Url = file: // % 5c % 5cmy-serv % 5 chomes/] While nmb is used for parsing, what is parsed? Is to shareWorking GroupAndNetbios nameResolved; [/url]
In general, in the RPM package system, if Samba is installed in the RPM package, you can generally start the Samba server in the following ways;
[Root @ localhost ~] #/Etc/init. d/smb start
Start the SMB service: [OK]
Start NMB service: [OK]
What if it stops? Add stop after smb; restart is restart
[Root @ localhost ~] #/Etc/init. d/smb stop
[Root @ localhost ~] #/Etc/init. d/smb restart
For all systems, the common method is to run smb and nmb directly. Of course, you need to know the directory where smb and nmb are located. If Samba is compiled by yourself, you should know where you put Samba;
[Root @ localhost ~] #/Usr/sbin/smbd
[Root @ localhost ~] #/Usr/sbin/nmbd
Run the following command to check whether the server is running;
[Root @ localhost ~] # Pgrep smbd
[Root @ localhost ~] # Pgrep nmbd
To disable the Samba server, you can also use the following methods, which are mostly common. You need the root permission to execute them;
[Root @ localhost ~] # Pkill smbd
[Root @ localhost ~] # Pkill nmbd

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.