Results 1 to 7 of 7

Thread: HOWTO: Listing current customizations to your system

  1. #1
    Join Date
    Jan 2007
    Beans
    68

    HOWTO: Listing current customizations to your system

    If you're at all like me, you probably have made customizations to your system from following other HOWTOs and then completely forgotten about what you changed. I find that this can be really inconvenient. Sometimes I follow a HOWTO and it turns out that it doesn't do what I want and I have to change things back, but I don't always remember what I did. Other times I modify configuration files and then forget what I changed in them.

    To help deal with this I've written a program called apt-diff that prints out the things that you have modified on your system.

    Installation

    I have a PPA with packages for Ubuntu 10.04 and later. To install, just run:

    Code:
    sudo add-apt-repository ppa:tschmelcher/apt-diff
    sudo apt-get update
    sudo apt-get install apt-diff
    Usage

    apt-diff can be used in two main ways. You can show all the customizations made to a certain directory, or you can show all the customizations made to a certain package. In both cases you just need to give the name of the directory/package on the command-line.

    Here's an example. Recently I customized the CUPS configuration file on my computer to enable printer sharing, but I don't remember what the name of the file is or what I changed in it. All I remember is that the file was in /etc/cups. To see what I changed, I can run:

    Code:
    apt-diff /etc/cups
    Which prints:

    Code:
    Skipping obsolete conffile /etc/cups/acroread.conf owned by cups
    Skipping obsolete conffile /etc/cups/mime.convs owned by cups
    Skipping obsolete conffile /etc/cups/mime.types owned by cups
    Skipping obsolete conffile /etc/cups/oopstops.convs owned by cups
    Skipping obsolete conffile /etc/cups/oopstops.types owned by cups
    Skipping obsolete conffile /etc/cups/pdftops.conf owned by cups
    Skipping obsolete conffile /etc/cups/pstopdf.convs owned by cups
    --- /tmp/apt-diff_1000/extracted/cups/etc/cups/cupsd.conf 2011-05-29 23:01:35.000000000 -0700
    +++ /etc/cups/cupsd.conf 2011-05-12 21:03:34.000000000 -0700
    @@ -1,128 +1,81 @@
    -#
    -#
    -# Sample configuration file for the CUPS scheduler.  See "man cupsd.conf" for a
    -# complete description of this file.
    -#
    -
    -# Log general information in error_log - change "warn" to "debug"
    -# for troubleshooting...
     LogLevel warn
    -
    -# Deactivate CUPS' internal logrotating, as we provide a better one, especially
    -# LogLevel debug2 gets usable now
     MaxLogSize 0
    -
    -# Administrator user group...
     SystemGroup lpadmin
    -
    -
    -# Only listen for connections from the local machine.
    -Listen localhost:631
    +# Allow remote access
    +Port 631
     Listen /var/run/cups/cups.sock
    -
    -# Show shared printers on the local network.
    -Browsing Off
    +# Share local printers on the local network.
    +Browsing On
     BrowseOrder allow,deny
    -BrowseAllow all
    -BrowseLocalProtocols CUPS dnssd
    +BrowseRemoteProtocols
     BrowseAddress @LOCAL
    -
    -# Default authentication type, when authentication is required...
    +BrowseLocalProtocols CUPS dnssd
     DefaultAuthType Basic
    ... snip ...
    -#
    -#
    --------------------------------
    Found 1 differences between filesystem state and package state
    Ignored 10 extra paths not owned by any package
    Skipped 2 unverifiable directories
    Finished in 1.74972 seconds
    The apt-diff output tells me several things:

    • There are a bunch of obsolete configuration files. Obsolete configuration files are ones that were used by previous versions of a package but aren't used anymore. These can be ignored, and I could even delete them if I wanted to.
    • The /etc/cups/cupsd.conf file has been modified, and apt-diff shows me what the changes are. The changes are displayed in the common "unified diff" format, which is explained on Wikipedia here. It shows me that I replaced Listen localhost:631 with Port 631, I changed some of the browsing options, and (for some crazy reason) I removed all the comments. (There are some other changes but I've left them out.)
    • At the end, apt-diff gives me a summary where it tells me how many differences it reported (1) and also certain other things that it ignored or skipped:
      • It ignored 10 "extra" paths not owned by any package. Typically this means a configuration file that was manually created from scratch, or perhaps one that was autogenerated. If you want to see the list, you can re-run with the option --no-ignore-extras.
      • It skipped 2 unverifiable directories. This simply means a directory where apt-diff can't figure out what is supposed to be inside it, if anything. Usually this means a directory that contains autogenerated or user-created content. If you want to see the list, you can re-run with the option --report-unverifiable.


    Of course, the only information I cared about in this case was the change to /etc/cups/cupsd.conf, but apt-diff couldn't have known that so it told me everything about the /etc/cups directory that might be relevant.

    Here's another example. I have a web server where I have customized the configuration of Apache, and I don't remember what I did. Let's suppose that I don't even remember where the Apache configuration file was located, but I do at least remember that it was an Apache file. I can give package names to apt-diff instead of a path!

    First, I find the list of all Apache packages that are installed, which can be done with dpkg and grep like so:

    Code:
    dpkg -l | grep apache
    Which prints:

    Code:
    ii  apache2                                    2.2.17-1ubuntu1                            Apache HTTP Server metapackage
    ii  apache2-mpm-prefork                        2.2.17-1ubuntu1                            Apache HTTP Server - traditional non-threaded model
    ii  apache2-utils                              2.2.17-1ubuntu1                            utility programs for webservers
    ii  apache2.2-bin                              2.2.17-1ubuntu1                            Apache HTTP Server common binary files
    ii  apache2.2-common                           2.2.17-1ubuntu1                            Apache HTTP Server common files
    ii  libapache2-mod-php5                        5.3.5-1ubuntu7.2                           server-side, HTML-embedded scripting language (Apache 2 module)
    ii  libapache2-mod-python                      3.3.1-9build2                              Python-embedding module for Apache 2
    Then I take that list of packages and give it to apt-diff:

    Code:
    apt-diff apache2 apache2-mpm-prefork apache2-utils apache2.2-bin apache2.2-common libapache2-mod-php5 libapache2-mod-python
    Which prints:

    Code:
    --- /tmp/apt-diff_1000/extracted/apache2.2-common/etc/apache2/envvars	2011-02-22 10:34:51.000000000 -0800
    +++ /etc/apache2/envvars	2011-05-07 21:53:36.000000000 -0700
    @@ -13,8 +13,8 @@
     # Since there is no sane way to get the parsed apache2 config in scripts, some
     # settings are defined via environment variables and then used in apache2ctl,
     # /etc/init.d/apache2, /etc/logrotate.d/apache2, etc.
    -export APACHE_RUN_USER=www-data
    -export APACHE_RUN_GROUP=www-data
    +export APACHE_RUN_USER=nebula
    +export APACHE_RUN_GROUP=nebula
     export APACHE_PID_FILE=/var/run/apache2$SUFFIX.pid
     export APACHE_RUN_DIR=/var/run/apache2$SUFFIX
     export APACHE_LOCK_DIR=/var/lock/apache2$SUFFIX
    --------------------------------
    Found 1 differences between filesystem state and package state
    Skipped 8 unverifiable directories
    Skipped 14 unverifiable symbolic links
    Finished in 1.31191 seconds
    It shows me that I modified /etc/apache2/envvars and changed the user and group. I can also see which of the packages it's in from looking at the first line of the output: the /tmp/apt-diff_1000/extracted/apache2.2-common/etc/apache2/envvars path has the apache2.2-common package name inside it, right after "extracted".

    Again, I also get a summary, and this time apt-diff reports 14 unverifiable symbolic links. apt-diff doesn't have a way to check for changes to a symbolic link, so it skips them. Again, the --report-unverifiable option would print the list if I needed to know.

    That's all for this HOWTO! I hope apt-diff will be as useful to you as it has been to me. You can also read about it at http://randomtristan.blogspot.com/20...-help-you.html.
    Last edited by Tristan Schmelcher; October 17th, 2011 at 03:39 AM. Reason: Updated install instructions

  2. #2
    Join Date
    Jul 2007
    Beans
    14

    Re: HOWTO: Listing current customizations to your system

    This looks like an very useful tool! Any chance there will be a version for 10.04 (Lucid)?

  3. #3
    Join Date
    Jan 2007
    Beans
    68

    Re: HOWTO: Listing current customizations to your system

    The 11.04 package actually works on 10.04 with no modifications. To install on 10.04 just follow the instructions in my post under "Other Versions of Ubuntu".

  4. #4
    Join Date
    Jul 2007
    Beans
    14

    Re: HOWTO: Listing current customizations to your system

    Quote Originally Posted by Tristan Schmelcher View Post
    The 11.04 package actually works on 10.04 with no modifications. To install on 10.04 just follow the instructions in my post under "Other Versions of Ubuntu".
    Thanks -- I should have seen that!

    My excuse is that I just followed the link to your blog post and read about it there, where there wasn't mention of other versions.

  5. #5
    Join Date
    Jun 2007
    Beans
    17,337

    Re: HOWTO: Listing current customizations to your system

    Thanks - will prove to be quite useful
    (also working fine on the current 11.10

  6. #6
    Join Date
    Jan 2007
    Beans
    68

    Re: HOWTO: Listing current customizations to your system

    Quote Originally Posted by wch View Post
    Thanks -- I should have seen that!

    My excuse is that I just followed the link to your blog post and read about it there, where there wasn't mention of other versions.
    Oops, I guess I should have mentioned that in both spots! Fixed.

  7. #7
    Join Date
    Jan 2007
    Beans
    68

    Re: HOWTO: Listing current customizations to your system

    My PPA now has packages for Ubuntu 10.04 and up, so there's no need anymore to edit the .list file.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •