Last updated on November 25, 2020 by Gabriel Cánepa
Samba is an open source/free software suite that provides seamless file and print services to SMB/CIFS clients. Unlike other implementations of the SMB/CIFS networking protocol (such as LM Server for HP-UX, LAN Server for OS/2, or VisionFS), Samba (along with its source code) is freely available (at no cost to the end user), and allows for interoperability between Linux/Unix servers and Windows/Unix/Linux clients.
For these reasons, Samba is the preferred solution for a file server in networks where different operating systems (other than Linux) coexist — the most common setup being the case of multiple Microsoft Windows clients accessing a Linux server where Samba is installed, which is the situation we are going to deal with in this article.
Please note that, on the other hand, if our network consists of only Unix-based clients (such as Linux, AIX, or Solaris, to name a few examples), we can consider using NFS (although Samba is still an option in this case), which has greater reported speeds.
Before we proceed with the installation, we can use our operating system's package management system to look for information about Samba:
On Ubuntu or Debian:
# aptitude show samba
On CentOS:
# yum info samba
In the following screenshot we can see the output of aptitude show samba
(yum info samba
yields similar results):
Now let's install Samba (the screenshot below corresponds to the installation on a Debian 7 [Wheezy] server)
On Debian:
# aptitude install samba
On CentOS:
# yum install samba
For versions earlier than 4.x, a local Unix account is required for adding users to Samba:
# adduser -s /dev/null -m -d /home/<username> <username>
Next, we need to add the user to Samba using the smbpasswd
command with the -a
option, which specifies that the username following should be added to the local smbpasswd file. We will be prompted to enter a password (which does not necessarily have to be the same as the password of the local Unix account):
# smbpassword -a <username>
Finally, we will give access to user xmodulo to a directory within our system that will be used as a Samba share for him (and other users as well, if needed). This is done by opening the /etc/samba/smb.conf
file with a text editor (such as Vim
), navigating to the end of the file, and creating a section (enclose name between square brackets) with a descriptive name, such as [xmodulo]:
# SAMBA SHARE [xmodulo] path = /home/xmodulo available = yes valid users = xmodulo read only = no browseable = yes public = yes writeable = yes
We must now restart Samba and -just in case- check the smb.conf file for syntax errors with the testparm
command:
# service samba restart # testparm
If there are any errors, they will be reported when testparm
ends.
Right click on Computer, and select Map network drive
:
Type the IP address of the machine where Samba is installed, followed by the name of the share (this is the name that is enclosed between single brackets in the smb.conf file), and make sure that the Connect using different credentials
checkbox is checked:
Enter the username and password that were set with smbpasswd -a
earlier:
Go to Computer and check if the network drive has been added correctly:
As a test, let's create a pdf file from the man page of Samba, and save it in the /home/xmodulo
directory:
Next, we can verify that the file is accessible from Windows:
And we can open it using our default pdf reader:
Finally, let's see if we can save a file from Windows in our newly mapped network drive. We will open the change.log file that lists the features of Notepad++:
and try to save it in Z: as a plain text file (.txt extension); then let's see if the file is visible in Linux:
As a first step, we need to verify whether the current kernel has been compiled with quota support:
# cat /boot/config-$(uname -r) | grep -i config_quota
Each file system has up to five types of quota limits that can be enforced on it: user soft limit, user hard limit, group soft limit, 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 that corresponds to the /home
filesystem in the /etc/fstab
file, and we will remount the file system in order to apply the changes:
Next, we need to create two files that will serve as the databases for user and group quotas: aquota.user
and aquota.group
, respectively, in /home
. Then, we will generate the table of current disk usage per file system with quotas enabled:
# quotacheck -cug /home # quotacheck -avugm
Even though we have enabled quotas for the /home
file system, we have not yet set any limits for any user or group. Check for quota information for existing user/group:
# quota -u <username> # quota -g <groupname>
Finally, the last couple of steps consist of assigning the quotas per user and / or group with the quotatool
command (note that this task can also be performed by using edquota
, but quotatool
is more straightforward and less error-prone).
To set the soft limits to 4 MB and the hard limit to 5 MB for xmodulo
user, and 10 MB / 15 MB for the xmodulo
group:
# quotatool -u xmodulo -bq 4M -l '5 Mb' /home # quotatool -g xmodulo -bq 10M -l '15 Mb' /home
And we can see the results in Windows 7 (3.98 MB free of 4.00 MB):
This website is made possible by minimal ads and your gracious donation via PayPal or credit card
Please note that this article is published by Xmodulo.com under a Creative Commons Attribution-ShareAlike 3.0 Unported License. If you would like to use the whole or any part of this article, you need to cite this web page at Xmodulo.com as the original source.
Xmodulo © 2021 ‒ About ‒ Write for Us ‒ Feed ‒ Powered by DigitalOcean