Share folders between Ubuntu systems and Win7 systems using Samba servers

Source: Internet
Author: User

1 Introduction

Now is the era of networking, each of us to better development, inseparable from the network, information-based support. It is a necessary skill for computer majors to use the support of network to share information among different operating systems. This article is about how to set up, set up, link Samba server, so that in the network of two computers, one is installed Ubuntu operating system, one is installed Win7, through the form of shared folders to share information. The location and network architecture of the two computers on the network are shown in Figure 1.


in the figure1of the two computers actually their physical location is next to me, just because of the physicalRJ47There are too few ports to have the desktop connected toRj47port, and my laptop is connected to the network via a wireless router. In order to facilitate the exchange of files and information between the two computers, I would like to share folders to achieve this function. If both computers areWindowssystem words good to do but now one isUbuntusystem, aWin7system, how to implement the function of shared folders? in the reference literature[1]based on the use ofSambaserver, I have successfully implemented this feature. Please see the detailed description below.

2 Creating and configuring a Samba server

Because of the need to share folders between Ubuntu systems and Win7 systems on the web, and the Samba server as a server that supports the ability to interact with Windows system files on Ubuntu systems, the idea is to create a Samba server on the desktop, The Win7 system accesses the shared folder on the server as a client, which is the folder on the Utuntu system. Samba, which appeared in 1992, was originally designed to facilitate the sharing of files between UNIX systems and Windows systems, but was not limited to this, but also supported the interactive sharing of files between different systems, such as Ubuntu for Ubuntu,mac OS to Mac OS and so on.

2.1 Installing the Samba server

If you are using Ubuntu Server distribution, it will be preinstalled, and you can skip this step and go directly to the next step. If you're using an ordinary Ubuntu distribution, it's not installed by itself and requires you to install Samba first. You can install Samba graphically from Ubuntu Software Center, or you can install it as a terminal command. The following commands are installed in the terminal mode:
sudo apt-get install Samba
sudo apt-get install Smbfs

2.2 Identify a folder to share on the Ubuntu system

This folder can be a pre-existing folder. If you want to keep the shared folder from being confused with your other folders, it's a good idea to create a separate folder to use as a share. Create the folder you want to share with the following Terminal command and give it permission to read and write:
sudo mkdir/home/share
sudo chmod 777/home/share

2.3 Edit smb.conf File

In order for other computers on the network to access the Samba server as a client, the first thing you do is configure the/etc/samba/smb.conf file. This configuration file is similar to the INI file under Windows, which makes it easier for managers to configure information about the server. Please follow the steps below:

1. Open the smb.conf file with an editor. Because the file requires permissions to be modified, do not use the direct click of the way to open, it is best to use the command sudo vim/etc/samba/smb.conf or sudo gedit/etc/samba/smb.conf way to open.

2. Locate [global] below to Workgroup = Workgroup in front of the semicolon (the;) is removed (the semicolon is preceded by a comment), and after it is added, the content is eventually changed to

Workgroup = Workgroup
Display CharSet = UTF-8
Unix CharSet = UTF-8
DOS charset = cp936

3. Locate the security = User line, remove the semicolon in front of it, and add the content after it, eventually becoming:
Security = User
Username map =/etc/samba/smbusers

4. Add the folder you want to share to the Samba server and specify which users are allowed to access it. This is done by adding the following at the end of the file (of course, you can also set it up by using the graphical Samba Configuration Manager, which is automatically reflected in this file). ):
[Share] The name to be shared under the//windows system
Comment = Test whether the method is good//note that you use to share added comments that can provide the purpose of sharing
Path =/home/share//Previous steps set up on Ubuntu system for shared folders
Public = yes
writeable = yes
Valid users = Chgzhi//user accessing the Samba server, but it must be an Ubuntu user, and must also be a separate password from the Ubuntu system you can make them consistent.
Create mask = 0700
Directory mask = 0700
force user = Nobody
Force Group = Nogroup
Available = yes
browseable = yes

5. Save and exit the editing process for the file.

2.4 Defining access passwords for Samba users

Note that users of an Ubuntu system that are already legally present can be users of the Samba server. Now assume that your Ubuntu system already has a user Chgzhi, which is exactly the user we set in the previous section (Valid users = Chgzhi). What we want to do now is to change the user to set the corresponding password, if it is the initial password set with the following command:

sudo Smbpasswd-achgzhi
If you have previously set this password, remove the parameter a.

2.5 Restarting the Samba server

Since the server has just been reconfigured, we'd better restart the server at this point, using the following command:
sudo service smbd restart

3 Shutting down the firewall

Because Ubuntu system is in the server position, so we just need to turn off the Ubuntu system firewall, for the WIN7 system firewall does not need to shut down. The command is as follows:
sudo ufw disable
At this point, the server side of the work we need to do is finished, the next is to use the client connection to share the folder.

4 Client connections

4.1 Smbclient client Program

This is a client command-line program that comes with a Samba server program that supports access to another Ubuntu system that has samba installed. Here we use it to test whether the server we just established is successful. As shown in 2. We are only testing this machine, and we are not using another computer to connect to the Samba server. As can be seen in Figure 2, we are connected successfully and entered the client interactive command prompt (SMB: \>), there are various commands available for you to use, see table 22-2 of page No. 535 of the literature [1]. The password you entered in the figure is the one you used to set up the password in section 2.4. I am already enjoying the convenience of sharing folders, Figure 2 is on the desktop Buntu system, and through the shared folder allows Win7 system access, and this writing is performed on the Win7 system.


Figure 2 Smbclient client program sample

4.2 Using the Win7 system to connect to the Samba server as a client

The process of accessing the shared folders set up on an Ubuntu computer is simple and does not require any client programs to be transferred to a notebook with a Win7 system installed.

1. Click MyComputer to appear in Figure 3, then click on Map Network Drive in the figure, then the Figure 4 appears.


2. In the folder text box in Figure 4, enter the IP address of the Ubuntu machine and the shared folder name share. Click Finish to appear in Figure 5.

Figure 4 Win7 Connection schematic

3. Enter your Samba account in Figure 5, which is created in section 2.4, click the OK button. The exciting moment arrived, the connection succeeded, 6. You can freely share files between two different operating systems, enjoy the results of networking!


Figure 5 Win7 Connection---Enter Samba user name and password


Figure 6 The shared folder of the Samba server that is connected under the WIN7 system share

5 Summary

This article describes how to set up shared folders, which requires the reader to have basic knowledge of Ubuntu usage, especially the use of terminal under Bash shell. [1] The introduction of basic methods of use of Ubuntu system, recommended books. The book is similar to the university freshman enrollment in the computer Culture Fundamentals course for Windows systems, but more practical. I believe that the method described in this article is only a method, there must be a better way to share folders. If any reader has a better way, please enlighten me.

References
[1] Richard Blum. Ubuntu Linux Secrets. Wiley, Indianapolis, in, 2009.

Share folders between Ubuntu systems and Win7 systems using Samba servers

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.