I want to modify a file like /etc/gdm/custom.conf from the shell or a script.

# GDM configuration storage

But the idea is that I can add a line to a section and it check if the section is defined, (add the definition if not), the property is defined, let it undefine (erase the line), (and delete the section header if there is no property defined), etc...

I didn't find anything except gconftool-2 but it do not explain how to modify other files. (there is a shema file there).

  • 8
    conf files do not have a fixed markup of any kind. Compare f.e. the /etc/gdm/custom.conf to /etc/X11/xorg.conf or /etc/resolv.conf.
    – Bobby
    Jun 22, 2010 at 17:22
  • as bobby states there is no such thing as .conf syntax but lots of scripting languages do have good config parser modules. you may achive what you are looking for with a short self written script. e.g. in python or perl Jun 23, 2010 at 15:39

5 Answers 5


Augeas is a: A command line tool to manipulate configuration from the shell (and shell scripts). (among other things)

It uses lenses to transform every file to xml, give special tools to edit them, and use the lenses to write the file back in native format.

  • This is exactly what I was looking for. Easy to install, easy to use. Just a note, this tool is in the default Ubuntu repos.
    – Matthew
    Dec 13, 2011 at 3:45
  • And what you need is the desktop.aug module.
    – raphink
    May 9, 2012 at 21:35

You could try crudini

crudini --set /etc/gdm/custom.conf daemon AutomaticLoginEnable 'true;'
  • This is the simplest and most versatile solution, thanks :) Aug 18, 2021 at 21:14

I wanted to edit the custom.conf file to auto-login a certain user on my embedded system. Interestingly enough, the Jetson Xavier boards automatically have git installed and I could simply do the following:

git config --file=/etc/gdm3/custom.conf daemon.AutomaticLoginEnable true
git config --file=/etc/gdm3/custom.conf daemon.AutomaticLogin ${USERNAME}

I put these two lines in one of my packages debian/package-name.postinst and voilà, it worked.

Note: The daemon part is a section name (i.e. [daemon]).



Some of the config file's use INI file headers. So you could use any INI parsers to do the validation and operations.

For Example, In python, you can use ConfigParser

In Perl , user ConfigAbstract

  • 1
    That sound good, but I've got to program for that to work (I know perl and python are easy, but I do not use them). With this in mind it should be easy to make a script/program that do what I want to do, but this is what I don't want to do... So I want to have a program that I can write (in the shell): configeditor "configfile" "section.item=value"
    – eloyesp
    Jun 22, 2010 at 17:53
  • 1
    I think I have to downvote this because, as Bobby mentioned in a comment on the question, there are a lot of config files that don't follow the INI format. But for those that do, this is the solution I'd go with.
    – David Z
    Jun 22, 2010 at 18:18
  • So the answer is NO, there isn't a program/script to achieve this, but can easyly be made for every config file.
    – eloyesp
    Jun 24, 2010 at 12:03

In vi, search for entries with /. Press n to find the next entry. Edit the files at will.

  • 1
    Asker is asking for an automated solution like adding a setting with a command. addconfig /configfile.conf --key=website --value=SuperUser.com
    – Pylsa
    Jun 22, 2010 at 18:30

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .