Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

This might be a really newbie question but here we go:

How can I find out what commands a package ran to install the software with apt-get install <package>?

For example, if I install a package that creates a user, how can I find out how it created that user?

share|improve this question
    
    
@illuminÉ Ah, the debian reference is still active? I recall submitting some patches for it once. –  Faheem Mitha Jul 30 at 14:48
    
@FaheemMitha Yes I find even when it's old or even obsoleted their apt documentation is still very rich! –  Amphiteót Jul 30 at 21:28

2 Answers 2

up vote 5 down vote accepted

You look at the post-installation script, which is actually run by dpkg. You can find these in /var/lib/dpkg/info. Such scripts contain the name of the binary package in question, and have the suffix .postinst.

Note that there are also pre-installation scripts, which have the suffix .preinst, but I think that a package is much more likely to create a new user in a postinst script.

Did you have a particular example in mind?

An example is postgresql-common, which creates the postgres user. Here is an extract from the file /var/lib/dpkg/info/postgresql-common.postinst.

   # Make sure the administrative user exists
    if ! getent passwd postgres > /dev/null; then
        adduser --system --quiet --home /var/lib/postgresql --no-create-home \
            --shell /bin/bash --group --gecos "PostgreSQL administrator" postgres
    fi
share|improve this answer
    
WOW.. read my mind. I was actually trying to figure out how the postgresql package creted the user. –  Grasshopper Jul 30 at 13:57

What apt-get install does is executing dpkg -i on the packages.

To find out what a package does while installing you have to unpack it. Look in /var/cache/apt/archives/ if your package is still there.

Inside the package is a data archive (data.tar.gz) and a control archive (control.tar.gz). Inside the control archive is a script to execute after the installation (postint) and one to execute after deleting the package (postrm). Open those scripts in an editor and see what the installation process does.

To unpack the package:

ar x package.deb

To unpack the control archive (after unpacking the package):

tar xfz control.tar.gz
share|improve this answer
    
I marked Faheem's answer as the solution because it is more specific to what I needed, but both answers complement each other. –  Grasshopper Jul 30 at 13:58
1  
Or since OP is on Debian (or a Debian-derivative, or at least using dpkg), dpkg-deb -c package.deb outdir is easier than the ar/tar combo. And will continue to work, even when dpkg changes formats (not sure if control.tar will change to xz) –  derobert Jul 30 at 15:04

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.