Install .dmg through command line on macOS

Oct 6, 2017 Mac 中文版

MacOS already provides an elegant and simple way to install applications. However, in some specific cases, we still need to install .dmg via command line. Thus, this article is about how to do it in 4 steps.

Install .dmg through command line

It’s very easy to achieve the goal. All we have to do is to mount the .dmg file and copy all files to a folder, and then unmount the .dmg file. Ok, let’s mount the disk image:

sudo hdiutil attach [disk-image-name].dmg

Enter into the mount volume:

cd /Volumes/[disk-image-name]

Then, copy entire .app folder to /Applications folder:

sudo cp -rf [app-name].app /Applications

Finally, unmount the disk image:

sudo hdiutil detach /Volumes/[disk-image-name]

That’s it. Now, you should be able to use the application.

You might also like:

If you have any suggestions, questions or even find some typos, feel free to contact me. Thank you! :)   © 2015-2019 zeckli, thanks to Jekyll and GitHub.