The Computer Oracle

How to extract a .dmg file in Linux?

--------------------------------------------------
Rise to the top 3% as a developer or hire one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------

Music by Eric Matyas
https://www.soundimage.org
Track title: City Beneath the Waves Looping

--

Chapters
00:00 How To Extract A .Dmg File In Linux?
00:42 Accepted Answer Score 51
01:19 Answer 2 Score 1
01:35 Answer 3 Score 1
01:58 Thank you

--

Full question
https://superuser.com/questions/958266/h...

--

Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...

--

Tags
#linux #extract #dmgimage

#avk47



ACCEPTED ANSWER

Score 51


Just use 7z x.

In the case of for example Sublime text, 7z x "Sublime Text 2.0.2.dmg" will be enough to extract all the files.

In other cases, like for example the JDK, you have to deal with some kind of matryoshka.

$ 7z x jdk-8u51-macosx-x64.dmg
$ cd JDK 8 Update 51/
$ 7z x JDK 8 Update 51.pkg
$ 7z x Payload~

But eventually you will get a folder containing the files you're looking for.




ANSWER 2

Score 1


Sometimes 7z do not work correctly.

Use https://sourceforge.net/projects/catacombae/files/HFSExplorer/0.23.1/ for that cases




ANSWER 3

Score 1


On the Mac, if the dmg is an image of a directory containing all the files, then make a tgz of the directory instead of a dmg, and migrate it.

#!/bin/bash
if [ -d "$1" ]; then  # $1 is the directory name
tar -cf "$1.tar" "$1" || exit  # First, create a tar-file
gzip -n -S .gz "$1.tar"  # Then ,gzip it to compress it.
mv "$1.tar.gz" "$1.tgz"  # Then rename it ti a .tgz
echo "Created $PWD/$1.tgz"
else echo "Not a directory"
fi
exit 0