Mac Os X Install Dmg Command Line If you're like me, you'll probably find Remote Desktop over 3G to be pretty boring, and will want to do as much as you can via command line. Mounting DMG with hdiutil command. In order to manually mount DMG file, you'll need to use hdiutil command. Xcode-select: error: command line tools are already installed, use “Software Update” to install updates. This means you'll need to go to the developer website instead. Installing the CLT. When the.dmg has finished downloaded, double click the file to open it. This will open a little window that looks like this. Find the downloaded file, which usually ends up in your Desktop or Downloads folder. Double-click the.DMG file to mount it. A new Finder window showing its contents should appear. If the window also contains a shortcut icon to “Applications”, drag and drop the app onto the shortcut.

An intrepid reader asked the following question:
How do you install a .dmg package from the command line?

  • This document explains Mac OS X's “.dmg” file, and some tips about using command line tools for Mac specific things, such as launching apps, put system to sleep, etc. What's “.dmg” File? “.dmg” file are files in Apple's disk image file format, The “.app” that deal with them are: Disk Copy, DiskImageMounter, Disk Utility.
  • Download and install a.dmg file from Mac OS terminal. I created a bash piece of code that downloads a.dmg. Set/get OSX volume/mute from the command line 23.

Many applications are distributed as disk images, a compressed binary format. If you double click a disk image in the Finder, it is mounted automatically. Once mounted, installation of the application is typically done by dragging an icon to the Applications folder. The same can be accomplished from the command line using two commands, hdiutil and cp.

The following steps show the installation of a popular VNC client for OS X called 'Chicken of the VNC'. It can be used as a remote desktop client for Linux, Mac, or Windows hosts.

The download file is named 'cotvnc-20b4.dmg'. Here are the steps needed to install it remotely from the command line.
note: this technique can be used from a local Terminal window or a remote SSH connection.

Mount the disk image

The first step is to mount (or attach) the disk image. From the command line, use:
hdiutil mount cotvnc-20b4.dmg
I received the following output:

A mounted disk image appears on the Desktop, in the Finder, and more importantly shows up as a directory in /Volumes. In this case, the last line of output from hdiutil showed exactly where the disk image was mounted.

Sometimes when a disk image is mounted, it will prompt you to agree to a license first. In that case, the text that would normally appear in a GUI dialog box instead appears in the Terminal window. Once you scroll to the bottom of the agreement, you can type in Y to continue or N to stop. The Firefox disk image is one example of a package that displays a license before mounting.

Install the application

Use the cp command to copy the application to /Applications:
sudo cp -R '/Volumes/Chicken of the VNC/Chicken of the VNC.app' /Applications

The -R switch means to copy recursively, in other words, copy everything from that location including all subdirectories and files below. It is important to leave off the trailing '/' from the 'Chicken of the VNC.app' directory, or the command will not copy the directory itself, just the contents. After entering your password, the application will be installed and ready to use.

Most applications can simply be copied to the /Applications directory. However, some are distributed in a .pkg format and must be installed using the installer command instead of cp. To install a .pkg, use this command:
sudo installer -package /path/to/package -target '/Volumes/Macintosh HD'

Unmount the disk image

To tidy up, return to your home directory and unmount the disk image:
cd ~
hdiutil unmount '/Volumes/Chicken of the VNC/'

You should see this message after the unmount:
'/Volumes/Chicken of the VNC/' unmounted successfully.

How to install dmg file on mac from command line download

Installing applications from a .dmg package at the command line is not something you need to do every day. But it is a nice tool to have if you want to install an application on a remote server or script the installation of a package to a group of desktop Macs.

By Xah Lee. Date: . Last updated:

This document explains Mac OS X's “.dmg” file, and some tips about using command line tools for Mac specific things, such as launching apps, put system to sleep, etc.

What's “.dmg” File?

“.dmg” file are files in Apple's disk image file format,The “.app” that deal with them are:Disk Copy,DiskImageMounter,Disk Utility.

What is a disk image? Why not just zip?

How to install dmg file on mac from command line download

Disk imagefiles are different than compressed files. Disk image is roughly a copy of the actual structure of disk. The OS will treat disk images just like a storage device, but a virtual one. For example, you can create a zip version of all files on a CD, but that zip file can't be used by the OS to boot the machine. With disk image file, it can. With disk image files, you can also create a image file of a CD, and that can be used to create a CD that is identical to the original CD.

Mac OS X's disk image file format is called “.dmg” files. For applications or executable files, it's better to use disk image format, because that way, all resource fork issues are done correctly, among other reasons.

How to create .dmg files using command line?

To create one, use hdiutil, like this:

This will create a disk image with 5 mega bytes, using HFS+ format (OS X standard), and the name of the disk is “myDisk”, and the disk image file created is “myDisk.dmg”.

How to open a “.dmg” file with commnand line tool?

You can just use the “open” command. Like this: open myDisk.dmg.

The disk image will show up at /Volumes/.

How To Install Dmg File On Mac From Command Lines

You can also use “hdid”, like this:hdid mydisk.dmg.If it is encrypted, a password GUI dialog will pop up.

To attach a encrypted dmg file without having it pop up a GUI dialog, do hdid -stdinpass mydisk.dmg.

How to eject a “.dmg” file using command line?

How To Install Dmg File On Mac From Command Line Download

To eject, first find out what disk device it is associated to by typing “df”. Here's a sample output:

then, use hdiutil to eject it, for example: hdiutil detach /dev/disk2s2.

How To Install Dmg File On Mac From Command Line Command

If you have a question, put $5 at patreon and message me.