Installing applications from command line

Discussion in 'macOS' started by jeremy.king, Jul 19, 2005.

  1. jeremy.king macrumors 603


    Jul 23, 2002
    Fuquay Varina, NC
    So I run my mini without a head, and do most of my administration using command line including software updates. I'd also like to install certain software, such as fink, using the command line without downloading/compiling/make/etc, so I was wondering:

    Before I just *try* it...Has anyone used /usr/sbin/installer to install an application that would otherwise run as a GUI'd installer (using Does it basically do everything a GUI based installer does (the usual license agreement prompt, install location, etc)?

    Thanks for your response.
  2. jeremy.king thread starter macrumors 603


    Jul 23, 2002
    Fuquay Varina, NC
    So no uber-command-line-geeks have tried this?

    Guess I will just have to see what happens... :)
  3. jeremy.king thread starter macrumors 603


    Jul 23, 2002
    Fuquay Varina, NC
    I'll just spam my own thread. ;)

    Actually found what I needed while I was trying to figure out how to mount a .dmg from SSH.

    Excellent writeup taken from


    Mount .DMG images remotely via the Terminal
    Authored by: brettmjohnson on Thu, May 19 '05 at 12:21AM
    Here is a writeup I did last year on how to download disk images, mount them, and install software from the command line. Very useful when you admin a machine only via SSH.

    $ cat HeadlessInstall.txt
    10 August 2004 Brett Johnson

    This describes some of the steps necessary to perform the
    installation of Mac OS X packages via the command line.

    1) Download the Package

    Download the installation image to a local directory.
    I usually download packages to the ~admin/staging directory [a client convention].
    Don't try to download it to some target directory like /etc or /usr

    I use 'curl' to fetch the package from the net. I usually Ctrl-click
    or right-click the package link in Safari (running locally) and select
    'Copy link to Clipboard'. This copies the URL to the package to the
    clipboard. I then paste the URL into the curl command in a ssh login
    window to this server. Note that curl writes its output to stdout,
    so be sure to redirect it to a file. For example

    % curl > Entropy-PHP-4.3.6-4.dmg

    This DOESN'T work for things on SourceForge, where the links are actually
    javascript that goes to a mirror. In that case, download it locally,
    then use sftp (or Fugu) to move it to this server.

    2) If it is a compressed archive, decompress it using the appropriate tool.
    For instance suppose you have a .tar.gz file:

    % ls

    % gunzip xyzzy.pkg.tar.gz
    % tar -xvf xyzzy.pkg.tar

    3) If it is a disk image file (.dmg) mount it using hdid. By default,
    the disk images are mounted under the /Volumes directory. I see no
    reason to do otherwise.

    % hdid Entropy-PHP-4.3.6-4.dmg
    % ls /Volumes
    Backup HD Entropy PHP 4.3.6-4 Server HD
    % cd "/Volumes/Entropy PHP 4.3.6-4"
    % ls
    Documentation.html php-4.3.6.pkg

    4) Run the command line version of the Mac OS X installer. By default
    the installer produces terse output suitable for parsing by scripts
    doing installations. We will make the output verbose [human readable].
    The installer takes the package name as well as the target Volume.
    The installer is /usr/sbin/installer , which should be on the path.
    The installer must be run as root, so be prepared to sudo...

    % sudo /usr/sbin/installer -verbose -pkg php-4.3.6.pkg -target /

    5) Don't forget to unmount the .dmg disk image if you mounted one.
    Here we execute the 'mount' command to determine which virtual
    disk device our dmg is mounted as (in this case it is /dev/disk2s2).
    Then we use 'hdiutil detach' to unmount it.

    % mount
    /dev/disk0s3 on / (local, journaled)
    /dev/disk1s3 on /Volumes/Backup HD (local)
    automount -nsl [336] on /Network (automounted)
    /dev/disk2s2 on /Volumes/Entropy PHP 4.3.6-4 (local, nodev, nosuid, read-only, mounted by admin)

    % hdiutil detach /dev/disk2s2 -force
    "disk2" unmounted.
    "disk2" ejected.
  4. Omen88 macrumors regular


    Jan 8, 2002
    Flanders (Belgium)
    That's pretty interesting. Might come in handy for me as well some day. And it's a pretty lonely thread, so I thought I'd post something :)
  5. MacsRgr8 macrumors 604


    Sep 8, 2002
    The Netherlands
    Cheers, kingjr3!

    IMO this is pretty vaulable.
    Let's hope this will be "Google findable (correct word ? :confused: )"

  6. jeremy.king thread starter macrumors 603


    Jul 23, 2002
    Fuquay Varina, NC
    It's worth noting that if the GUI installer relies on some post install scripts to execute, installer doesn't seem to call these. In my case, the fink installer (GUI) would have called a script in /sw/bin/ to modify your path, yada,yada,yada. Well, it didn't happen so I had to call it explicitly after installation. I don't know if this is the default behavior, but it's just what I experienced...


Share This Page