{
    "mode": "man",
    "parameter": "CVTSUDOERS",
    "section": "1",
    "url": "https://www.chedong.com/phpMan.php/man/CVTSUDOERS/1/json",
    "generated": "2026-06-03T03:50:09Z",
    "synopsis": "cvtsudoers [-ehMpV] [-b dn] [-c conffile] [-d deftypes] [-f outputformat] [-i inputformat]\n[-I increment] [-l logfile] [-m filter] [-o outputfile] [-O startpoint]\n[-P padding] [-s sections] [inputfile ...]",
    "sections": {
        "NAME": {
            "content": "cvtsudoers — convert between sudoers file formats\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "cvtsudoers [-ehMpV] [-b dn] [-c conffile] [-d deftypes] [-f outputformat] [-i inputformat]\n[-I increment] [-l logfile] [-m filter] [-o outputfile] [-O startpoint]\n[-P padding] [-s sections] [inputfile ...]\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "The cvtsudoers utility accepts one or more security policies in either sudoers or LDIF format\nas input, and generates a single policy of the specified format as output.  The default input\nformat is sudoers. The default output format is LDIF.  It is only possible to convert a policy\nfile that is syntactically correct.\n\nIf no inputfile is specified, or if it is ‘-’, the policy is read from the standard input.\nInput files may be optionally prefixed with a host name followed by a colon (‘:’) to make the\npolicy rules specific to a host when merging multiple files.  By default, the result is written\nto the standard output.\n\nThe options are as follows:\n",
            "subsections": [
                {
                    "name": "-b --base",
                    "content": "The base DN (distinguished name) that will be used when performing LDAP queries.\nTypically this is of the form ou=SUDOers,dc=my-domain,dc=com for the domain\nmy-domain.com.  If this option is not specified, the value of the SUDOERSBASE en‐\nvironment variable will be used instead.  Only necessary when converting to LDIF\nformat.\n",
                    "flag": "-b",
                    "long": "--base"
                },
                {
                    "name": "-c --config",
                    "content": "Specify the path to the configuration file.  Defaults to /etc/cvtsudoers.conf.\n",
                    "flag": "-c",
                    "long": "--config"
                },
                {
                    "name": "-d --defaults",
                    "content": "Only convert Defaults entries of the specified types.  One or more Defaults types\nmay be specified, separated by a comma (‘,’).  The supported types are:\n\nall       All Defaults entries.\n\nglobal    Global Defaults entries that are applied regardless of user, runas, host,\nor command.\n\nuser      Per-user Defaults entries.\n\nrunas     Per-runas user Defaults entries.\n\nhost      Per-host Defaults entries.\n\ncommand   Per-command Defaults entries.\n\nSee the Defaults section in sudoers(5) for more information.\n\nIf the -d option is not specified, all Defaults entries will be converted.\n",
                    "flag": "-d",
                    "long": "--defaults"
                },
                {
                    "name": "-e --expand-aliases",
                    "content": "Expand aliases in inputfile.  Aliases are preserved by default when the output\nformat is JSON or sudoers.\n",
                    "flag": "-e",
                    "long": "--expand-aliases"
                },
                {
                    "name": "-f --output-format",
                    "content": "Specify the output format (case-insensitive).  The following formats are supported:\n\nCSV       CSV (comma-separated value) files are often used by spreadsheets and re‐\nport generators.  For CSV output, cvtsudoers double quotes strings that\ncontain commas.  For each literal double quote character present inside\nthe string, two double quotes are output.  This method of quoting commas\nis compatible with most spreadsheet programs.\n\nJSON      JSON (JavaScript Object Notation) files are usually easier for third-\nparty applications to consume than the traditional sudoers format.  The\nvarious values have explicit types which removes much of the ambiguity of\nthe sudoers format.\n\nLDIF      LDIF (LDAP Data Interchange Format) files can be imported into an LDAP\nserver for use with sudoers.ldap(5).\n\nConversion to LDIF has the following limitations:\n\n••  Command, host, runas, and user-specific Defaults lines cannot be\ntranslated as they don't have an equivalent in the sudoers LDAP\nschema.\n\n••  Command, host, runas, and user aliases are not supported by the sudo‐\ners LDAP schema so they are expanded during the conversion.\n\nsudoers   Traditional sudoers format.  A new sudoers file will be reconstructed\nfrom the parsed input file.  Comments are not preserved and data from any\ninclude files will be output inline.\n\n--group-file=file\nWhen the -M option is also specified, perform group queries using file instead of\nthe system group database.\n",
                    "flag": "-f",
                    "long": "--output-format"
                },
                {
                    "name": "-h --help",
                    "content": "",
                    "flag": "-h",
                    "long": "--help"
                },
                {
                    "name": "-i --input-format",
                    "content": "Specify the input format.  The following formats are supported:\n\nLDIF      LDIF (LDAP Data Interchange Format) files can be exported from an LDAP\nserver to convert security policies used by sudoers.ldap(5).  If a base\nDN (distinguished name) is specified, only sudoRole objects that match\nthe base DN will be processed.  Not all sudoOptions specified in a sudo‐\nRole can be translated from LDIF to sudoers format.\n\nsudoers   Traditional sudoers format.  This is the default input format.\n",
                    "flag": "-i",
                    "long": "--input-format"
                },
                {
                    "name": "-I --increment",
                    "content": "When generating LDIF output, increment each sudoOrder attribute by the specified\nnumber.  Defaults to an increment of 1.\n",
                    "flag": "-I",
                    "long": "--increment"
                },
                {
                    "name": "-l --logfile",
                    "content": "Log conversion warnings to logfile instead of to the standard error.  This is par‐\nticularly useful when merging multiple sudoers files, which can generate a large\nnumber of warnings.\n",
                    "flag": "-l",
                    "long": "--logfile"
                },
                {
                    "name": "-m --match",
                    "content": "Only output rules that match the specified filter.  A filter expression is made up\nof one or more key = value pairs, separated by a comma (‘,’).  The key may be\n“cmnd” (or “cmd”), “host”, “group”, or “user”.  For example, user = operator or\nhost = www.  An upper-case CmndAlias, Hostalias, or HostAlias may be specified\nas the “cmnd”, “host”, or “user”.\n\nA matching sudoers rule may also include users, groups, and hosts that are not part\nof the filter.  This can happen when a rule includes multiple users, groups, or\nhosts.  To prune out any non-matching user, group, or host from the rules, the -p\noption may be used.\n\nBy default, the password and group databases are not consulted when matching\nagainst the filter so the users and groups do not need to be present on the local\nsystem (see the -M option).  Only aliases that are referenced by the filtered pol‐\nicy rules will be displayed.\n",
                    "flag": "-m",
                    "long": "--match"
                },
                {
                    "name": "-M --match-local",
                    "content": "When the -m option is also specified, use password and group database information\nwhen matching users and groups in the filter.  Only users and groups in the filter\nthat exist on the local system will match, and a user's groups will automatically\nbe added to the filter.  If the -M is not specified, users and groups in the filter\ndo not need to exist on the local system, but all groups used for matching must be\nexplicitly listed in the filter.\n",
                    "flag": "-M",
                    "long": "--match-local"
                },
                {
                    "name": "-o --output",
                    "content": "Write the converted output to outputfile.  If no outputfile is specified, or if\nit is ‘-’, the converted sudoers policy will be written to the standard output.\n",
                    "flag": "-o",
                    "long": "--output"
                },
                {
                    "name": "-O --order-start",
                    "content": "When generating LDIF output, use the number specified by startpoint in the sudo‐\nOrder attribute of the first sudoRole object.  Subsequent sudoRole object use a su‐\ndoOrder value generated by adding an increment, see the -I option for details.  De‐\nfaults to a starting point of 1.  A starting point of 0 will disable the generation\nof sudoOrder attributes in the resulting LDIF file.\n\n--passwd-file=file\nWhen the -M option is also specified, perform passwd queries using file instead of\nthe system passwd database.\n",
                    "flag": "-O",
                    "long": "--order-start"
                },
                {
                    "name": "-p --prune-matches",
                    "content": "When the -m option is also specified, cvtsudoers will prune out non-matching users,\ngroups, and hosts from matching entries.\n",
                    "flag": "-p",
                    "long": "--prune-matches"
                },
                {
                    "name": "-P --padding",
                    "content": "When generating LDIF output, construct the initial sudoOrder value by concatenating\norderstart and increment, padding the increment with zeros until it consists of\npadding digits.  For example, if orderstart is 1027, padding is 3, and increment\nis 1, the value of sudoOrder for the first entry will be 1027000, followed by\n1027001, 1027002, etc.  If the number of sudoRole entries is larger than the pad‐\nding would allow, cvtsudoers will exit with an error.  By default, no padding is\nperformed.\n",
                    "flag": "-P",
                    "long": "--padding"
                },
                {
                    "name": "-s --suppress",
                    "content": "Suppress the output of specific sections of the security policy.  One or more sec‐\ntion names may be specified, separated by a comma (‘,’).  The supported section\nname are: defaults, aliases and privileges (which may be shortened to privs).\n",
                    "flag": "-s",
                    "long": "--suppress"
                },
                {
                    "name": "-V --version",
                    "content": "Print the cvtsudoers and sudoers grammar versions and exit.\n",
                    "flag": "-V",
                    "long": "--version"
                },
                {
                    "name": "Merging multiple files",
                    "content": "When multiple input files are specified, cvtsudoers will attempt to merge them into a single\npolicy file.  It is assumed that user and group names are consistent among the policy files to\nbe merged.  For example, user “bob” on one host is the same as user “bob” on another host.\n\nWhen merging policy files, it is possible to prefix the input file name with a host name, sepa‐\nrated by a colon (‘:’).  When the files are merged, the host name will be used to restrict the\npolicy rules to that specific host where possible.\n\nThe merging process is performed as follows:\n\n••  Each input file is parsed into internal sudoers data structures.\n\n••  Aliases are merged and renamed as necessary to avoid conflicts.  In the event of a conflict,\nthe first alias found is left as-is and subsequent aliases of the same name are renamed with\na numeric suffix separated with a underscore (‘’).  For example, if there are two different\naliases named SERVERS, the first will be left as-is and the second will be renamed\nSERVERS1.  References to the renamed alias are also updated in the policy file.  Duplicate\naliases (those with identical contents) are pruned.\n\n••  Defaults settings are merged and duplicates are removed.  If there are conflicts in the De‐\nfaults settings, a warning is emitted for each conflict.  If a host name is specified with\nthe input file, cvtsudoers will change the global Defaults settings in that file to be host-\nspecific.  A warning is emitted for command, user, or runas-specific Defaults settings which\ncannot be made host-specific.\n\n••  Per-user rules are merged and duplicates are removed.  If a host name is specified with the\ninput file, cvtsudoers will change rules that specify a host name of ALL to the host name\nassociated with the policy file being merged.  The merging of rules is currently fairly sim‐\nplistic but will be improved in a later release.\n\nIt is possible to merge policy files with differing formats.\n"
                },
                {
                    "name": "The cvtsudoers.conf file",
                    "content": "Options in the form “keyword = value” may also be specified in a configuration file,\n/etc/cvtsudoers.conf by default.  The following keywords are recognized:\n\ndefaults = deftypes\nSee the description of the -d command line option.\n\nexpandaliases = yes | no\nSee the description of the -e command line option.\n\ngroupfile = file\nSee the description of the --group-file command line option.\n\ninputformat = ldif | sudoers\nSee the description of the -i command line option.\n\nmatch = filter\nSee the description of the -m command line option.\n\nmatchlocal = yes | no\nSee the description of the -M command line option.\n\norderincrement = increment\nSee the description of the -I command line option.\n\norderstart = startpoint\nSee the description of the -O command line option.\n\noutputformat = csv | json | ldif | sudoers\nSee the description of the -f command line option.\n\npadding = padding\nSee the description of the -P command line option.\n\npasswdfile = file\nSee the description of the --passwd-file command line option.\n\nprunematches = yes | no\nSee the description of the -p command line option.\n\nsudoersbase = dn\nSee the description of the -b command line option.\n\nsuppress = sections\nSee the description of the -s command line option.\n\nOptions on the command line will override values from the configuration file.\n"
                }
            ]
        },
        "FILES": {
            "content": "/etc/cvtsudoers.conf      default configuration for cvtsudoers\n",
            "subsections": []
        },
        "EXAMPLES": {
            "content": "Convert /etc/sudoers to LDIF (LDAP Data Interchange Format) where the ldap.conf file uses a\nsudoersbase of my-domain,dc=com, storing the result in sudoers.ldif:\n\n$ cvtsudoers -b ou=SUDOers,dc=my-domain,dc=com -o sudoers.ldif \\\n/etc/sudoers\n\nConvert /etc/sudoers to JSON format, storing the result in sudoers.json:\n\n$ cvtsudoers -f json -o sudoers.json /etc/sudoers\n\nParse /etc/sudoers and display only rules that match user ambrose on host hastur:\n\n$ cvtsudoers -f sudoers -m user=ambrose,host=hastur /etc/sudoers\n\nSame as above, but expand aliases and prune out any non-matching users and hosts from the ex‐\npanded entries.\n\n$ cvtsudoers -ep -f sudoers -m user=ambrose,host=hastur /etc/sudoers\n\nConvert sudoers.ldif from LDIF to traditional sudoers format:\n\n$ cvtsudoers -i ldif -f sudoers -o sudoers.new sudoers.ldif\n\nMerge a global sudoers file with two host-specific policy files from the hosts “xyzzy” and\n“plugh”:\n\n$ cvtsudoers -f sudoers -o sudoers.merged sudoers \\\nxyzzy:sudoers.xyzzy plugh:sudoers.plugh\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "sudoers(5), sudoers.ldap(5), sudo(8)\n",
            "subsections": []
        },
        "AUTHORS": {
            "content": "Many people have worked on sudo over the years; this version consists of code written primarily\nby:\n\nTodd C. Miller\n\nSee the CONTRIBUTORS file in the sudo distribution (https://www.sudo.ws/contributors.html) for\nan exhaustive list of people who have contributed to sudo.\n",
            "subsections": []
        },
        "BUGS": {
            "content": "If you feel you have found a bug in cvtsudoers, please submit a bug report at\nhttps://bugzilla.sudo.ws/\n",
            "subsections": []
        },
        "SUPPORT": {
            "content": "Limited free support is available via the sudo-users mailing list, see\nhttps://www.sudo.ws/mailman/listinfo/sudo-users to subscribe or search the archives.\n",
            "subsections": []
        },
        "DISCLAIMER": {
            "content": "cvtsudoers is provided “AS IS” and any express or implied warranties, including, but not lim‐\nited to, the implied warranties of merchantability and fitness for a particular purpose are\ndisclaimed.  See the LICENSE file distributed with sudo or https://www.sudo.ws/license.html for\ncomplete details.\n",
            "subsections": []
        },
        "Sudo 1.9.9                     January 19, 2022                     Sudo 1.9.9": {
            "content": "",
            "subsections": []
        }
    },
    "summary": "cvtsudoers — convert between sudoers file formats",
    "flags": [
        {
            "flag": "-b",
            "long": "--base",
            "arg": null,
            "description": "The base DN (distinguished name) that will be used when performing LDAP queries. Typically this is of the form ou=SUDOers,dc=my-domain,dc=com for the domain my-domain.com. If this option is not specified, the value of the SUDOERSBASE en‐ vironment variable will be used instead. Only necessary when converting to LDIF format."
        },
        {
            "flag": "-c",
            "long": "--config",
            "arg": null,
            "description": "Specify the path to the configuration file. Defaults to /etc/cvtsudoers.conf."
        },
        {
            "flag": "-d",
            "long": "--defaults",
            "arg": null,
            "description": "Only convert Defaults entries of the specified types. One or more Defaults types may be specified, separated by a comma (‘,’). The supported types are: all All Defaults entries. global Global Defaults entries that are applied regardless of user, runas, host, or command. user Per-user Defaults entries. runas Per-runas user Defaults entries. host Per-host Defaults entries. command Per-command Defaults entries. See the Defaults section in sudoers(5) for more information. If the -d option is not specified, all Defaults entries will be converted."
        },
        {
            "flag": "-e",
            "long": "--expand-aliases",
            "arg": null,
            "description": "Expand aliases in inputfile. Aliases are preserved by default when the output format is JSON or sudoers."
        },
        {
            "flag": "-f",
            "long": "--output-format",
            "arg": null,
            "description": "Specify the output format (case-insensitive). The following formats are supported: CSV CSV (comma-separated value) files are often used by spreadsheets and re‐ port generators. For CSV output, cvtsudoers double quotes strings that contain commas. For each literal double quote character present inside the string, two double quotes are output. This method of quoting commas is compatible with most spreadsheet programs. JSON JSON (JavaScript Object Notation) files are usually easier for third- party applications to consume than the traditional sudoers format. The various values have explicit types which removes much of the ambiguity of the sudoers format. LDIF LDIF (LDAP Data Interchange Format) files can be imported into an LDAP server for use with sudoers.ldap(5). Conversion to LDIF has the following limitations: •• Command, host, runas, and user-specific Defaults lines cannot be translated as they don't have an equivalent in the sudoers LDAP schema. •• Command, host, runas, and user aliases are not supported by the sudo‐ ers LDAP schema so they are expanded during the conversion. sudoers Traditional sudoers format. A new sudoers file will be reconstructed from the parsed input file. Comments are not preserved and data from any include files will be output inline. --group-file=file When the -M option is also specified, perform group queries using file instead of the system group database."
        },
        {
            "flag": "-h",
            "long": "--help",
            "arg": null,
            "description": ""
        },
        {
            "flag": "-i",
            "long": "--input-format",
            "arg": null,
            "description": "Specify the input format. The following formats are supported: LDIF LDIF (LDAP Data Interchange Format) files can be exported from an LDAP server to convert security policies used by sudoers.ldap(5). If a base DN (distinguished name) is specified, only sudoRole objects that match the base DN will be processed. Not all sudoOptions specified in a sudo‐ Role can be translated from LDIF to sudoers format. sudoers Traditional sudoers format. This is the default input format."
        },
        {
            "flag": "-I",
            "long": "--increment",
            "arg": null,
            "description": "When generating LDIF output, increment each sudoOrder attribute by the specified number. Defaults to an increment of 1."
        },
        {
            "flag": "-l",
            "long": "--logfile",
            "arg": null,
            "description": "Log conversion warnings to logfile instead of to the standard error. This is par‐ ticularly useful when merging multiple sudoers files, which can generate a large number of warnings."
        },
        {
            "flag": "-m",
            "long": "--match",
            "arg": null,
            "description": "Only output rules that match the specified filter. A filter expression is made up of one or more key = value pairs, separated by a comma (‘,’). The key may be “cmnd” (or “cmd”), “host”, “group”, or “user”. For example, user = operator or host = www. An upper-case CmndAlias, Hostalias, or HostAlias may be specified as the “cmnd”, “host”, or “user”. A matching sudoers rule may also include users, groups, and hosts that are not part of the filter. This can happen when a rule includes multiple users, groups, or hosts. To prune out any non-matching user, group, or host from the rules, the -p option may be used. By default, the password and group databases are not consulted when matching against the filter so the users and groups do not need to be present on the local system (see the -M option). Only aliases that are referenced by the filtered pol‐ icy rules will be displayed."
        },
        {
            "flag": "-M",
            "long": "--match-local",
            "arg": null,
            "description": "When the -m option is also specified, use password and group database information when matching users and groups in the filter. Only users and groups in the filter that exist on the local system will match, and a user's groups will automatically be added to the filter. If the -M is not specified, users and groups in the filter do not need to exist on the local system, but all groups used for matching must be explicitly listed in the filter."
        },
        {
            "flag": "-o",
            "long": "--output",
            "arg": null,
            "description": "Write the converted output to outputfile. If no outputfile is specified, or if it is ‘-’, the converted sudoers policy will be written to the standard output."
        },
        {
            "flag": "-O",
            "long": "--order-start",
            "arg": null,
            "description": "When generating LDIF output, use the number specified by startpoint in the sudo‐ Order attribute of the first sudoRole object. Subsequent sudoRole object use a su‐ doOrder value generated by adding an increment, see the -I option for details. De‐ faults to a starting point of 1. A starting point of 0 will disable the generation of sudoOrder attributes in the resulting LDIF file. --passwd-file=file When the -M option is also specified, perform passwd queries using file instead of the system passwd database."
        },
        {
            "flag": "-p",
            "long": "--prune-matches",
            "arg": null,
            "description": "When the -m option is also specified, cvtsudoers will prune out non-matching users, groups, and hosts from matching entries."
        },
        {
            "flag": "-P",
            "long": "--padding",
            "arg": null,
            "description": "When generating LDIF output, construct the initial sudoOrder value by concatenating orderstart and increment, padding the increment with zeros until it consists of padding digits. For example, if orderstart is 1027, padding is 3, and increment is 1, the value of sudoOrder for the first entry will be 1027000, followed by 1027001, 1027002, etc. If the number of sudoRole entries is larger than the pad‐ ding would allow, cvtsudoers will exit with an error. By default, no padding is performed."
        },
        {
            "flag": "-s",
            "long": "--suppress",
            "arg": null,
            "description": "Suppress the output of specific sections of the security policy. One or more sec‐ tion names may be specified, separated by a comma (‘,’). The supported section name are: defaults, aliases and privileges (which may be shortened to privs)."
        },
        {
            "flag": "-V",
            "long": "--version",
            "arg": null,
            "description": "Print the cvtsudoers and sudoers grammar versions and exit."
        }
    ],
    "examples": [
        "Convert /etc/sudoers to LDIF (LDAP Data Interchange Format) where the ldap.conf file uses a",
        "sudoersbase of my-domain,dc=com, storing the result in sudoers.ldif:",
        "$ cvtsudoers -b ou=SUDOers,dc=my-domain,dc=com -o sudoers.ldif \\",
        "/etc/sudoers",
        "Convert /etc/sudoers to JSON format, storing the result in sudoers.json:",
        "$ cvtsudoers -f json -o sudoers.json /etc/sudoers",
        "Parse /etc/sudoers and display only rules that match user ambrose on host hastur:",
        "$ cvtsudoers -f sudoers -m user=ambrose,host=hastur /etc/sudoers",
        "Same as above, but expand aliases and prune out any non-matching users and hosts from the ex‐",
        "panded entries.",
        "$ cvtsudoers -ep -f sudoers -m user=ambrose,host=hastur /etc/sudoers",
        "Convert sudoers.ldif from LDIF to traditional sudoers format:",
        "$ cvtsudoers -i ldif -f sudoers -o sudoers.new sudoers.ldif",
        "Merge a global sudoers file with two host-specific policy files from the hosts “xyzzy” and",
        "“plugh”:",
        "$ cvtsudoers -f sudoers -o sudoers.merged sudoers \\",
        "xyzzy:sudoers.xyzzy plugh:sudoers.plugh"
    ],
    "see_also": [
        {
            "name": "sudoers",
            "section": "5",
            "url": "https://www.chedong.com/phpMan.php/man/sudoers/5/json"
        },
        {
            "name": "sudoers.ldap",
            "section": "5",
            "url": "https://www.chedong.com/phpMan.php/man/sudoers.ldap/5/json"
        },
        {
            "name": "sudo",
            "section": "8",
            "url": "https://www.chedong.com/phpMan.php/man/sudo/8/json"
        }
    ]
}