<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-GB">
	<id>https://wiki.2clever.uk/index.php?action=history&amp;feed=atom&amp;title=SMEServer_DB_Command</id>
	<title>SMEServer DB Command - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.2clever.uk/index.php?action=history&amp;feed=atom&amp;title=SMEServer_DB_Command"/>
	<link rel="alternate" type="text/html" href="https://wiki.2clever.uk/index.php?title=SMEServer_DB_Command&amp;action=history"/>
	<updated>2026-05-01T09:30:00Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.6</generator>
	<entry>
		<id>https://wiki.2clever.uk/index.php?title=SMEServer_DB_Command&amp;diff=108&amp;oldid=prev</id>
		<title>Rdswikiadmin: Created page with &quot;copied from; https://wiki.koozali.org/Db_command_tutorial#Signal-event (This page was last edited on 5 March 2022, at 19:31.)  ==db command tutorial==  The &#039;&#039;&#039;db&#039;&#039;&#039; command is unique to SME Server, and is the command line user interface to the &#039;&#039;&#039;db system&#039;&#039;&#039;. It is used to manipulate configuration setting of the various configuration databases which are then incorporated into the standard configuration files in /etc/.... via the template expansion process.  The &#039;&#039;&#039;db sy...&quot;</title>
		<link rel="alternate" type="text/html" href="https://wiki.2clever.uk/index.php?title=SMEServer_DB_Command&amp;diff=108&amp;oldid=prev"/>
		<updated>2026-04-03T10:23:36Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;copied from; https://wiki.koozali.org/Db_command_tutorial#Signal-event (This page was last edited on 5 March 2022, at 19:31.)  ==db command tutorial==  The &amp;#039;&amp;#039;&amp;#039;db&amp;#039;&amp;#039;&amp;#039; command is unique to SME Server, and is the command line user interface to the &amp;#039;&amp;#039;&amp;#039;db system&amp;#039;&amp;#039;&amp;#039;. It is used to manipulate configuration setting of the various configuration databases which are then incorporated into the standard configuration files in /etc/.... via the template expansion process.  The &amp;#039;&amp;#039;&amp;#039;db sy...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;copied from; https://wiki.koozali.org/Db_command_tutorial#Signal-event (This page was last edited on 5 March 2022, at 19:31.)&lt;br /&gt;
&lt;br /&gt;
==db command tutorial==&lt;br /&gt;
&lt;br /&gt;
The &amp;#039;&amp;#039;&amp;#039;db&amp;#039;&amp;#039;&amp;#039; command is unique to SME Server, and is the command line user interface to the &amp;#039;&amp;#039;&amp;#039;db system&amp;#039;&amp;#039;&amp;#039;. It is used to manipulate configuration setting of the various configuration databases which are then incorporated into the standard configuration files in /etc/.... via the template expansion process.&lt;br /&gt;
&lt;br /&gt;
The &amp;#039;&amp;#039;&amp;#039;db system&amp;#039;&amp;#039;&amp;#039; comes with default values that can be manipulated by either manually through the CLI or fully automatic through the Server Manager. This tutorial explains manipulating the &amp;#039;&amp;#039;&amp;#039;db system&amp;#039;&amp;#039;&amp;#039; manually through the CLI.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To display the syntax issue the following command:&lt;br /&gt;
 /sbin/e-smith/db&lt;br /&gt;
which will result in the db help output below, for we did not pass any parameters.&lt;br /&gt;
 /sbin/e-smith/db dbfile keys&lt;br /&gt;
 /sbin/e-smith/db dbfile print [key]&lt;br /&gt;
 /sbin/e-smith/db dbfile show [key]&lt;br /&gt;
 /sbin/e-smith/db dbfile get key&lt;br /&gt;
 /sbin/e-smith/db dbfile set key type [prop1 val1] [prop2 val2] ...&lt;br /&gt;
 /sbin/e-smith/db dbfile setdefault key type [prop1 val1] [prop2 val2] ...&lt;br /&gt;
 /sbin/e-smith/db dbfile delete key&lt;br /&gt;
 /sbin/e-smith/db dbfile printtype [key]&lt;br /&gt;
 /sbin/e-smith/db dbfile gettype key&lt;br /&gt;
 /sbin/e-smith/db dbfile settype key type&lt;br /&gt;
 /sbin/e-smith/db dbfile printprop key [prop1] [prop2] [prop3] ...&lt;br /&gt;
 /sbin/e-smith/db dbfile getprop key prop&lt;br /&gt;
 /sbin/e-smith/db dbfile setprop key prop1 val1 [prop2 val2] [prop3 val3] ...&lt;br /&gt;
 /sbin/e-smith/db dbfile delprop key prop1 [prop2] [prop3] ...&lt;br /&gt;
&lt;br /&gt;
{{Note box|Note that on a properly setup SME Server (path wise) &amp;#039;&amp;#039;&amp;#039;you do not need&amp;#039;&amp;#039;&amp;#039; to include the&lt;br /&gt;
/sbin/e-smith/ part, &amp;#039;&amp;#039;&amp;#039;only use db or config&amp;#039;&amp;#039;&amp;#039; since you are in the Path of your environment}}&lt;br /&gt;
&lt;br /&gt;
===Only for the configuration database===&lt;br /&gt;
{{Note box| Use of &amp;#039;config&amp;#039; is a shorthand version for &amp;#039;db configuration&amp;#039; and therefore only works with the configuration database}}&lt;br /&gt;
 db configuration&lt;br /&gt;
is&lt;br /&gt;
 config&lt;br /&gt;
&lt;br /&gt;
Note this only applies to this one often used database file, all others must be referred to using the format&lt;br /&gt;
 db dbname command key [property value] [property2 value2]&lt;br /&gt;
&lt;br /&gt;
All database files are in&lt;br /&gt;
 /home/e-smith/db&lt;br /&gt;
&lt;br /&gt;
===Auto completion===&lt;br /&gt;
&lt;br /&gt;
Like in every Linux shell you can use the TAB key when you use the command line to auto complete or propose all available answers&lt;br /&gt;
&lt;br /&gt;
===Examples===&lt;br /&gt;
Here are a few examples to demonstrate usage and syntax correlation&lt;br /&gt;
 db dbname show&lt;br /&gt;
&lt;br /&gt;
Using real db names - for the database in /home/e-smith/db/configuration&lt;br /&gt;
 db configuration show&lt;br /&gt;
 db configuration show |less&lt;br /&gt;
 db configuration keys |less&lt;br /&gt;
&lt;br /&gt;
* An example for the imap service&lt;br /&gt;
 [root@sme8dev64 ~]# db configuration show imap&lt;br /&gt;
&lt;br /&gt;
 imap=service&lt;br /&gt;
    ConcurrencyLimit=400&lt;br /&gt;
    ConcurrencyLimitPerIP=12&lt;br /&gt;
    TCPPort=143&lt;br /&gt;
    access=private&lt;br /&gt;
    status=enabled&lt;br /&gt;
&lt;br /&gt;
we can retrieve a value&lt;br /&gt;
 [root@sme8dev64 ~]# db configuration getprop imap status&lt;br /&gt;
which gives something like&lt;br /&gt;
 enabled&lt;br /&gt;
&lt;br /&gt;
 [root@sme8dev64 ~]# db configuration getprop dansguardian ConcurrencyLimitPerIP&lt;br /&gt;
which gives something like&lt;br /&gt;
 12&lt;br /&gt;
&lt;br /&gt;
Compare the above displayed actual element values of the db command with the syntax result from issuing the db command where each element or piece equates to:&lt;br /&gt;
&lt;br /&gt;
===Keys/Properties/values===&lt;br /&gt;
&lt;br /&gt;
All turn around A key with properties and values of the properties, no more, no less. You can have a lot of properties under a key which is unique&lt;br /&gt;
&lt;br /&gt;
 imap=service&lt;br /&gt;
   ConcurrencyLimit=400&lt;br /&gt;
   ConcurrencyLimitPerIP=12&lt;br /&gt;
   TCPPort=143&lt;br /&gt;
   access=private&lt;br /&gt;
   status=enabled&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Database name !! Unique key !! Property name !! Default value || Possible values || Description&lt;br /&gt;
|-&lt;br /&gt;
| configuration ||style=&amp;quot;text-align:center;&amp;quot;| imap || ||style=&amp;quot;text-align:center;&amp;quot;|&amp;#039;&amp;#039;&amp;#039;service&amp;#039;&amp;#039;&amp;#039;|| || Unique key name&lt;br /&gt;
|-&lt;br /&gt;
| || || Concurrenstyle || style=&amp;quot;text-align:center;&amp;quot;|&amp;#039;&amp;#039;&amp;#039;400&amp;#039;&amp;#039;&amp;#039; || style=&amp;quot;text-align:center;&amp;quot;|nnn || User defined value&lt;br /&gt;
|-&lt;br /&gt;
| || || ConcurrencyLimitPerIP || style=&amp;quot;text-align:center;&amp;quot;|&amp;#039;&amp;#039;&amp;#039;12&amp;#039;&amp;#039;&amp;#039; || style=&amp;quot;text-align:center;&amp;quot;|nn || User defined value&lt;br /&gt;
|-&lt;br /&gt;
| || || TCPPort || style=&amp;quot;text-align:center;&amp;quot;|&amp;#039;&amp;#039;&amp;#039;143&amp;#039;&amp;#039;&amp;#039; || style=&amp;quot;text-align:center;&amp;quot;|nnn || TCP port or port range [nnn] or [nnn-nnn]&lt;br /&gt;
|-&lt;br /&gt;
| || || access || style=&amp;quot;text-align:center;&amp;quot;|&amp;#039;&amp;#039;&amp;#039;private&amp;#039;&amp;#039;&amp;#039; || style=&amp;quot;text-align:center;&amp;quot;|private / public || Specify LAN only or LAN and WAN access.&amp;lt;br&amp;gt; The firewall will be adjusted accordingly&lt;br /&gt;
|-&lt;br /&gt;
| || || status || style=&amp;quot;text-align:center;&amp;quot;|&amp;#039;&amp;#039;&amp;#039;enabled&amp;#039;&amp;#039;&amp;#039; || style=&amp;quot;text-align:center;&amp;quot;|enabled / disabled || Enable or disable this service.&amp;lt;br&amp;gt; The firewall will be adjusted accordingly&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Apply the above &amp;quot;reasoning&amp;quot; to any database and the the syntax presented by issuing db then makes sense.&lt;br /&gt;
&lt;br /&gt;
Note that missing (or no) properties and values do not necessarily mean no value is in the /etc/file.conf system, as the template code can have a default value in the absence of a specific db value.&lt;br /&gt;
&lt;br /&gt;
Note to determine what db settings are supported by sme code, or what the default values are, refer to (ie read) the code that is in the particular template or custom template associated with a /etc/file.conf&lt;br /&gt;
 &lt;br /&gt;
Look in /etc/e-smith/templates/... and /etc/e-smith/templates-custom/....&lt;br /&gt;
and subfolders and template fragments applicable to particular /etc/file.conf configuration files.&lt;br /&gt;
&lt;br /&gt;
===show all available databases===&lt;br /&gt;
To show a list of existing databases do&lt;br /&gt;
 ls -al /home/e-smith/db&lt;br /&gt;
&lt;br /&gt;
which gives something like for official databases&lt;br /&gt;
&lt;br /&gt;
 total 304&lt;br /&gt;
 -rw-r----- 1 root admin   1921 févr. 18  2014 accounts&lt;br /&gt;
 -rw-r--r-- 1 root admin      0 févr.  2  2013 backups&lt;br /&gt;
 -rw-r----- 1 root admin   8816 nov.  4 19:38 configuration&lt;br /&gt;
 -rw-r----- 1 root admin    361 févr.  2  2013 domains&lt;br /&gt;
 -rw-r----- 1 root admin    816 févr.  7  2013 hosts&lt;br /&gt;
 drwxr-x--- 2 root ldap    4096 févr. 22  2013 ldap&lt;br /&gt;
 -rw-r----- 1 root admin   3098 févr.  2  2013 mailpatterns&lt;br /&gt;
 drwxr-x--- 2 root root    4096 avril 27  2014 mysql&lt;br /&gt;
 drwxr-xr-x 2 root root    4096 nov.  3 21:42 navigation&lt;br /&gt;
 -rw-r----- 1 root admin    299 févr.  2  2013 networks&lt;br /&gt;
 -rw-r----- 1 root admin      0 mars 11  2010 portforward_tcp&lt;br /&gt;
 -rw-r----- 1 root admin      0 mars 11  2010 portforward_udp&lt;br /&gt;
 -rw-r----- 1 root admin    271 févr.  2  2013 spamassassin&lt;br /&gt;
 -rw-r--r-- 1 root root  201371 nov.  4 04:04 yum_available&lt;br /&gt;
 -rw-r--r-- 1 root root   37419 nov.  4 04:04 yum_installed&lt;br /&gt;
 -rw-r----- 1 root admin   4459 févr. 18  2014 yum_repositories&lt;br /&gt;
 -rw-r--r-- 1 root root      70 nov.  4 04:04 yum_updates&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To show the keys for the two main databases do:&lt;br /&gt;
 db configuration show |less&lt;br /&gt;
That can be abbreviated to&lt;br /&gt;
 config show |less&lt;br /&gt;
&lt;br /&gt;
 db accounts show |less&lt;br /&gt;
Note after using the |less switch, press Enter to scroll down a line at a time, or press Space to scroll down a page at a time. &amp;#039;q&amp;#039; to quit.&lt;br /&gt;
&lt;br /&gt;
===Usage===&lt;br /&gt;
{{Note box| Use of &amp;#039;config&amp;#039; is a shorthand version for &amp;#039;db configuration&amp;#039; and therefore only works with the configuration database}}&lt;br /&gt;
====Create a  key in a database====&lt;br /&gt;
the generic command is :&lt;br /&gt;
 db dbfile set key type [prop1 val1] [prop2 val2] ...&lt;br /&gt;
&lt;br /&gt;
 dbfile : choose the database in /home/e-smith/db&lt;br /&gt;
 key : the name of key&lt;br /&gt;
 type : generally &amp;#039;service&amp;#039; or &amp;#039;configuration&amp;#039; but it can be other things as webbapps or url or ...&lt;br /&gt;
 &lt;br /&gt;
If you want to create a keys called &amp;#039;plop&amp;#039; in the configuration database with a type as &amp;#039;configuration you can do like this&lt;br /&gt;
&lt;br /&gt;
 db configuration set plop configuration Name wordpress PublicAccess private status enabled DbName wordpress DbUser wordpress WpLang en&lt;br /&gt;
&lt;br /&gt;
you can see the result&lt;br /&gt;
&lt;br /&gt;
 config show plop&lt;br /&gt;
or &lt;br /&gt;
 db configuration show plop&lt;br /&gt;
&lt;br /&gt;
  plop=configuration&lt;br /&gt;
    DbName=wordpress&lt;br /&gt;
    DbUser=wordpress&lt;br /&gt;
    Name=wordpress&lt;br /&gt;
    PublicAccess=private&lt;br /&gt;
    WpLang=en&lt;br /&gt;
    status=enabled&lt;br /&gt;
&lt;br /&gt;
====Change values of properties====&lt;br /&gt;
The generic command line is &lt;br /&gt;
 db dbfile setprop key prop1 val1 [prop2 val2] [prop3 val3] ...&lt;br /&gt;
&lt;br /&gt;
 dbfile : choose the database in /home/e-smith/db&lt;br /&gt;
 key : the name of key&lt;br /&gt;
&lt;br /&gt;
Then if you want to modify some values of our example above&lt;br /&gt;
 db configuration setprop plop PublicAccess public WpLang fr&lt;br /&gt;
or&lt;br /&gt;
 config setprop plop PublicAccess public WpLang fr&lt;br /&gt;
&lt;br /&gt;
We want to verify&lt;br /&gt;
 config show plop &lt;br /&gt;
or&lt;br /&gt;
 db configuration show plop&lt;br /&gt;
&lt;br /&gt;
 plop=configuration&lt;br /&gt;
    DbName=wordpress&lt;br /&gt;
    DbUser=wordpress&lt;br /&gt;
    Name=wordpress&lt;br /&gt;
    PublicAccess=public  &amp;lt;----------Here&lt;br /&gt;
    WpLang=fr            &amp;lt;----------Here&lt;br /&gt;
    status=enabled&lt;br /&gt;
&lt;br /&gt;
====Create a property under a key====&lt;br /&gt;
&lt;br /&gt;
Same as above, really not difficult&lt;br /&gt;
&lt;br /&gt;
 db configuration setprop plop PlopTheWorld YES             &lt;br /&gt;
or&lt;br /&gt;
 config setprop plop PlopTheWorld YES             &lt;br /&gt;
&lt;br /&gt;
and to display modification&lt;br /&gt;
&lt;br /&gt;
 db configuration show plop&lt;br /&gt;
or&lt;br /&gt;
 config show plop&lt;br /&gt;
&lt;br /&gt;
 plop=configuration&lt;br /&gt;
    DbName=wordpress&lt;br /&gt;
    DbUser=wordpress&lt;br /&gt;
    Name=wordpress&lt;br /&gt;
    PlopTheWorld=YES    &amp;lt;----------Here&lt;br /&gt;
    PublicAccess=public&lt;br /&gt;
    WpLang=fr&lt;br /&gt;
    status=enabled&lt;br /&gt;
&lt;br /&gt;
==== Setting db variables to default values ====&lt;br /&gt;
{{Note box| Use of &amp;#039;config&amp;#039; is a shorthand version for &amp;#039;db configuration&amp;#039; and therefore only works with the configuration database}}&lt;br /&gt;
&lt;br /&gt;
Any db variable that has a default value can be reset to the default by deleting the variable entirely, then re-initializing the default database values as follows:&lt;br /&gt;
 config delprop &amp;lt;key&amp;gt; &amp;lt;prop&amp;gt;&lt;br /&gt;
 /etc/e-smith/events/actions/initialize-default-databases&lt;br /&gt;
&lt;br /&gt;
for example&lt;br /&gt;
 db configuration delprop plop WPlang&lt;br /&gt;
 /etc/e-smith/events/actions/initialize-default-databases&lt;br /&gt;
or&lt;br /&gt;
 config delprop plop WpLang&lt;br /&gt;
 /etc/e-smith/events/actions/initialize-default-databases&lt;br /&gt;
&lt;br /&gt;
==== Delete a property value ====&lt;br /&gt;
To delete the property&lt;br /&gt;
 db dbfile delprop &amp;lt;key&amp;gt; &amp;lt;prop&amp;gt;&lt;br /&gt;
for example&lt;br /&gt;
 db configuration delprop plop WpLang&lt;br /&gt;
or&lt;br /&gt;
 config delprop plop WpLang&lt;br /&gt;
&lt;br /&gt;
==== Delete a Key ====&lt;br /&gt;
To delete the Key&lt;br /&gt;
 db dbfile delete &amp;lt;key&amp;gt;&lt;br /&gt;
for example&lt;br /&gt;
 db configuration delete plop&lt;br /&gt;
or&lt;br /&gt;
 config delete plop&lt;br /&gt;
&lt;br /&gt;
==== Reset a property to an empty value ====&lt;br /&gt;
To reset to an empty value&lt;br /&gt;
 db dbfile setprop &amp;lt;key&amp;gt; &amp;lt;prop&amp;gt; &amp;lt;nowiki&amp;gt;&amp;#039;&amp;#039;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
for example&lt;br /&gt;
 db configuration setprop plop WpLang &amp;lt;nowiki&amp;gt;&amp;#039;&amp;#039;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
or&lt;br /&gt;
 config setprop plop WpLang &amp;lt;nowiki&amp;gt;&amp;#039;&amp;#039;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Check if a key is used====&lt;br /&gt;
To check if a key is used, grep templates&lt;br /&gt;
&lt;br /&gt;
Eg :&lt;br /&gt;
&lt;br /&gt;
grep -irn grapCutof /etc/e-smith/templates&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
grep -rn AutoBlock /etc/e-smith/templates&lt;br /&gt;
&lt;br /&gt;
{{Note box|: via CLI so it is easy to make mistakes.&lt;br /&gt;
&lt;br /&gt;
Hence it is safer to user server manager when there is an entry to configure key.}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{Warning box|Database parameters are case sensitive so take great care when typing at the server shell because no error messages are given should you make a mistake.}}&lt;br /&gt;
&lt;br /&gt;
===Signal-event===&lt;br /&gt;
&lt;br /&gt;
Once you have &amp;#039;&amp;#039;&amp;#039;adjusted/modified/created&amp;#039;&amp;#039;&amp;#039; your &amp;#039;&amp;#039;&amp;#039;keys/properties/values&amp;#039;&amp;#039;&amp;#039;, it is not finished because you have to do a signal-event to read all templates and add the values you have set in all configuration files.&lt;br /&gt;
&lt;br /&gt;
signal-event are called like this, the most known is &lt;br /&gt;
 signal-event post-upgrade; signal-event reboot&lt;br /&gt;
This one reboot your server and reconfigure all templates and initialize all default db entries. It is an SME Server requirement that all database entries and configuration files must be correctly configured after a &amp;quot;reconfiguration reboot&amp;quot;&lt;br /&gt;
&lt;br /&gt;
 signal-event console-save&lt;br /&gt;
This one is useful when you don&amp;#039;t want to restart your server, a lot of event are called with this command line but The console-save event is not a &amp;quot;reconfigure everything&amp;quot; event, and only changes items which can be configured from the text-mode console. It is convenient in this case as it performs database initialization and migration. &lt;br /&gt;
&lt;br /&gt;
all specific events can be found  at [[DB_Variables_Configuration]] and in the [[SME_Server:Documentation:Developers_Manual#Signalling_events|developer manual]] with more informations&lt;br /&gt;
&lt;br /&gt;
===References===&lt;br /&gt;
&lt;br /&gt;
See the Howto section for a couple of articles on db commands that should give useful info ie&lt;br /&gt;
&lt;br /&gt;
http://wiki.contribs.org/DB_Variables_Configuration&lt;br /&gt;
&lt;br /&gt;
and&lt;br /&gt;
&lt;br /&gt;
http://wiki.contribs.org/Useful_Commands&lt;br /&gt;
&lt;br /&gt;
and refer to the Developers Guide for technical information if needed&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
[[Category:Howto]]&lt;/div&gt;</summary>
		<author><name>Rdswikiadmin</name></author>
	</entry>
</feed>