Working with Mac Files from Linux

How to work with Mac-specific files, even ones from 20 years ago. By Bryan Lunduke

If you've got a Macintosh and a Linux PC, eventually you're going to want to move files between them. (See Petros Koutoupis' guide to "Accessing Those Old macOS Volumes" in this issue for a great primer on how to read/write Mac volumes.)

But, what about when you actually want to work with those Mac-specific files? Perhaps you'd like to extract an archive originally made on a Macintosh 20 years ago. Or maybe you need to read a document file created in some Mac-specific office suite.

Luckily, this is usually not too difficult (emphasis on the "usually").

Let's walk through some of the more common file types and how to read/write them on Linux machines.

DMG

Apple has a few "Disk Image" file types that have been popular through the years: .SMI, .IMG and .DMG, with DMG being the most common these days.

On a modern Macintosh, .DMG files are a pretty typical way to distribute software. Each individual DMG is mounted with a double-click, and applications (plus supporting files) typically are contained within. Think of these as, essentially, .ISO files.

Luckily, there are a few easy ways to get at the contents of a DMG. The simplest is to use 7zip (which tends to be in just about every repository on the planet for every distro) to extract the .DMG, exactly like you would extract the contents of any old archive (like a .zip file). Usage is simple:


7z x AnyRandomDMGFile.dmg

This will dump the contents into a folder for your non-Mac enjoyment.

But, if you'd prefer to mount the DMG, that's pretty straightforward as well (although I have encountered some errors with a few DMG files, but those errors are rare). Run the following from your terminal:


sudo mount -t hfsplus AnyRandomDMGFile.dmg /mnt

Most Linux distributions shipping in the past few years have the HFS+ filesystem (the commonly used one on modern Macintoshes) support, and a simple mount command works surprisingly often.

However, if you use this on more than a handful of DMG files, you will encounter errors. Sometimes the DMG file is protected (which mount can't handle). Sometimes there are partition details that make mount choke. But, when it works, it works fairly well.

Worst-case scenario, go with the 7zip option. It seems to be a bit more reliable.

HQX and SIT

Let's say you've got an older Macintosh (of the pre-OS X variety). You'll often come across two common archive formats: HQX and SIT.

HQX (also known as "BinHex") isn't actually a compression format at all. It's simply a mechanism for encoding the files so they can be transferred without losing any data—such as sent via email. In fact, often an HQX file will be larger than the original file it contains.

Then there is SIT (aka "StuffIt"), which was the de facto compression format on Macs from the late 1980s up until the release of Mac OS X. If you, or anyone you know, had a Mac during that period of time, odds are you've got at least a couple .SIT files hanging around.

Decoding HQX files is actually pretty straightforward, thanks to a little package called macutils. You can install it easily enough on just about any Linux distro (a simple sudo apt install macutils).

To decode an HQX file into a folder (preserving the Macintosh resource forks as separate directories), use the following:


hexbin -3 AnyRandomHQXFile.hqx

macutils also contains functions for encoding BinHex and decoding MacBinary (an even older archive format), which is very handy and works great.

Now, Stuffit (.SIT) files are a different story—as the format, itself, is proprietary.

Luckily, the unar command works well—most of the time, like when the moon is in the right part of the sky, and the tea leaves are arranged just so.

It's in almost every repository, and a simple apt install unar (not to be confused with unrar, which extracts .RAR files) will get it installed, and it is invoked with the incredibly complex:


unar AnyRandomSitFile.sit

If it works, you're all set. If it doesn't, you're plum out of luck. The best bet then is to find a Macintosh, install the proprietary "Stuffit Expander", expand the archive, re-compress it into a .zip file, then transfer the file to your Linux system. Yeah, it's a pain. Hopefully, unar works for you.

ClarisWorks, AppleWorks and iWork

Depending on the age of the Macintosh in question, the popular office suite is going to be ClarisWorks, AppleWorks (which are really the same thing, kinda, sorta) or iWork. And, of course, none of them are available for Linux.

Luckily, LibreOffice does contain some support for reading (but not writing) to these file formats. The page layout formatting can be a bit garbled, and sometimes various parts can be corrupted (leading to significant bang-head-against-wall-time), but it mostly works. Okay, maybe "mostly" was a strong way to word it. It sometimes works, especially on less-complex documents.

The iWork formats, Pages and Numbers, are supported. As is Apple Keynote (the presentation application) version 5. Although I wouldn't rely on the formatting being preserved properly.

AppleWorks, ClarisWorks and (to some extent) even older Mac-specific word processing formats (like MacWrite) also are supported. The formatting is preserved better in those than with the newer formats of iWork—most likely simply due to the fact that the file formats have been around longer and there has been more time to work out kinks on the import process.

Again, though there is no ability to save into those formats. This is a one-way journey here, folks. But, at least you'll be able to read that old document you wrote (or that your annoying friend, who pretends like Macintoshes are the only computers on the planet, sent you) and save it into another format.

In fact, I highly recommend getting that document to a Mac and exporting it to Microsoft Word or Excel. I know that's a crazy recommendation, but LibreOffice does a far better job of supporting .Docx files than .Pages.

It Could Be Worse

That covers the basic, most common files types. None of the options are totally perfect, but with these tools, you'll at least be able to recover critical data and archives.

If Apple were to allow the ability to run Mac OS X inside a virtual machine, this all would be a lot easier, as you could quickly fire up a VM to convert a file. Unfortunately, Apple doesn't allow it. I assume Apple made that decision just to make me sad.

About the Author

Bryan Lunduke is a former Software Tester, former Programmer, former VP of Technology, former Linux Marketing Guy (tm), former openSUSE Board Member...and current Deputy Editor of Linux Journal, Marketing Director for Purism, as well as host of the (aptly named) Lunduke Show. More details: http://lunduke.com.

Bryan Lunduke