How to build a Samba file server used in combination with a Windows client?

Source: Internet
Author: User

How to build a Samba file server used in combination with a Windows client?

According to the Samba project website, Samba is an open-source/free software suite that provides seamless and smooth file and print services for SMB/CIFS clients. Unlike other systems that implement SMB/CIFS network protocols such as HP-UX-oriented LM Server, OS/2-oriented LAN Server or VisionFS), Samba and its source code) you can get the end user free of charge without any fees), and allow the Linux/Unix server and Windows/Unix/Linux client to run collaboratively.

For these reasons, different operating systems are not just Linux, samba is the preferred solution for file servers-the most common network architecture is that multiple Microsoft Windows clients access a Linux server with Samba installed. We will discuss this situation in this article.

Note: On the other hand, if our network is completely composed of Unix-based clients, such as Linux, AIX, or Solaris, you can consider using NFS, But Samba is still an option in this case). At this time, NFS is faster.

Install Samba On Debian and CentOS

Before starting the installation, you can use the software package management system of the operating system to find information about Samba:

On Debian:

 
 
  1. # aptitude show samba 

On CentOS:

 
 
  1. # yum info samba 

On the screen below, we can see that the output result "yum info samba" of "aptitude show samba" will get a similar result ):

Now, you may want to install the screen below Samba, which corresponds to the installation on the Debian 7 [Wheezy] server ):

On Debian:

 
 
  1. # aptitude install samba 

On CentOS:

 
 
  1. # yum install samba 

Add a user to Samba

For versions earlier than 4.x, you need a local Unix account to add users to Samba:

 
 
  1. # adduser <username> 

Next, we need to use the smbpasswd command with the "-a" option to add the user to Samba. This option specifies that the user name should be added to the local smbpasswd file. The system will prompt us to enter a password, which is not necessary to be the same as the password of the Local Unix account ):

 
 
  1. # smbpassword -a <username> 

Finally, we grant the xmodulo user the permission to access a directory in the system used as the Samba shared area to grant the access permission to other users if needed ). To complete this step, you only need to use the file editor such as Vim to open/etc/samba/smb. conf file, browse to the end of the file, use a descriptive name, create a code section to enclose the name in square brackets), such as [xmodulo]:

 
 
  1. # SAMBA SHARE  

  2. [xmodulo]  

  3. path = /home/xmodulo  

  4. available = yes 

  5. valid users = xmodulo 

  6. read only = no 

  7. browseable = yes 

  8. public = yes 

  9. writeable = yes 

Now we must restart Samba. In case of any errors, run the testparm command to check the smb. conf file:

 
 
  1. # service samba restart  

  2. # testparm 

 

If there are any errors, after testparm is finished running, it will be truthfully reported.

Map a Samba shared area to a network drive on a Windows 7 PC

Right-click the Computer) and select Map network drive to Map the network drive ):

Enter the IP address of the machine on which Samba is installed, and then enter the name of the shared area. This is smb. in the conf file, the name is enclosed in single brackets), and make sure that the "Connect using different credentials" uses different logon materials to Connect) check box has been selected:

Enter the user name and password previously set with "smbpasswd-:

To the Computer), check whether the network drive has been correctly added:

To test this, create a PDF file on the Samba reference manual page and save it to the/home/xmodulo directory:

Next, we can verify that the file can be accessed from Windows:

We can use the default pdf reading software to open this file:

Finally, let's see if we can save a file from Windows to the newly mapped network drive. We will open the change. log file, which lists the features of Notepad ++:

After all, try to save the file as a plaintext file. txt extension) to Z: \. Then, check whether the file can be viewed in Linux:

Enable quota

Step 1: Check whether the current kernel has been compiled and supports the quota:

 
 
  1. # cat /boot/config-$(uname -r) | grep -i config_quota 

Each file system can have up to five quota restrictions: User soft limit, user hard limit, user group soft limit, user group hard limit, and grace time.

Now we will enable the quota for the/home file system, so in the/etc/fstab file corresponding to the/home file system line, add the usrquota and kgquota mounting options to the existing ults option. To make the change take effect, we will re-mount the file system:

Next, we need to create two files in/home, which will act as the database for user quota and user group quota: aquota. user and aquota. group. Then, we will create the current disk usage table for the quota-enabled File System:

 
 
  1. # quotacheck -cug /home  

  2. # quotacheck -avugm 

Although we have enabled quotas for the/home file system, we have not set any limits for any users or user groups. Check the quota information of existing users/user groups:

 
 
  1. # quota -u <username> 

  2. # quota -g <groupname> 

The last few steps include: Use the quotatool command to specify a quota for each user and/or user group. Note: You can use edquota to execute this task, but quotatool is more intuitive and simple, ).

To set the soft limit to 4 MB for a user named xmodulo and the hard limit to 5 MB, set the soft and hard limits to 10 MB and 15 MB for the xmodulo user group respectively:

 
 
  1. # quotatool -u xmodulo -bq 4M -l '5 Mb' /home  
  2. # quotatool -g xmodulo -bq 10M -l '15 Mb' /home 

In Windows 7, we can see that 3.98MB of result 4.00MB is idle ):

Http://xmodulo.com/2014/08/samba-file-server-windows-clients.html:

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.