Skip to content

Installing .pkg with terminal ?

66 down vote favorite 19

Is it possible to install a .pkg using a terminal ? (I wanted to install an app through ssh). terminal install pkg shareimprove this question asked Nov 21 '12 at 11:23 Matthieu Riegler 16.3k64588 add a comment 2 Answers active oldest votes up vote 81 down vote accepted /usr/sbin/installer

The installer command is used to install Mac OS X installer packages to a specified domain or volume. The installer command installs a single package per invocation, which is specified with the -package parameter ( -pkg is accepted as a synonym). It may be either a single package or a metapackage. In the case of the metapackage, the packages which are part of the default install will be installed unless disqualified by a package's check tool(s).

See man installer for the full functionality. Often

sudo installer -pkg /path/to/package.pkg -target /

is all that's needed. shareimprove this answer edited Oct 26 '15 at 8:25 answered Nov 21 '12 at 11:28 nohillside 50.4k13109146

Note that the -target is a device and not a path. So keep it "/" for most cases. – AlexV Nov 15 '16 at 2:53
1
@AlexV colour me confused - / is a path and a device is mounted on it. So why would an option that requires a device as an argument accept /? – muru Jun 14 '17 at 2:25

add a comment up vote 3 down vote

Install all .pkg files from the current folder to /Applications:

for f in *.pkg ; do sudo installer -verbose -pkg "$f" -target / done

As an alternative you can install the packages to your home folder with -target ~. They will end up in /Users/<your_account>/Applications unless a specific path is predefined in the installer.

If you need to see what exactly an pkg installer contains and what pre- and post-install scripts will be run then you could install SuspiciousPackage (freeware), and use quick preview from Finder while the .pkg file is selected. Pressing spacebar in Finder with the file selected should work too.

shareimprove this answer edited May 24 '17 at 9:58 answered Mar 18 '17 at 22:05 ccpizza 8641217

3
This doesn't necessarily install to /Applications - it depends on the package, for example PowerShell for macOS installs to /usr/local. – RichVel May 24 '17 at 8:21

add a comment

https://apple.stackexchange.com/questions/72226/installing-pkg-with-terminal