1KDB(1) KDB(1)
2
3
4
6 kdb - Elektra key database command line administration tool
7
9 kdb get [-dlr] key/name
10
11 kdb set [-t type] [-d] [-c "A comment about this key"] [-m mode]
12 [-u uid] [-g gid] key/name "the value"
13
14 kdb set [-t type] [-m mode] [-c "A comment"] key/name -- "the value"
15
16 kdb set [-t type] [-b file] key/name
17
18 kdb ls [-lRfvs] [key/dir | key/name]
19
20 kdb ls [-lRfvx] [key/dir | key/name] > keys.xml
21
22 kdb edit [-R] [key/dir | key/name]
23
24 kdb rm key/name
25
26 kdb mv key/src key/dest
27
28 kdb ln key/src key/dest
29
30 kdb export [-f] system/some/tree.root > [file.xml]
31
32 kdb import < file.xml
33
34 kdb import file.xml
35
36 kdb monitor some/key/name Description.PP The kdb command provide ways
37 to manipulate the Elektra keys database.
38
39 The subcommands implemented are very similar to regular UNIX commands
40 like ls, and rm, specially in their output and options. Subcommands.PP
41 get
42 Get the value from the specified key. Accepts options: -d, -l, -f,
43 -s
44
45 set
46 Set the value to the specified key. Accepts options: -c, -t, -d,
47 -m, -b
48
49 ls
50 As the ls(1) command, list key names for the specified key, or
51 children keys, if specified a folder key. The -v argument will make
52 it show also the values of each key. The -d (descriptive) will make
53 it show the comment, key name and its value, as you are watching a
54 plain text file. Accepts options: -x, -d, -l, -f, -v, -R, -s
55
56 ln
57 Creates a key that is a symbolic links to another key.
58
59 mv
60 Move, or renames a key. Currently it can´t move keys across
61 different filesystems.
62
63 rm
64 As the rm(1) command, removes the key specified.
65
66 edit
67 A very powerfull subcommand that lets you edit an XML
68 representation of the keys. The parameters it accepts is usually a
69 parent key, so its child keys will be gathered. Can be used with
70 the -R flag to work recursively. The editor used is the one set in
71 the $EDITOR environment variable, or vi. After editing the keys,
72 kdb edit will analyze them and commit only the changed keys, remove
73 the keys removed, and add the keys added. This command is only
74 available when /usr/lib/libelektratools.so is available.
75
76 export, save
77 Export a subtree of keys to XML. If no subtree is defined right
78 after the export command, system and current user trees will be
79 exported. Output is written to standard output. The output encoding
80 will allways be UTF-8, regardeless of your system encoding. UTF-8
81 is the most universal charset you can get when exchanging data
82 between multiple systems. Accepts -f.
83
84 import, load
85 Import an XML representation of keys and save it to the keys
86 database. If no filename is passed right after the import command,
87 standard input is used. This command is only available when
88 /usr/lib/libelektratools.so is available.
89
90 monitor, mon
91 Monitor a key for some value change. It will block your command
92 line until a change in the key value is detected, then return its
93 new value.
94 Options.PP -R
95 Causes to work recursively. In ls, will list recursively.
96
97 -x
98 Makes ls output an XML representation of the keys, instead of an
99 ls-compatible output.
100
101 -l
102 Causes to display long results. With ls, will generate lists
103 similar to ls -l. With get, will show also the key name.
104
105 -a
106 Causes ls to display also inactive keys. Generate lists similar to
107 ls -a. Inactive keys are keys which basename begins with a ´.´
108 (dot). An example of inactive key:
109 system/sw/XFree/current/Monitor/.Monitor1
110
111 -f
112 Causes to work with full key names. A full key name makes sense
113 only on user/* keys, and differentiate from the regular key names
114 in specifying the owner user. If the current user is someuser, the
115 user/some/key full name is user:someuser/some/key. Makes effect in
116 ls, export and get subcommands.
117
118 -d
119 Causes get to work descriptivelly. When requesting a key it will
120 show the comment, key name and its value in a fancy format. Causes
121 set to mark the key as a directory key.
122
123 -s
124 Causes get and ls to be more friendly to Shell scripts. For
125 example, when requesting user/env/env2/PATH, the output will be
126 PATH="the value", that is, only the basename of the key will be
127 showed and the value will be surrounded by ´ " ´.
128
129 -t type
130 When setting a key´s value, you can specify the type with this
131 switch. Currently accepted types are string for plain text, bin for
132 binary as-is values, dir to create folder keys and link to create
133 symbolic links between keys. Plain text are always stored as
134 UTF-8(7) in Elektra, regardeless of your current encoding ($LANG).
135 If you want to force a value to be stored without the UTF-8(7)
136 encoding (a bad idea), you can set it as binary. Binary values
137 should be avoided, because they are black boxes for system
138 administrators.
139
140 -b filename
141 Set the key value as the content of file filename. This option is
142 more usefull when setting binary keys.
143
144 -m mode
145 For the set command. Will set the key access permission to mode,
146 which must be an octal number as for chmod(1).
147
148 -u uid
149 Create the key with uid user ID. It can be a user name or a uid
150 number.
151
152 -g gid
153 Create the key with gid group ID. It can be a group name or a gid
154 number
155
156 -c comment
157 When setting keys, you can use this argument to set a descriptive
158 comment for it. This comment is exactly as a comment in a plain
159 text configuration file. The comment is stored as UTF-8(7)
160 regardeless of your current encoding ($LANG).
161
162 -v
163 With the ls subcommand, will make it show also the value stored in
164 the key.
165
166 --
167 With the set subcommand, everything after it will be considered the
168 value, even text with dashes (-).
169 Best Practices When Creating Keys.PP When using Elektra to store your
170 application´s configuration and state, please keep in mind the
171 following rules:
172
173 · You are not allowed to create keys right under system or user.
174
175 · You are not allowed to create folder keys right under system or
176 user. They are reserved for very essential OS subsystems.
177
178 · The keys for your application, called say MyApp, should be created
179 under system/sw/MyApp and/or user/sw/MyApp.
180
182 KDB_ROOT if defined, prepends it to key names.
183
184 KDB_BACKEND defines the name of another backend plugin library to use
185 ExamplesSetting Keys.PP bash$kdb set -c "My first key" user/example/key
186 "Some nice value"
187
188 bash$kdb set user:luciana/example/key -- "Some - nice - value with
189 dashes"
190
191 bash#KDB_ROOT=user:http/sw/httpd kdb set -u nobody -g http key "Some
192 value"
193
194 bash$kdb set -b image.png -t bin user/example/binaryKey
195
196 bash$kdb set -b file.txt user/example/regularKey
197
198 bash#kdb set -t link system/sw/XFree/current system/sw/XFree/handmade
199 Getting Keys.PP bash$KDB_ROOT=user/example kdb get some/key/name
200
201 bash$eval `kdb get -s user/env/env1/PS1`
202
203 bash$KDB_BACKEND=gconf kdb get
204 user/sw/gnome-terminal/global/active_encodings Listing.PP bash$kdb ls
205 -laR user:valeria
206
207 bash$kdb ls -lR system/sw/xorg/current
208
209 bash$KDB_ROOT=system/sw kdb ls -lR xorg
210
211 bash$KDB_BACKEND=fstab kdb ls -Rv system/filesystems
212
213 bash$eval `kdb ls -Rvs user/env/env2` Miscelaneous.PP bash#kdb ln
214 system/sw/xorg/handmade system/sw/xorg/current
215
216 bash#kdb mv system/sw/xorg/current system/sw/xorg/old
217
218 bash#kdb rm system/inittab/rc4
219
220 bash$KDB_BACKEND=gconf kdb rm user/gconfKey XML Import and Export.PP
221 bash#kdb export user/sw/app | sed -e ´s|/app/|/app2/|g´ | kdb import
222
223 bash#KDB_ROOT=system/sw kdb export myapp > myappconf.xml
224
225 bash#kdb import myappconf.xml
226
227 bash$KDB_BACKEND=gconf kdb export user/sw
228
230 elektra(7), elektra(5)
231
233 Avi Alkalay <avi at unix.sh>
234 Linux Market Developer, Senior IT and Software Architect, IBM Linux
235 Impact Team :: ibm.com/linux
236 Author.
237
239 Copyright © 2004 Avi Alkalay
240
241
242
243Elektra Initiative March 2004 KDB(1)