After successfully installing samba as a file and printer sharing tools which is provided in Linux operating system distribution, it needs to be configured further so that it can provide a file sharing that can be accessed from another host even with different operating system such as Windows for example.
1. Create the folder which is going to be used for file sharing by using a command or any kind of utility. For an example :
mkdir folder_name mkdir : it is a command which is used to create a new directory. folder_name : the name of the folder or directory which is going to be created by using the 'mkdir' command.
The sample output of the command shown below :
user@hostname:~$ mkdir share user@hostname:~$
2. In order to be able to configure samba, it needs special or highest level privilege, so change to ‘root’ by executing this command to accomplish the purpose :
sudo su -
Below is the execution of the command in a bash prompt :
user@hostname:~$ sudo su - [sudo] password for user: root@hostname:~#
3. Add an additional configuration to samba file configuration which exist in the following location : /etc/samba/smb.conf. But, first of all in order to be able to keep the original samba file configuration in case that the new configured samba file cannot be used, backup the original samba file configuration by executing the following command in the bash prompt :
root@hostname:~# cp /etc/samba/smb.conf /etc/samba/smb.conf.ori
4. This is the additional content which is needed to be added in order to define a new file sharing resource. Edit the file smb.conf located in the /etc/samba with a text-editor, in the case of this article, it is using vim :
vim /etc/samba/smb.conf
Add the following line accordingly to the Share Definitions section represent with the following line :
#======================= Share Definitions =======================
This is the entry of the new sharing definition which is going to be used :
[share] path = /home/user/share guest ok = yes read only = no create mask = 0700 [share] : it is the shared name definition of the file sharing path : variable used to define the value of the folder or directory which is going to be shared /home/user/share : it is the value of path variable, in the above it acts as an example of folder or directory path which is going to be shared. guest ok : variable used to define whether a guest user can access the file sharing yes : it is the value of the guest ok variable, it means it allow guest to access the file sharing create mask : it is the variable which is defining the permission to mask against the assigned permission for a newly created file from Windows operating system when it is created from Windows client. 0700 : it is the bit mask value which is the value of the create mask variable.
5. Test the file configuration which has already modified by executing the following command :
testparm
Below is the above command executed in the bash prompt :
root@hostname:~# testparm Load smb config files from /etc/samba/smb.conf rlimit_max: increasing rlimit_max (1024) to minimum Windows limit (16384) WARNING: The "syslog" option is deprecated Processing section "[printers]" Processing section "[print$]" Loaded services file OK. Server role: ROLE_STANDALONE Press enter to see a dump of your service definitions # Global parameters [global] server string = %h server (Samba, Ubuntu) server role = standalone server map to guest = Bad User obey pam restrictions = Yes pam password change = Yes passwd program = /usr/bin/passwd %u passwd chat = *Enter\snew\s*\spassword:* %n\n *Retype\snew\s*\spassword:* %n\n *password\supdated\ssuccessfully* . unix password sync = Yes syslog = 0 log file = /var/log/samba/log.%m max log size = 1000 dns proxy = No usershare allow guests = Yes panic action = /usr/share/samba/panic-action %d idmap config * : backend = tdb [share] path = /home/user/share read only = No create mask = 0700 guest ok = Yes [printers] comment = All Printers path = /var/spool/samba create mask = 0700 printable = Yes browseable = No [print$] comment = Printer Drivers path = /var/lib/samba/printers
6. Soon as the share definition is redisplayed in the ‘testparm’ command which means it has already been calculated as a new added file sharing definition, restart samba service by execute the following command :
service smbd restart
This is the output of the command executed in the bash prompt :
root@hostname:~# service smbd restart
7. Use samba client tools to explore the already configured file sharing by executing the following command :
smbclient -L //xxx.xxx.xxx.xxx/share smbclient : it is a command used to -L : additional parameter which is used to List the share folder exist within the host or server specified by the IP address. //xxx.xxx.xxx.xxx/share : IP address of the host and also the share name which is going to be accessed for folder and files inside the sharing.
Below is the output of the command above which is executed in the bash prompt :
root@hostname:~# smbclient -L //xxx.xxx.xxx.xxx/share WARNING: The "syslog" option is deprecated Domain=[WORKGROUP] OS=[Windows 6.1] Server=[Samba 4.3.9-Ubuntu] Sharename Type Comment --------- ---- ------- print$ Disk Printer Drivers IPC$ IPC IPC Service (primary server (Samba, Ubuntu)) Officejet-100-Mobile-L411 Printer HP Officejet 100 Mobile L411 HP_LaserJet_Professional_P1606dn Printer HP LaserJet Professional P1606dn Domain=[WORKGROUP] OS=[Windows 6.1] Server=[Samba 4.3.9-Ubuntu] Server Comment --------- ------- MARK-DELL39 mark-Dell39 server (Samba, Linux Mint) PRIMARY primary server (Samba, Ubuntu) Workgroup Master --------- ------- WORKGROUP OFFICE user@hostname:~#
3 thoughts on “Configure Samba for Windows File Sharing”