This is a discussion on OS X Tips and shortcuts within the OS X How-To's, Tutorials, Tips & Tricks forums, part of the Mac OS X category; Need to convert a DMG disk image file to a CDR or ISO disk image format? Don’t bother downloading any third party tools, all you ...
Need to convert a DMG disk image file to a CDR or ISO disk image format? Don’t bother downloading any third party tools, all you need for conversion is built right into Mac OS X and you don’t even have to go the command line route for most cases.
Converting a DMG to CDR
Going from DMG to CDR is as easy as it gets:
Mount the DMG disk image you want converted to CDR format by double-clicking it in the Finder
Launch Disk Utility found in /Applications/Utilities/
Select the .dmg image from the sidebar list and then click the “Convert” button in the toolbar
Pull down the “Image Format” menu and choose “DVD/CD master”, then click “Save”
Conversion happens very quickly and you’ll find the converted CDR file at the destination where you saved it. It’s also immediately visible in the Disk Utility sidebar if you want to do something else with the file.
Now if you want to get the CDR file to ISO format, there are a few easy ways to do that.
Converting the CDR to ISO the Easy Way
You can think of a .cdr as the Mac variation of a .iso disk image, and in fact you can often convert the cdr to iso just by renaming the file extension from the Finder. If you don’t have file extensions showing in Mac OS X you’ll need to do that first, then just rename the extension to .iso and accept the changes by selecting “Use .iso”.
It’s important to point out the file extension method typically works fine on a Mac but if you want to use the resulting image to burn a bootable disk, or burn it through Windows or Linux, you’ll probably want to go with the more complete method shown below.
Converting CDR to ISO via Command Line
If you want to be certain the ISO conversion and its headers are accurate, jump to the command line by launching Terminal, found in /Applications/Utilities/, and then using the following hdiutil command:
Force Empty Trash in Mac OS X When File is Locked or In Use
Mac OS X can sometimes throw permissions errors when trying to delete files or empty the Trash. The most common variations of the errors are usually “Operation cannot be completed because the item “File” is in use” or “because the file is locked”, sometimes you can get around this by just quitting open applications or rebooting the Mac, but if you don’t want to do either you can also forcibly remove files through the command line. We will cover two different approaches to this, the first changes a files flags to attempt to unlock the file in question, and the second is a no-nonsense force delete.
First: Try quitting all apps to release the file lock or permissions, then attempt to Secure Empty Trash by holding down the Command key and right-clicking the Trash icon. If that doesn’t work, proceed with the methods outlined below.
Change Permissions To Forcibly Empty Trash
The first approach uses the chflags command to change the flags of all files in the Trash
Launch Terminal found in /Applications/Utilities/ and then proceed:
chflags -R nouchg *
Now you can try emptying the Trash as usual through the Dock, or go the rm route mentioned below.
Advanced: Forcibly Emptying the Trash via Command Line
This is a last resort and intended only for advanced users. Make sure the syntax is correct with this, the “sudo rm -rf” command will erase anything without warning. If you don’t know what you’re doing you could easily delete crucial system or personal files. Have backups ready or don’t bother with this method, proceed at your own risk.
First change the directory to Trash:
Confirm you are in the proper directory and the only files you see are the ones you want to forcibly remove by using ls:
Now try to delete the specific file:
If that still doesn’t work you can try the ultimate delete approach using sudo and -rf *. This is intentionally not spelled out easily to try and prevent any novice users from accidentally deleting something significant.
Using sudo requires the administrator password but combined with rm it will absolutely forcibly remove any file regardless of whats going on with it.
Want to quickly hide a file from prying eyes? Just like you can hide folders, you can hide individual files too. Here is how to do this using the command line tool chflags.
Launch Terminal from /Applications/Utilities/ and use the following command syntax:
chflags hidden /path/to/hide/file.txt
If you know the path to the file just type it yourself. If you don’t, follow the drag & drop method to automatically type the entire path within the Terminal, just be sure to drop it in after the initial command, and then hit the return key:
chflags hidden [DRAG FILE HERE]
If you’re confused at all watch the quick video below that demonstrates the command being used with drag and drop:
Having a bunch of Terminal tabs named “bash” “bash” and “bash” isn’t too useful, instead you can rename each tab individually to something more specific by using the Terminal inspector. Before doing so, keep in mind that tabs default to rename themselves automatically based on the currently running process.
From any multi-tabbed Terminal window, just hit Shift+Command+i, or pull down the “Shell” menu and select “Edit Title”, from here you can either rename the tab name, or even the Terminal window itself.
Name tabs by location, category, purpose, usage, whatever you go with will be easier to identify than the defaults.
Hide Anything from Spotlight in Mac OS X with the Library Folder
Though you can add anything to Spotlights Privacy list to prevent indexing of that folder or file, the obvious problem with that approach is the file or folder is shown within the Spotlight control panel in Mac OS X, making it easy for someone else to find the excluded items.
Another way to hide a file from Spotlight is to drop it in the user Library directory. This makes it invisible to the vast majority of people, and it also prevents the file from being indexed by Spotlight despite not being directly excluded. This works because Spotlight does not index the user Library directory which is typically just filled with preference and cache files.
Sleep can be invoked instantly on any Mac through the command line by running the pmset command or a very simple AppleScript. To try this yourself, launch Terminal and use one of the following commands, remember there is no warning, sleep is immediate:
That is one of the most simple uses of pmset, which is a full featured power management utility.
You can also use AppleScript to instantly initiate sleep from Terminal:
osascript -e 'tell application "Finder" to sleep'
osascript is a command line tool that runs OSA scripts, the -e flag executes the script in quotes rather than looking for a file, and the text in quotations is basic AppleScript.
Using either method should override anything else running in Mac OS X and force the system to sleep. You can also target the application “System Events” if you do encounter something preventing sleep:
osascript -e 'tell application "System Events" to sleep'
Mac Won’t Sleep? Here’s How to Find Out Why And Fix It
On the rare occasion that you go to put a Mac to sleep and, well, it won’t sleep, there’s an easy to way to find out what the holdup is. Though this is a somewhat technical approach, it should give a good starting point to anyone who’s confused as to why something like automatic sleep isn’t taking effect, and hopefully provide a quick resolution to the problem.
Launch Terminal from /Applications/Utilities/ and type the following command:
pmset -g assertions
Look through the reported assertion list for items with a “1″ next to their name to find what’s keeping the Mac awake
For example, if you see something like the following:
You’ll notice the “sleep when idle” feature is disabled, but what you really want to pay attention to is the lower portion of the list where the “Listed by owning process” report shows com.apple.audio as the reason that PreventUserIdleSystemSleep is enabled. Why is that? Because iTunes is running and playing music, meaning the computer isn’t idle.
If you’re having persistent problems with sleep and the above tip doesn’t give you any clue as to where to begin, sleep issues relating to hardware and power management quirks can often be fixed with an SMC reset. On the other side of the fence, another command line tip shows us how to find out why a Mac woke up from sleep. Sometimes the same thing preventing a Mac from sleeping is responsible from waking it up too, like Time Machine and schedule backups.
Have you ever put your Mac to sleep, only to find it awake seemingly on it’s own when you return to the machine? I’ve run into this mystery a few times, and with a few terminal commands you can help track down what caused your Mac to wake from sleep.
Launch the Terminal and type the following at the command line:
syslog |grep -i "Wake reason"
You will then see a report from the system logs that looks like the following:
Sat Jul 10 08:49:33 MacBookPro kernel : Wake reason = OHC1
Sat Jul 10 17:21:57 MacBookPro kernel : Wake reason = PWRB
Sun Jul 11 08:34:20 MacBookPro kernel : Wake reason = EHC2
Sun Jul 16 18:25:28 MacBookPro kernel : Wake reason = OHC1
Now you’re going to want to look at the code next to the “Wake reason=” text. So what do these wake reason codes mean?
OHC: stands for Open Host Controller, is usually USB or Firewire. If you see OHC1 or OHC2 it is almost certainly an external USB keyboard or mouse that has woken up the machine.
EHC: standing for Enhanced Host Controller, is another USB interface, but can also be wireless devices and bluetooth since they are also on the USB bus of a Mac.
USB: a USB device woke the machine up
LID0: this is literally the lid of your MacBook or MacBook Pro, when you open the lid the machine wakes up from sleep.
PWRB: PWRB stands for Power Button, which is the physical power button on your Mac
RTC: Real Time Clock Alarm, is generally from wake-on-demand services like when you schedule sleep and wake on a Mac via the Energy Saver control panel. It can also be from launchd setting, user applications, backups, and other scheduled events.
There may be some other codes (like PCI, GEGE, etc) but the above are the ones that most people will encounter in the system logs. Once you find out these codes, you can really narrow down what is causing your Mac to wake up from sleep seemingly at random.
Note: You can also monitor the Wake Reason codes by looking at the Console if you are not comfortable with the command line. However, in my experience the Console is slower to search and use than the Terminal. This is usually because the default string match search in Console will look through all of your system and applications logs, including those from third parties.
Though Mac OS X from Lion onward includes built-in encoding tools to perform conversions of video to audio, you can also extract an audio track from a movie by using QuickTime Player. No downloads are necessary, no enabling any buried features, it’s a simple Export setting in QuickTime and you’ll wind up with the audio track as an .m4a file, here’s how:
Open any compatible video with QuickTime Player
Pull down the File menu and choose “Export”
From the “Format” drop down menu, select “Audio Only” and click “Export”
Conversion is usually very fast though ultimately it will depend on the speed of your Mac and the size of the video file. If you’re ripping the audio from a 45 minute TED talk so you can listen to it on the iPhone, it will take quite a bit longer than extracting audio from a short video.
Open Wi-Fi networks are everywhere, if you’re stationed in an area with tons of them you’ll probably want to prioritize your own network to be the top wireless network to join so you don’t accidentally end up on someone elses unsecured network. Prioritizing is also a good idea if you use Personal Hotspot in public so you don’t end up on an open public access point. This is how you can tell Mac OS X to prioritize certain wifi networks over others:
Open System Preferences from the Apple menu and click on “Network”
Click the lock icon in the corner to unlock the settings
Now click on “Advanced” and then choose the “Wi-Fi” tab
Click on the wireless network you want to connect to primarily and drag it to the top of the list, arrange the other networks by priority
Click “OK” to save the changes and close out of System Preferences
Whatever the topmost wi-fi network is will be the first to be joined, assuming it’s available. If the topmost network isn’t available the next one down will become the preferred network, and so on. With the iPhone Hotspot example you’d probably want that to be at the very top of the list.
For an additional layer of security and to prevent a Mac from inadvertently joining the wrong network, you can check the “Ask to join new networks” box within Network preferences. This will cause OS X to behave more like iOS and ask you before it joins whatever wi-fi network is open and available, though the wifi pop-ups can get annoying.