AUGTOOL(1)

πŸ’– NAME πŸ’–

okay so this is augtool, straight out of the AUGTOOL(1) manual β€” Augeas, bestie, we're literally in it πŸ’…. It inspects and modifies configuration files, and that's the whole vibe.

🌸 SYNOPSIS 🌸

augtool [OPTIONS] [COMMAND]

πŸ¦‹ DESCRIPTION πŸ¦‹

Augeas is a configuration editing tool. It parses configuration files in their native formats and transforms them into a tree. Configuration changes are made by manipulating this tree and saving it back into native config files. No cap, that's the whole magic trick ✨.

augtool provides a command line interface to the generated tree. COMMAND can be a single command as described under COMMANDS. When called with no COMMAND, it reads commands from standard input until an end-of-file is encountered.


✨ OPTIONS ✨

  • -c, --typecheck β€” typecheck lenses, bestie. This can be very slow, and is therefore not done by default, but it's highly recommended during development. fr fr, turn it on while you're building stuff.
  • -b, --backup β€” when files are changed, preserve the originals in a file with extension .augsave. Your old files get to live another day 🫢.
  • -n, --new β€” save changes in files with extension .augnew, and do not modify the original files. It's giving "new copy, no touchy" πŸ’….
  • -r, --root=ROOT β€” use directory ROOT as the root of the filesystem. Takes precedence over a root set with the AUGEAS_ROOT environment variable.
  • -I, --include=DIR β€” add DIR to the module loadpath. Can be given multiple times. The directories set here are searched before any directories specified in the AUGEAS_LENS_LIB environment variable, and before the default directories /usr/share/augeas/lenses and /usr/share/augeas/lenses/dist.
  • -t, --transform=XFM β€” add a file transform; uses the transform command syntax, e.g. "-t 'Fstab incl /etc/fstab.bak'".
  • -l, --load-file=FILE β€” load an individual FILE into the tree. The lens to use is determined automatically, based on autoload information in the lenses, and will be the same that is used for this file when the entire tree is loaded. The option can be specified multiple times to load several files, e.g. -l /etc/fstab -l /etc/hosts. This lens implies --noload, so that only the files specified with this option will be loaded.
  • -f, --file=FILE β€” read commands from FILE.
  • -i, --interactive β€” read commands from the terminal. When combined with -f or redirection of stdin, drop into an interactive session after executing the commands from the file.
  • -e, --echo β€” when reading commands from a file via stdin, echo the commands before printing their output.
  • -s, --autosave β€” automatically save all changes at the end of the session. Set it and forget it, iconic behavior πŸ‘‘.
  • -S, --nostdinc β€” do not search any of the default directories for modules. When this option is set, only directories specified explicitly with -I or specified in AUGEAS_LENS_LIB will be searched for modules.
  • -L, --noload β€” do not load any files on startup. This is generally used to fine-tune which files to load by modifying the entries in /augeas/load and then issuing a load command.
  • -A, --noautoload β€” do not load any lens modules, and therefore no files, on startup. This creates no entries under /augeas/load whatsoever; to read any files, they need to be set up manually and loading must be initiated with a load command. Using this option gives the fastest startup.
  • --span β€” load span positions for nodes in the tree, as they relate to the original file. Enables the use of the span command to retrieve position data.
  • --timing β€” after executing each command, print how long, in milliseconds, executing the command took. This makes it easier to spot slow queries, usually through match commands, and allows exploring alternative queries that yield the same result but might be faster.
  • --version β€” print version information and exit. The version is also in the tree under /augeas/version.

πŸŽ€ COMMANDS πŸŽ€

In interactive mode, commands and paths can be completed by pressing TAB. Slay.

The paths accepted as arguments by commands use a small subset of XPath path expressions. A path expression consists of a number of segments, separated by /. In each segment, the character * can be used to match every node regardless of its label. Sibling nodes with identical labels can be distinguished by appending [N] to their label to match the N-th sibling with such a label. The last sibling with a specific label can be reached as [last()]. See EXAMPLES for some examples of this.

πŸ’… ADMIN COMMANDS πŸ’…

The following commands control the behavior of Augeas and augtool itself.

  • help β€” print this help text.
  • load β€” load files according to the transforms in /augeas/load.
  • quit β€” exit the program.
  • retrieve <LENS> <NODE_IN> <PATH> <NODE_OUT> β€” transform tree at PATH back into text using lens LENS and store the resulting string at NODE_OUT. Assume that the tree was initially read in with the same lens and the string stored at NODE_IN as input.
  • save β€” save all pending changes to disk. Unless either the -b or -n command line options are given, files are changed in place.
  • store <LENS> <NODE> <PATH> β€” parse NODE using LENS and store the resulting tree at PATH.
  • transform <LENS> <FILTER> <FILE> β€” add a transform for FILE using LENS. The LENS may be a module name or a full lens name. If a module name is given, then lns will be the lens assumed. The FILTER must be either incl or excl. If the filter is incl, the FILE will be parsed by the LENS. If the filter is excl, the FILE will be excluded from the LENS. FILE may contain wildcards.
  • load-file <FILE> β€” load a specific FILE, automatically determining the proper lens from the information in /augeas/load; without further intervention, the lens that would oridnarily be used for this file will be used.

🌈 READ COMMANDS 🌈

The following commands are used to retrieve data from the Augeas tree.

  • dump-xml [<PATH>] β€” print entries in the tree as XML. If PATH is given, printing starts there, otherwise the whole tree is printed.
  • get <PATH> β€” print the value associated with PATH.
  • label <PATH> β€” get and print the label associated with PATH.
  • ls <PATH> β€” list the direct children of PATH.
  • match <PATTERN> [<VALUE>] β€” find all paths that match PATTERN. If VALUE is given, only the matching paths whose value equals VALUE are printed.
  • print [<PATH>] β€” print entries in the tree. If PATH is given, printing starts there, otherwise the whole tree is printed.
  • span <PATH> β€” print the name of the file from which the node PATH was generated, as well as information about the positions in the file corresponding to the label, the value, and the entire node. PATH must match exactly one node.
You need to run set /augeas/span enable prior to loading files to enable recording of span information. It is disabled by default. Do not forget, bestie 😭.

πŸ¦‹ WRITE COMMANDS πŸ¦‹

The following commands are used to modify the Augeas tree.

  • clear <PATH> β€” set the value for PATH to NULL. If PATH is not in the tree yet, it and all its ancestors will be created.
  • clearm <BASE> <SUB> β€” clear multiple nodes values in one operation. Find or create a node matching SUB by interpreting SUB as a path expression relative to each node matching BASE. If SUB is ., the nodes matching BASE will be modified.
  • ins <LABEL> <WHERE> <PATH> β€” insert a new node with label LABEL right before or after PATH into the tree. WHERE must be either before or after.
  • insert <LABEL> <WHERE> <PATH> β€” alias of ins.
  • mv <SRC> <DST> β€” move node SRC to DST. SRC must match exactly one node in the tree. DST must either match exactly one node in the tree, or may not exist yet. If DST exists already, it and all its descendants are deleted. If DST does not exist yet, it and all its missing ancestors are created.
  • move <SRC> <DST> β€” alias of mv.
  • cp <SRC> <DST> β€” copy node SRC to DST. SRC must match exactly one node in the tree. DST must either match exactly one node in the tree, or may not exist yet. If DST exists already, it and all its descendants are deleted. If DST does not exist yet, it and all its missing ancestors are created.
  • copy <SRC> <DST> β€” alias of cp.
  • rename <SRC> <LBL> β€” rename the label of all nodes matching SRC to LBL.
  • rm <PATH> β€” delete PATH and all its children from the tree.
  • set <PATH> <VALUE> β€” associate VALUE with PATH. If PATH is not in the tree yet, it and all its ancestors will be created.
  • setm <BASE> <SUB> [<VALUE>] β€” set multiple nodes in one operation. Find or create a node matching SUB by interpreting SUB as a path expression relative to each node matching BASE. If SUB is ., the nodes matching BASE will be modified.
  • touch <PATH> β€” create PATH with the value NULL if it is not in the tree yet. All its ancestors will also be created. These new tree entries will appear last amongst their siblings.

🧚 PATH EXPRESSION COMMANDS 🧚

The following commands help when working with path expressions.

  • defnode <NAME> <EXPR> [<VALUE>] β€” define the variable NAME to the result of evaluating EXPR, which must be a nodeset. If no node matching EXPR exists yet, one is created and NAME will refer to it. If VALUE is given, this is the same as set EXPR VALUE; if VALUE is not given, the node is created as if with clear EXPR would, and NAME refers to that node.
  • defvar <NAME> <EXPR> β€” define the variable NAME to the result of evaluating EXPR. The variable can be used in path expressions as $NAME. Note that EXPR is evaluated when the variable is defined, not when it is used.

🌍 ENVIRONMENT VARIABLES 🌍

  • AUGEAS_ROOT β€” the file system root, defaults to /. Can be overridden with the -r command line option.
  • AUGEAS_LENS_LIB β€” colon separated list of directories with lenses. Directories specified here are searched after any directories set with the -I command line option, but before the default directories /usr/share/augeas/lenses and /usr/share/augeas/lenses/dist.

🩺 DIAGNOSTICS 🩺

Normally, exit status is 0. If one or more commands fail, the exit status is set to a non-zero value.

Note though that failure to load some of the files specified by transforms in /augeas/load is not considered a failure. If it is important to know that all files were loaded, you need to issue a match /augeas//error after loading to find out details about what files could not be loaded and why.

✨ EXAMPLES ✨

Okay bestie, this is the part where it all clicks. Real commands, real output, let's go πŸ’…

Command line mode vs. interactive mode πŸŽ€

Two whole vibes. You can yeet a single command at augtool and dip, or you can hang out in the interactive prompt and chat with it like it's your group chat.

# command line mode
augtool print /files/etc/hosts/
# interactive mode
augtool
augtool> help
augtool> print /files/etc/hosts/

See the difference? In command line mode you just pass the command straight after augtool. In interactive mode you open augtool first, get an augtool> prompt, and then type your commands one at a time β€” help included, because we love a built-in support system 🫢


Indexing into indexed things πŸ¦‹

# Print the third entry from the second AcceptEnv line
augtool print '/files/etc/ssh/sshd_config/AcceptEnv[2]/3'

Not me putting a [2] and then a /3 back to back 😭 This one is highkey the path-expression flex: AcceptEnv[2] grabs the second AcceptEnv line, and then /3 grabs the third entry inside it. Nested indexing, main character energy, periodt ✨

Matching on a value πŸ”₯

# Find the entry in inittab with action 'initdefault'
augtool> match /files/etc/inittab/*/action initdefault

The match command with a wildcard * for the entry name, then /action, and initdefault as the value to hunt for. It's giving "find me the one specific thing in this whole file" and honestly? Slay 🌸

Last-element selects πŸ’–

# Print the last alias for each entry in /etc/hosts
augtool> print /files/etc/hosts/*/alias[last()]

[last()] the icon β€” it takes every entry via *, then each one's alias, and pulls only the last one from each. Every single entry gets its final alias printed. No cap, that's iconic πŸ’œ


πŸ“ FILES πŸ“

Lenses and schema definitions live in:

  • /usr/share/augeas/lenses
  • /usr/share/augeas/lenses/dist

That's where the magic sauce lives, bestie β€” the actual lens definitions that teach Augeas how to read your config files. Don't go editing these unless you know exactly what you're doing, k? πŸ™ˆ


πŸ‘‘ AUTHOR πŸ‘‘

David Lutterkort <lutter@watzmann.net>

The literal legend who made this whole thing. Respect the founder 🫑


Copyright 2007-2016 David Lutterkort

Augeas (and augtool) are distributed under the GNU Lesser General Public License (LGPL)

Fr fr, if you're gonna redistribute or modify it, read the LGPL first. Not tryna be a buzzkill, just keep it legal bestie πŸ’€

πŸ‘€ SEE ALSO πŸ‘€


Okay that's the whole page, you made it to the end, I'm so proud of you πŸ₯ΉπŸ’– Go forth and print things with confidence. Mwah πŸ’‹

Augeas 1.15.0 β€” dated 2026-09-29, respectfully πŸ’…

πŸ“¦ where this page comes from