Samba Linux Test Configuration File Command

Posted on

This is another article discuss on testing samba configuration file. To be able to change the original samba file configuration, it is a wise decision if the step executed for the first time is backup the original file by duplicating it into another file.

After duplicating the file into another file name, the original file of samba configuration can be edited. Below is the process of executing it :

root@hostname:~# cp /etc/samba/smb.conf /etc/samba/smb.conf.ori
root@hostname:~#

Description : 

cp : It is the command used to copy file from certain location into another location or if the location of the source and destination are the smae, it can also be used to create or duplicate another file with another name. 
/etc/samba/smb.conf : It is the original samba configuration file. The location is in /etc/samba and the name of the file is smb.conf. In this context, it is the source parameter of cp command
/etc/samba/smb.conf.ori : It is the duplicate of the samba configuration file. Since it is a duplicate, the name needs to be adjusted so that it has a different name since the location is actually the same. In this context, the file name which is chosen is smb.conf.ori

After duplicating samba file configuration, the next step is to edit the samba file configuration to be suited with the need which has been defined. If the edited samba file configuration later on is used by samba service and turns out the service failed to use it because of the wrong entry, the original samba file configuration can still be used which is the smb.conf.ori samba file configuration.

Before using the edited samba file configuration, it can be tested before it is going to be implemented. The testing process can be done by executing a specific tool or command. That tool executed as a command in a command line is ‘testparm’. Below is an example of the execution command :

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


[printers]
comment = All Printers
path = /var/spool/samba
create mask = 0700
printable = Yes
browseable = No


[print$]
comment = Printer Drivers
path = /var/lib/samba/printers
root@hostname:~#

From the above output of command execution trying to figure out whether the edited samba file configuration has a misstyped entry using ‘testparm’, turns out there is no problem at all.

So, in order to activate the samba service using the edited samba file configuration just restart the samba service :

root@hostname:~# systemctl restart smbd
root@hostname:~#

Leave a Reply