Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to build a Samba file server for use with Windows clients

2025-01-20 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

Xiaobian to share with you how to build a Samba file server used in conjunction with Windows clients, I hope you have something to gain after reading this article, let's discuss it together!

Samba is an open source/free software suite that provides seamless file and print services for SMB/CIFS clients, according to the Samba project website. Unlike other systems that implement SMB/CIFS networking protocols (such as LM Server for HP-UX, LAN Server for OS/2, or VisionFS), Samba (and its source code) is freely available (end users pay nothing) and allows interoperability between Linux/Unix servers and Windows/Unix/Linux clients.

It is for these reasons that Samba is the preferred solution for file servers in network environments where different operating systems (not just Linux) coexist--and the most common network architecture is multiple Microsoft Windows clients accessing a Linux server with Samba installed, which we explore in this article.

Note: On the other hand, if our network consists entirely of Unix-based clients (Linux, AIX, Solaris, etc.), consider using NFS (although Samba is still an option in this case), which is faster.

Install Samba on Debian and CentOS

Before we start installing, we can use the operating system's package management system to find information about Samba:

On Debian:

# aptitude show samba

On CentOS:

# yum info samba

In the screenshot below, we can see the output of "aptitude show samba"("yum info samba" would give a similar result):

Samba may now be installed (the screenshot below corresponds to installation on a Debian 7 [Wheezy] server):

On Debian:

# aptitude install samba

On CentOS:

# yum install samba

Adding Users to Samba

Before 4.x, you need a local Unix account to add users to Samba:

# adduser

Next, we need to add the user to Samba using the smbpasswd command with the "-a" option, which specifies that the user name should then be added to the local smbpasswd file. We are prompted for a password (which does not have to be the same as the local Unix account password):

# smbpassword -a

***, we grant user xmodulo access to a directory on the system used as a Samba share (and other users if desired). To do this, simply open the/etc/samba/smb.conf file with a file editor (such as Vim), browse to the end of the file, and create a code with a descriptive name (enclosed in square brackets), such as [xmodulo]:

# SAMBA SHARE [xmodulo] path = /home/xmodulo available = yes valid users = xmodulo read only = no browseable = yes public = yes writeable = yes

Now we have to restart Samba; just in case, check the smb.conf file for syntax errors using testparm:

# service samba restart # testparm

If there is an error, testparm will report it when it finishes running.

Map Samba shares to network drives on Windows 7 PCs

Right-click Computer and select Map network drive:

Type the IP address of the machine on which Samba is installed, then type the name of the share (this is the name scratched in single parenthesis in the smb.conf file), and make sure the "Connect using different credentials" checkbox is checked:

Enter the username and password previously set with "smbpasswd -a":

Go to Computer and check that the network drive has been added correctly:

To test it out, create a PDF file using Samba's reference man page and save it in the/home/xmodulo directory:

Next, we can verify that the file is accessible from Windows:

We can open the file using the default pdf reader:

*** Let's see if we can save a file from Windows to the network drive we just mapped. We'll open the change.log file, which lists the features of Notepad++:

Then try saving it to Z:\as a plaintext file (.txt extension) and see if the file can be browsed in Linux:

enable quotas

*** Step, we need to verify whether the current kernel has been compiled and supports quotas:

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

Up to five quota limits can be enforced per file system: user soft limit, user hard limit, user group soft limit, user group hard limit, and grace time.

We will now enable quotas for the/home file system by adding the usrquota and grpquota mount options to the existing defaults option in the line corresponding to the/home file system in the/etc/fstab file; for the changes to take effect, we will remount the file system:

Next, we need to create two files in/home that will act as databases for user quotas and user group quotas: aquota.user and aquota.group, respectively. We will then create a current disk usage table for quota-enabled file systems:

# quotacheck -cug /home # quotacheck -avugm

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

# quota -u # quota -g

***, the next few steps include: using the quotatool command to specify quotas for each user and/or each user group (note: edquota can be used to perform this task, but quotatool is more intuitive and less error-prone).

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

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

We can see the results in Windows 7 (3.98MB idle out of 4.00MB):

After reading this article, I believe you have a certain understanding of "how to build a Samba file server used in combination with Windows clients." If you want to know more about this knowledge, please pay attention to the industry information channel. Thank you for reading!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report