3 augtool - inspect and modify configuration files
7 augtool [OPTIONS] [COMMAND]
11 Augeas is a configuration editing tool. It parses configuration files
12 in their native formats and transforms them into a tree. Configuration
13 changes are made by manipulating this tree and saving it back into
16 augtool provides a command line interface to the generated tree. COMMAND
17 can be a single command as described under L</COMMANDS>. When called with
18 no COMMAND, it reads commands from standard input until an end-of-file is
25 =item B<-c>, B<--typecheck>
27 Typecheck lenses. This can be very slow, and is therefore not done by
28 default, but is highly recommended during development.
30 =item B<-b>, B<--backup>
32 When files are changed, preserve the originals in a file with extension
37 Save changes in files with extension '.augnew', do not modify the original
40 =item B<-r>, B<--root>=I<ROOT>
42 Use directory ROOT as the root of the filesystem. Takes precedence over a
43 root set with the AUGEAS_ROOT environment variable.
45 =item B<-I>, B<--include>=I<DIR>
47 Add DIR to the module loadpath. Can be given multiple times. The
48 directories set here are searched before any directories specified in the
49 AUGEAS_LENS_LIB environment variable, and before the default directories
50 F</usr/share/augeas/lenses> and F</usr/share/augeas/lenses/dist>.
52 =item B<-t>, B<--transform>=I<XFM>
54 Add a file transform; uses the 'transform' command syntax,
55 e.g. C<-t 'Fstab incl /etc/fstab.bak'>.
57 =item B<-f>, B<--file>=I<FILE>
59 Read commands from FILE.
61 =item B<-i>, B<--interactive>
63 Read commands from the terminal. When combined with B<-f> or redirection of
64 stdin, drop into an interactive session after executing the commands from
67 =item B<-e>, B<--echo>
69 When reading commands from a file via stdin, echo the commands before
70 printing their output.
72 =item B<-s>, B<--autosave>
74 Automatically save all changes at the end of the session.
76 =item B<-S>, B<--nostdinc>
78 Do not search any of the default directories for modules. When this option
79 is set, only directories specified explicitly with B<-I> or specified in
80 B<AUGEAS_LENS_LIB> will be searched for modules.
82 =item B<-L>, B<--noload>
84 Do not load any files on startup. This is generally used to fine-tune which
85 files to load by modifying the entries in C</augeas/load> and then issuing
88 =item B<-A>, B<--noautoload>
90 Do not load any lens modules, and therefore no files, on startup. This
91 creates no entries under C</augeas/load> whatsoever; to read any files,
92 they need to be set up manually and loading must be initiated with a
93 C<load> command. Using this option gives the fastest startup.
97 Load span positions for nodes in the tree, as they relate to the original
98 file. Enables the use of the B<span> command to retrieve position data.
102 Print version information and exit. The version is also in the tree under
109 In interactive mode, commands and paths can be completed by pressing C<TAB>.
111 The paths accepted as arguments by commands use a small subset of XPath
112 path expressions. A path expression consists of a number of segments,
113 separated by C</>. In each segment, the character C<*> can be used to match
114 every node regardless of its label. Sibling nodes with identical labels can
115 be distinguished by appending C<[N]> to their label to match the N-th
116 sibling with such a label. The last sibling with a specific label can be
117 reached as C<[last()]>. See L</EXAMPLES> for some examples of this.
119 =head2 ADMIN COMMANDS
121 The following commands control the behavior of Augeas and augtool itself.
131 Load files according to the transforms in C</augeas/load>.
137 =item B<retrieve> E<lt>LENSE<gt> E<lt>NODE_INE<gt> E<lt>PATHE<gt> E<lt>NODE_OUTE<gt>
139 Transform tree at PATH back into text using lens LENS and store the
140 resulting string at NODE_OUT. Assume that the tree was initially read in
141 with the same lens and the string stored at NODE_IN as input.
145 Save all pending changes to disk. Unless either the B<-b> or B<-n>
146 command line options are given, files are changed in place.
148 =item B<store> E<lt>LENSE<gt> E<lt>NODEE<gt> E<lt>PATHE<gt>
150 Parse NODE using LENS and store the resulting tree at PATH.
152 =item B<transform> E<lt>LENSE<gt> E<lt>FILTERE<gt> E<lt>FILEE<gt>
154 Add a transform for FILE using LENS. The LENS may be a module name or a
155 full lens name. If a module name is given, then "lns" will be the lens
156 assumed. The FILTER must be either "incl" or "excl". If the filter is
157 "incl", the FILE will be parsed by the LENS. If the filter is "excl",
158 the FILE will be excluded from the LENS. FILE may contain wildcards.
164 The following commands are used to retrieve data from the Augeas tree.
168 =item B<dump-xml> I<[E<lt>PATHE<gt>]>
170 Print entries in the tree as XML. If PATH is given, printing starts there,
171 otherwise the whole tree is printed.
173 =item B<get> E<lt>PATHE<gt>
175 Print the value associated with PATH
177 =item B<label> E<lt>PATHE<gt>
179 Get and print the label associated with PATH
181 =item B<ls> E<lt>PATHE<gt>
183 List the direct children of PATH
185 =item B<match> E<lt>PATTERNE<gt> [E<lt>VALUEE<gt>]
187 Find all paths that match PATTERN. If VALUE is given, only the matching
188 paths whose value equals VALUE are printed
190 =item B<print> I<[E<lt>PATHE<gt>]>
192 Print entries in the tree. If PATH is given, printing starts there,
193 otherwise the whole tree is printed
195 =item B<span> E<lt>PATHE<gt>
197 Print the name of the file from which the node PATH was generated, as well
198 as information about the positions in the file corresponding to the label,
199 the value, and the entire node. PATH must match exactly one node.
201 You need to run 'set /augeas/span enable' prior to loading files to enable
202 recording of span information. It is disabled by default.
206 =head2 WRITE COMMANDS
208 The following commands are used to modify the Augeas tree.
212 =item B<clear> E<lt>PATHE<gt>
214 Set the value for PATH to NULL. If PATH is not in the tree yet, it and all
215 its ancestors will be created.
217 =item B<clearm> E<lt>BASEE<gt> E<lt>SUBE<gt>
219 Clear multiple nodes values in one operation. Find or create a node matching SUB
220 by interpreting SUB as a path expression relative to each node matching
221 BASE. If SUB is '.', the nodes matching BASE will be modified.
223 =item B<ins> I<E<lt>LABELE<gt>> I<E<lt>WHEREE<gt>> I<E<lt>PATHE<gt>>
225 Insert a new node with label LABEL right before or after PATH into the
226 tree. WHERE must be either 'before' or 'after'.
228 =item B<insert> I<E<lt>LABELE<gt>> I<E<lt>WHEREE<gt>> I<E<lt>PATHE<gt>>
232 =item B<mv> E<lt>SRCE<gt> E<lt>DSTE<gt>
234 Move node SRC to DST. SRC must match exactly one node in the tree. DST
235 must either match exactly one node in the tree, or may not exist yet. If
236 DST exists already, it and all its descendants are deleted. If DST does not
237 exist yet, it and all its missing ancestors are created.
239 =item B<move> E<lt>SRCE<gt> E<lt>DSTE<gt>
243 =item B<cp> E<lt>SRCE<gt> E<lt>DSTE<gt>
245 Copy node SRC to DST. SRC must match exactly one node in the tree. DST
246 must either match exactly one node in the tree, or may not exist yet. If
247 DST exists already, it and all its descendants are deleted. If DST does not
248 exist yet, it and all its missing ancestors are created.
250 =item B<copy> E<lt>SRCE<gt> E<lt>DSTE<gt>
254 =item B<rename> E<lt>SRCE<gt> E<lt>LBLE<gt>
256 Rename the label of all nodes matching SRC to LBL.
258 =item B<rm> E<lt>PATHE<gt>
260 Delete PATH and all its children from the tree
262 =item B<set> E<lt>PATHE<gt> E<lt>VALUEE<gt>
264 Associate VALUE with PATH. If PATH is not in the tree yet,
265 it and all its ancestors will be created.
267 =item B<setm> E<lt>BASEE<gt> E<lt>SUBE<gt> [E<lt>VALUEE<gt>]
269 Set multiple nodes in one operation. Find or create a node matching SUB by
270 interpreting SUB as a path expression relative to each node matching
271 BASE. If SUB is '.', the nodes matching BASE will be modified.
273 =item B<touch> E<lt>PATHE<gt>
275 Create PATH with the value NULL if it is not in the tree yet. All its
276 ancestors will also be created. These new tree entries will appear
277 last amongst their siblings.
281 =head2 PATH EXPRESSION COMMANDS
283 The following commands help when working with path expressions.
287 =item B<defnode> E<lt>NAMEE<gt> E<lt>EXPRE<gt> [E<lt>VALUEE<gt>]
289 Define the variable NAME to the result of evaluating EXPR, which must be a
290 nodeset. If no node matching EXPR exists yet, one is created and NAME will
291 refer to it. If VALUE is given, this is the same as 'set EXPR VALUE'; if
292 VALUE is not given, the node is created as if with 'clear EXPR' would and
293 NAME refers to that node.
295 =item B<defvar> E<lt>NAMEE<gt> E<lt>EXPRE<gt>
297 Define the variable NAME to the result of evaluating EXPR. The variable
298 can be used in path expressions as $NAME. Note that EXPR is evaluated when
299 the variable is defined, not when it is used.
303 =head1 ENVIRONMENT VARIABLES
309 The file system root, defaults to '/'. Can be overridden with
310 the B<-r> command line option
312 =item B<AUGEAS_LENS_LIB>
314 Colon separated list of directories with lenses. Directories specified here
315 are searched after any directories set with the B<-I> command line option,
316 but before the default directories F</usr/share/augeas/lenses> and
317 F</usr/share/augeas/lenses/dist>
323 Normally, exit status is 0. If one or more commands fail, the exit status
324 is set to a non-zero value.
326 Note though that failure to load some of the files specified by transforms
327 in C</augeas/load> is not considered a failure. If it is important to know
328 that all files were loaded, you need to issue a C<match /augeas//error>
329 after loading to find out details about what files could not be loaded and
335 augtool print /files/etc/hosts/
340 augtool> print /files/etc/hosts/
342 # Print the third entry from the second AcceptEnv line
343 augtool print '/files/etc/ssh/sshd_config/AcceptEnv[2]/3'
345 # Find the entry in inittab with action 'initdefault'
346 augtool> match /files/etc/inittab/*/action initdefault
348 # Print the last alias for each entry in /etc/hosts
349 augtool> print /files/etc/hosts/*/alias[last()]
353 Lenses and schema definitions in F</usr/share/augeas/lenses> and
354 F</usr/share/augeas/lenses/dist>
358 David Lutterkort <dlutter@redhat.com>
360 =head1 COPYRIGHT AND LICENSE
362 Copyright 2007-2012 Red Hat Inc.
364 Augeas (and augtool) are distributed under the GNU Lesser General Public
369 B<Augeas> project homepage L<http://www.augeas.net/>