TerminalTips

Latest

  • Download Amazon MP3s in Terminal with clamz

    by 
    TJ Luoma
    TJ Luoma
    11.13.2011

    If you've ever wanted to download Amazon MP3s via Terminal or over ssh, or ever found yourself unable to use the "Amazon MP3 Downloader.app" then I have good news for you: there is another way. The problem Amazon's MP3 Store annoys me to no end. I love the deals that they occasionally offer, but in order to download the files, you have to download the Amazon MP3 Downloader. Inside that dmg file is an installer application that doesn't use the normal .pkg format. The special installer failed to install the application on my Mac. I managed to install it manually (as well as the plugin that needs to be installed to "/Library/Internet Plug-Ins/"), but then the application kept crashing after each song. So, to recap, Amazon doesn't use the standard package installer, and their installer failed to work; and they don't use normal downloads, and their non-standard downloader failed to work. This is why you should stick to standards -- they've been better tested for a lot longer than your "roll your own" solution. Stop reinventing the wheel. The ".amz" file that you download from Amazon is an XML file which includes a download URL, but you can't access that URL to download the music directly. I was all ready to start sniffing TCP headers and try to figure out what special headers the Amazon MP3 Downloader.app uses, when the same thought occurred to me: "Don't reinvent the wheel." The solution I was able to find the solution on Google code, specifically at http://code.google.com/p/clamz/ which is described as "is a little command-line program to download MP3 files from Amazon.com's music store." Side note: I needed to install 'libgcrypt' in order to get clamz to build, which I did using Homebrew simply by typing brew install libgcrypt (assuming you already have brew and Xcode installed). The clamz page also mentions libcurl and libexpat, but those were already installed on my Mac. Once I had the necessary libraries installed, installation of clamz was as simple as the instructions on its homepage: Then I just had to get a "fresh" .amz file from Amazon. To do that, I went to the Amazon Cloud Player, clicked the checkbox at the top to select all my music (see #1 below) and then clicked "Download" (see #2 below): Note that if you have more songs than will fit on one page, you may have to do this repeatedly for each "page". I only have 230 songs in my Amazon Cloud Player. That downloaded new ".amz" file on my computer called "Amazon-MP3-1321140421.amz" (yours will be named something similar but different). Then I ran this command simple command: clamz --output-dir=~/Music/ ~/Downloads/Amazon-MP3-1321140421.amz and watched with sheer delight as clamz downloaded all of my Amazon music files. I accidentally closed my MacBook Air before it was finished, but was able to resume the download simply by adding the --resume flag: clamz --resume --output-dir=~/Music/ ~/Downloads/Amazon-MP3-1321140421.amz When it finishes, you can delete the .amz file, as the links it contains will expire anyway. You can always download another one later. Thanks, Internet This simply would not have been possible without the help of the open source community, both the developer behind clamz (Benjamin Moody) and the awesome folks behind Homebrew. After I finished using clamz I also found pymazon, but I'm not sure if that works on Mac. Since I criticized Amazon's non-standard downloader, someone might say "Well, iTunes is a non-standard downloader, too!" That's a valid point. If I had been trying to download from iTunes and it failed to work, I would not have been so fortunate to find an open source solution.

  • Why hibernate or 'safe sleep' mode is no longer necessary in OS X Lion (Updated)

    by 
    Chris Rawson
    Chris Rawson
    08.22.2011

    Update: Several commenters expressed concern that disabling safe sleep could expose you to the possibility of drive corruption if you lose power or your machine spontaneously restarts. This particular fear is groundless; Safe Sleep doesn't have anything to do with volume corruption (except if you inadvertently bounce your laptop around while the drive is still spinning to save the sleep image, as noted below). The technology that helps OS X deal with uncertain volume status is HFS+ journaling, and it's set on by default when your drive is first formatted for an OS X install. The file system journal keeps track of changes and updates to your drive; if your Mac loses power, the journal is 'replayed' to help restore the drive to a known good state. This is always at work regardless of the safe sleep status. Whether you choose to keep Safe Sleep on or not is a matter of personal preference, but if your machine is generally plugged in and you don't run the battery down below 20%, you are never actually taking advantage of the feature. If you want to chew up the drive space and take the time for the sleep image to write anyway, that's up to you. On SSD-equipped machines, the image save time is inconsequential but the loss of storage space is even more acute. Original post below. Introduced in 2005's PowerBooks, 'safe sleep' (or 'hibernate mode' as it's known in the Windows world) is a feature designed to preserve the current state of your Mac when you put it to sleep. Enabled by default on Apple's notebooks, the feature writes the entire contents of your RAM onto the hard disk when you put your Mac to sleep. The practical upshot of this is if your Mac loses power, the next time you start it up everything should be restored to exactly the way it was when you put your Mac to sleep. If you're running OS X Lion, this feature may sound very familiar. That's because it somewhat parallels the functionality of Lion's Autosave and Resume features, which also allow you to pick up where you left off, even after a power failure or a discretionary reboot. For that reason and several others, safe sleep mode seems like an unnecessary feature for most OS X Lion users. I've disabled it on my Mac, and if you're running Lion, you may be interested in doing the same thing on your own Mac. Even if safe sleep does duplicate features already built into OS X Lion, why even bother disabling it? I did it for two reasons. First, if the system has to write the contents of your RAM to the hard disk every time you put your Mac to sleep, it could take a long time for your Mac to actually fall asleep. While this process is relatively fast on the new SSD I just installed, on my old and extremely slow HDD it could take a minute or more for my Mac to actually fall asleep. If you're in the (bad) habit of grabbing your laptop and tucking it away in your bag before the pulsing power light tells you the machine is fully asleep, you could be moving your machine just as the drive is trying to write out the data for the sleep image; that's a prescription for drive trouble down the line. The second reason I disabled safe sleep was because of the large amounts of hard drive space it consumes. The 'sleep image' generated by safe sleep isn't restricted to the amount of RAM you're actively using; instead, it's equal to the entire amount of your RAM. On my system, this meant 6 GB of drive space was being consumed by the sleep image, and since I can think of many better uses for all that space, I decided to get rid of it. If you've now decided that you also want to disable safe sleep, you have a few options. SafeSleep is one third-party app that can get the job done for free, but be warned it's no longer being updated or supported. SmartSleep may be a better option, and it's even available on the Mac App Store, but it does cost US$3.99. A few other third-party solutions exist; those are just the first two that came to mind. However, it seems these solutions merely toggle your Mac's sleep mode and don't do anything to get rid of the space-consuming sleep image. Another option, for those of you who aren't afraid of the OS X Terminal, is to input the following commands (which will require you to enter your admin password): To remove the sleep image file: sudo rm -rf /var/vm/sleepimage To disable safe sleep mode: sudo pmset hibernatemode 0 Whether you use one of the third-party utilities or the Terminal commands, you'll now have reclaimed a portion of your hard drive space equal to the amount of RAM you have installed in your Mac. If you have Lion's Resume feature enabled, you shouldn't be losing out on anything by disabling safe sleep on your Mac. Resume plus Autosave accomplishes essentially the same thing, but without consuming unnecessarily huge swathes of your disk space and without making it take forever to put your Mac to sleep. There is one caveat to this: applications not yet updated with full Lion compatibility may not support Resume or Autosave features. If you find yourself heavily reliant on these apps and don't want to risk losing your data, you may want to leave safe sleep enabled despite the potential benefits of disabling it.

  • Make a backup copy of the MacBook Air USB Software Reinstall Drive

    by 
    TJ Luoma
    TJ Luoma
    07.14.2011

    Since it doesn't come with an optical drive, giving MacBook Air buyers a DVD of the operating system wouldn't be very helpful. That's why Apple's lightest laptop comes with the USB Software Reinstall Drive -- a very small white USB drive. Sometimes USB flash drives are referred to as "Thumb Drives," but this one is more like the size of a baby's finger. The USB stick that comes with the MacBook Air is the best way -- and in many situations, the only way -- to restore/reinstall your MacBook Air if something goes wrong. If you have the US$100 external USB SuperDrive, then you can try to use a DVD, but I found that my MacBook Air wouldn't even boot from my original Snow Leopard DVD. (I believe this is because the DVD's build of Snow Leopard is a lower version number than the Air originally shipped with, but I am not sure.) Since my MacBook Air first arrived I have been afraid of losing the USB recovery drive. According to someone on the Apple Discussion Forums, Apple may be willing to provide you with a new one, free of charge, if you lose yours, but what I really wanted was a backup. (I have done the same thing with my Snow Leopard DVD when I bought it, just in case it was lost or damaged.) In this case, I wanted to duplicate it onto another USB drive. I tried 'cloning' the Reinstall Drive using SuperDuper!, which completed without error, but after it was done, my MacBook Air would not boot with the new USB drive. Apple created the drive so that when it is mounted by OS X, it appears as a DVD, not a USB drive. This means that it was not available for me to use as a "Restore" source in Disk Utility. I could not find any way to make a copy of the disk image from Disk Utility. (If one exists, I'd be happy to hear about it.) That's when my GeekInstincts kicked in. If Apple wanted me to treat it as a DVD drive, that's exactly what I would do. In the past I have backed up my OS X DVDs using the Terminal, and I wondered if the same thing would work here. (Spoiler alert! It did.) Duplicating a CD or DVD the Unix way Rather than using a GUI program such as Roxio Toast or Burn, we're going to use the Terminal. Why? Because unlike those two programs, the Unix way is free, simple, and "just works." Plus, you end up with a disk image, which you should be able to use to burn an actual DVD on just about any computer. The steps are fairly simple: Create an .iso file of the official Reinstall Drive Mount the .iso file in Disk Utility Mount a generic USB drive Use the "restore" function in Disk Utility to copy the .iso file to the generic USB device. Save the .iso file in case you lose the Reinstall Drive and your generic backup. Note: you can do this same process with any CD/DVD and any Mac. In the past I have done it with Microsoft Office, iWork, and others. This article is addressing the MacBook Air specifically, but the same steps would work equally well for other media. The Disclaimer We are going to be using Terminal.app (found in the /Applications/Utilities/ folder in the Finder) to run a few commands. If you are not careful in the Terminal, you can do some serious damage. Then again, the same thing is true about a car. So, look both ways, stop if you aren't sure about something, and (whenever possible) copy & paste commands rather than typing them manually, to avoid typos. The command we will be using is /bin/dd, which I suggest you think of as "Data Duplication." Wikipedia says that it probably originally meant "Data Description," and it is often jokingly referred to as "data destroyer" or other scary-sounding names. Read slowly, take your time. There should be no real danger unless you are extremely careless. Don't proceed unless you know what you are doing and have verified your backups. Step By Step 1) Insert your Reinstall Drive and make sure it appears in the Finder 2) Open Terminal.app (in Finder press Command-Shift-U to quickly go to the Utilities folder) 3) In Terminal, type (or paste) these following commands: DEVICE=`mount | fgrep 'Mac OS X Install' | awk '{print $1}'` if [ "$DEVICE" != "" ]; then ; echo $DEVICE ; fi You should see something like "/dev/disk?s?" where the ?s are replaced by numbers. If all you get a blank line, something went wrong. Make sure the drive appears in Finder. 4) Still in Terminal, type/paste this line: diskutil unmount "/Volumes/Mac OS X Install" which should tell you "Volume Mac OS X Install on disk?s? unmounted" (again, where ? and ? will be numbers). This will unmount but not eject the drive. 5) READ this entire step, and make sure you understand it, before you do anything. Now we will tell dd to: a) read input from the "$DEVICE" named above. This is the "Input File" which is identified using if=/dev/disk?s? (where ? are numbers) b) copy what you read (in step 'a') out to a new file. This is the "Output File" which is identified using of=WhateverYouWant.iso (I went with airinstall.iso for simplicity and clarity). c) We also need to tell dd to use a Block Size of 2048 (this last part may not be 100% necessary, but I have seen it suggested and it is how I have done mine, and it worked). If you put all of that together, it should look like this: /bin/dd if="$DEVICE" of="$HOME/Desktop/airinstall.iso" bs=2048 WARNING: if, by some bizarre chance, you already have a file named "$HOME/Desktop/airinstall.iso" be sure to move or rename it before you enter that line. Otherwise it will be overwritten. (The Output File does not have to be saved to the Desktop, I just chose that because it is a place most people will notice.) If you see an error "dd: /dev/disk?s?: Resource busy" then the device did not unmount properly in step #4. If you copied my "DEVICE=" line above in Step #3, you should be able to use "$DEVICE" in the 'dd' line to automatically fill in the proper device. Note! the 'dd' command may run for 20–30 minutes, or longer. Don't panic. Just go do something else for awhile. nothing new will appear on the screen until 'dd' is finished. When it is done you should see something like this: 3738954 0 records in 3738954 0 records out The "records in" should equal the "records out" (although your number might not be the same as mine). 6) Assuming everything went as expected, you can now tell the computer to eject the Apple Reinstall Drive by entering this line in Terminal: diskutil eject "$DEVICE" It should tell you that the device was ejected. If so, it will be safe to physically disconnect the Apple Reinstall Drive from the USB port of your computer. 7) Open the .iso file in Disk Utility. If you used my /bin/dd line above, you can now enter: open -a "Disk Utility" "$HOME/Desktop/airinstall.iso" and Disk Utility will open and the .iso will appear in the left sidebar. Note: we are now done with Terminal.app. You may quit it and switch over to Disk Utility for the next steps. 8) You should see airinstall.iso in the left side of Disk Utility window. If you look at the bottom of the window you will see it is not mounted. Click the "Open" button on the top toolbar to mount the .iso file. NOTE: When you mount the .iso file, Finder will probably jump up and show you the window like an excited schoolchild. If that happens, just switch back to Disk Utility. This is what Disk Utility will look like after you mount the .iso: Note that the capacity it shown, and the open button is now a greyed out "Mount" button, and the "Eject" button is now available. 9) Insert your generic USB drive now. You will need an 8GB USB drive. I'm usng a SanDisk because it's what I already had. Here is Disk Utility showing my USB drive. A few important things to notice: Make sure the drive is formatted as "Mac OS Extended" or "Mac OS Extended (Journaled)." The "Name" of your drive isn't important. Notice mine is "USB_MOUNT" but the important thing is that I have it selected in Disk Utility. 10) We are now going to tell Disk Utility to "Restore" the .iso's "Mac OS X Install" to "USB_MOUNT" by doing three things: a) click the "Restore" button (see red box below) b) Control-Click ("right click") on the "Mac OS X Install" line, and select "Set as source" as shown here. You could also just drag the Mac OS X Install volume over to the Source: field in the right-hand pane. c) Control-Click on the "Name" of your generic USB drive (mine is "USB_MOUNT") and choose "Set as destination." Again, you could alternatively drag-and-drop the volume icon into the blank Destination field on the right side, per the onscreen instructions. 11) When you are ready to restore, it should look something like this: If everything looks correct, click the "Restore" button on the bottom right. Disk Utility will give you a "human readable" explanation of what it is about to do: Read through it to make sure that you haven't accidentally swapped the Source and Destination fields. When you click "Erase" OS X will prompt you for your administrator password. Once you enter it, the restore process will begin. This took 30 minutes on my MacBook Air, so it's a good time to take that Apple Software Reinstall Drive and put it somewhere safe. (I highly recommend putting it back in the box your MacBook Air came in. You kept the box, right?) Once the Restore Process completes, Finder will most likely mount the generic USB drive. Disk Utility will look like this: Now we're ready to test it, so quit all of your applications, logout, and shutdown the computer. The Proof is in the Booting The only real test that matters is whether or not you can boot your MacBook Air with the generic USB drive. After the computer id turned off, make sure that: the official Apple Softwware Reinstall Drive is not connected to your MacBook Air the generic USB drive is connected to the MacBook Air Then power the computer on and press the Option/Alt key. In a few moments you should a screen offering the option of booting from your hard drive or the USB drive. Choose the USB drive. When it finishes booting, it will start into the "Install OS X" screens and ask you to select a language. Don't panic. Select a language, and then at the next screen you can exit out of the installer. (If you want to set an Open Firmware Password, this would be a good time to do it, since you can't set it when booting off the internal drive, but if you do, remember that if you forget the password, a trip to the Apple Store is your only hope of recovering it.) That's it The USB drive won't work on any other computer, but it can add a little peace of mind to know that you have another copy of your restore drive in case you ever need it.

  • Terminal Tip: Find out which files won't be backed up

    by 
    Samuel Gibbs
    Samuel Gibbs
    04.12.2011

    Backing up is one of the most important things you can do on a Mac, and thankfully, it's a pretty trivial affair with Time Machine built right in. Of course, when you're looking at what needs backing up, people often overlook what doesn't need backing up (or isn't, but should be). A good example of this would be a rented media file, like a TV show rented from iTunes. It's only valid for 48 hours, so even if you do back it up, by the time you've restored your machine after a system failure, it's unlikely to play anyway. In essence, it's wasted space. Thankfully, OS X has a built-in system of defining what should and shouldn't be backed up using metadata, and for the most part, it happens under your nose without you even noticing. There are times when it would be useful to see what's marked for backup and what's not, however, and that's where we turn to Terminal.

  • Terminal Tips: More reliable SSH connections to your Back to My Mac hosts

    by 
    TJ Luoma
    TJ Luoma
    11.10.2010

    Back to My Mac is a feature of MobileMe that allows you to connect remotely to your Macs. Usually this is for screen-sharing or file-sharing through the Finder, but you can also connect via SSH. In the Terminal app (found in /Applications/Utilities/), you can connect via Shell » New Remote Connection, then click the "Secure Shell (SSH)" item, then the computer you want to connect to under the "Server" column. But what if that doesn't work? In that case, I have two suggestions for you: first, use SSH v2 and IPv6. Perhaps it's best to show you the command and then explain it: ssh -2 -6 imac.luomat.members.mac.com -v The "members.mac.com" is consistent for all users. "luomat" is my MobileMe username. "imac" is the hostname of my Mac. See System Preferences » Sharing if you don't know what your computer's name is, or to change it. The "-2" tells SSH to only try SSH protocol version 2, and the "-6" tells SSH to only use IPv6 addresses. The "-v" tells SSH to be "a little" verbose in its output. That part is optional. You could also use -vv or -vvv if you want more verbosity. So far, this method has given me even more success than my DynDNS hostname, which I described before. Before you worry about the security implications of giving people my MobileMe hostname, I should mention that it seems to be impossible to connect to BTMM hostnames unless you are connecting from another computer that is logged into that same MobileMe account. If you have spaces in the computer's name, they are usually replaced with "-" and punctuation is ignored. So, "John's iMac" becomes "Johns-iMac" in the SSH command. Marco Arment also figured out that if you have a period in the hostname or MobileMe username, you should escape it with a \ so that "john.doe" becomes "john\.doe" when you are connecting via SSH. Of course, to be able to connect to your remote Mac via SSH, you must have enabled "Remote Login" under System Preferences » Sharing.

  • Terminal Tips: bash cron script to keep an app running

    by 
    TJ Luoma
    TJ Luoma
    10.21.2010

    Do you have some apps that you want to keep running all the time? If so, and if you're not afraid of the Terminal or the command line, I have a script for you. When I come home at the end of the day, Dropbox has stopped running on my iMac. I'm running the latest version, and it works fine on my MacBook Pro, but for some reason, this just keeps happening. The script has nothing to do with Dropbox itself; you could substitute any app that you always want running, such as LaunchBar, OmniFocus, 1Password, or any other app that you like. It's fairly simple: #!/bin/sh PATH=/bin:/usr/bin # Change 'Dropbox' to whatever app you want. Be sure to capitalize # it correctly and include any spaces. You do not need to add .app APPNAME="Dropbox" # if the app name _IS_ found in process list, exit ps xc|fgrep "${APPNAME}" >/dev/null && exit 0 # if the app isn't found, open it open -a "${APPNAME}" exit 0 That's it. Now, you save the file (I call mine "keep-my-app-running.sh"); I saved it to ~/bin/, but you can put it anywhere you want. Be sure to type 'chmod +x /Users/luomat/bin/keep-my-app-running.sh' (or wherever it is saved) to tell OS X it is an eXecutable file. (Thanks to Justin for reminding me about this in the comments below.) Now, we need to tell cron to run it. Some folks will tell you to use launchd, but cron works well and it's easy, so we'll use that. To do that, create a ~/.crontab file using your favorite text editor. If it already exists, just keep whatever's there, and add this line at the bottom: */5 * * * * /Users/luomat/bin/keep-my-app-running.sh Change "luomat" to whatever your login name is, and change "keep-my-app-running.sh" to whatever you named the script. This tells cron to check if your app is running every 5 minutes or so. You can change the 5 to something else if you want to change the frequency. The last step is to tell cron to load the new file you've created: crontab ~/.crontab If you want to verify that it worked, run 'crontab -l' to see if your crontab is listed properly. It may also be a good idea to run 'crontab -l' before you begin in order to make sure that there isn't anything already in there. Most likely there isn't, or if there is, you already know about it. Update: As noted in the comments, cron works fine, but launchd can be configured to relaunch Dropbox as soon as it exits. I've enclosed a picture of a Lingon screenshot below, or you can see the plist that it creates. Lingon is no longer developed, but it works fine for me under Snow Leopard. I tried to use launchd to run a script at 0, 15, 30, and 45 minutes past the hour, which I can do in cron using this: */15 * * * * /path/to/script.sh but launchd didn't keep that schedule (for example, it posted at 11:48 and 12:03). So I decided to keep using cron for that, although launchd is a much better option for the 'keep alive' purpose. %Gallery-105694%

  • How to kill that Ping drop-down in iTunes 10

    by 
    Dave Caolo
    Dave Caolo
    09.30.2010

    Apple recently updated iTunes to version 10.0.1 which, among other things, added drop-down access to Ping, Apple's social network for iTunes customers, into your library. Some of you like Ping more than others, and there are those in the latter group who are completely disinterested. The Mac Observer explains how you can eliminate that drop-down menu from iTunes 10 entirely. The procedure is simple. First, quit iTunes, launch Terminal and enter the following: defaults write com.apple.iTunes hide-ping-dropdown -bool TRUE Finally, quit Terminal and re-launch iTunes. Presto! The drop-down is gone. The Mac Observer also describes how to restore the menu as well as how to re-orient the control buttons in the upper left-hand corner to a horizontal, rather than vertical, position. Hop over to find out how.

  • Terminal Tips: Generate random filenames for digital photo frame images

    by 
    Aron Trimble
    Aron Trimble
    02.25.2010

    It's not at all unlikely that you or a relative have received a digital photo frame as some sort of gift. The concept is great, one frame on your mantle, many pictures on display. Unfortunately, Apple has yet to enter the photo frame market -- at least until the iPad is released, that is. In the interim, we are stuck dealing with photo frames that look good but do not always function as we expect. One example of a photo frame feature gap is the lack of ability to "shuffle" photos so that they can be displayed in a random order. While sitting at my grandma's house for hours on end, it quickly became a personal challenge to try and successfully guess the next photo that would appear. Luckily, the screencast junkies over at Murphy Mac have found a somewhat simple solution to this conundrum. The problem is the result of frames using the all-too-common alphabetical sorting method when showing photos. While this is useful for organization, it is less helpful for the purposes of the photo frame. The answer lies in assigning totally random filenames to your digital photos. As the title indicates, this is a Terminal.app-based tip so you'll have to get your hands a little dirty with this one. The process is something that could take a long time, especially when you consider that many photo libraries have thousands of images. However, through the power of Terminal and the use of a for-loop, it is possible to randomly rename an entire folder of images with one fell swoop. To begin, you will need to place all of your images in a single folder. We here at the TUAW HQ cannot recommend strongly enough using copied image files and triple-checking your backups prior to moving forward. Open up Terminal.app and use cd to navigate to the new directory where you placed your image copies (now might be a good time to check your backups a fourth time). When done, type the following command and then press return. for i in *.jpg; do mv $i $RANDOM.jpg; done Assuming all of your photos are jpegs and located in same directory, then after some whizzbangery you will have a folder filled with very strangely-named images. Copy these files to your photo frame and you now have a fully randomized photo slideshow. Feel free repeat as often as your guests (or your OCD) require. Got any other handy Terminal tips? Feel free to share them in the comments!

  • TUAW Tip: Moving your home folder to another disk (or moving it back)

    by 
    Robert Palmer
    Robert Palmer
    05.14.2009

    In ye olde times, with "Mack OSe 9," many users chose to keep their personal files, work, and documents on a different physical disk from their startup disk. It was a safety measure: If one disk goes down, at least the other won't. There was no structural reason to keep files in a particular disk location, other than keeping them out of the System Folder. I visited a client yesterday whose drive scheme was set up exactly like this, and he wanted to be (finally) upgraded to Leopard. I wasn't sure how Leopard would handle the fact that his Users folder had been moved to a different drive, so (knowing I had backups of his entire system) I cautiously proceeded with the installation. After the installer finished, Leopard had created a fresh, blank Users folder on the startup disk with a home folder bearing the same username. This wasn't exactly the answer I was looking for. I had to link, somehow, the new Users/hisname folder with his existing user folder on the other volume. Turns out, Leopard handles this much better than previous versions of Mac OS X. Read on to find out how.

  • Safari 4 hidden preferences

    by 
    Mat Lu
    Mat Lu
    02.25.2009

    There's quite a debate going on in the Mac web over Safari 4's new user interface. Personally, I think the new tab implementation is hideous, so I was glad to see that Caius Durling has discovered a bevy of hidden preferences for Safari 4.With a few quick Terminal commands you can restore sanity to your tabs, bring back the old URL completion behavior, remove CoverFlow from the Bookmarks view, and few other neat tricks. On the other hand, if crazy tabs float your boat, they're easy enough to restore in the same way.[via Download Squad]

  • iLife Tip: Enable Multi-Touch maps in iPhoto '09

    by 
    Cory Bohon
    Cory Bohon
    01.28.2009

    After using iPhoto '09 for a couple days, I have come to love the new features, in particular the Places feature. However, one thing that annoyed me is that you cannot use the Multi-Touch feature on newer MacBooks to manipulate the maps (zooming in/out, etc.). However, thanks to a Tweet-tip from Steven Troughton-Smith (@stroughtonsmith), there is a way to enable this functionality. To add Multi-Touch maps to places in iPhoto '09, just open Terminal.app (/Applications/Utilities) and type (or copy/paste) the following statement and press enter: defaults write com.apple.iphoto MapScrollWheel -bool YES When you restart iPhoto, you will notice that you are now able to scroll in/out of the Places maps with ease. If it turns out that you don't want the scrolling feature, just retype the statement, replacing "YES" with "NO." Thanks for the tip, Steven!

  • Terminal Tip: Enable half-star ratings in iTunes

    by 
    Cory Bohon
    Cory Bohon
    12.31.2008

    Do you like giving ratings to songs in iTunes? If so, then you've probably noticed that you are only able to rate songs on a full-star basis, not enough granularity for some music fans... there's a longstanding AppleScript hack to enable half-stars, but now there's an easier way around this issue. Macworld's Rob Griffiths found a work around, involving a simple Terminal tip to enable half-star ratings. To enable half-star ratings, close iTunes, and open Terminal (/Applications/Utilities). Once you have Terminal opened, type the following command and press enter: defaults write com.apple.iTunes allow-half-stars -bool TRUE When you reopen iTunes and rate a song, you will be able to give half-stars. That simple. If you wish to make things normal again, open Terminal and type the same command, replacing "TRUE" with "FALSE."

  • Terminal Tip: Change Time Machine backup interval

    by 
    Cory Bohon
    Cory Bohon
    12.08.2008

    Sometimes you want your Mac to be backed up more frequently than usual. If you want to instantly back up using Time Machine, you could click on the menu bar item and select "Back Up Now," but what if you want to change the backup interval indefinitely? With this Terminal Tip, you can do just that. Time Machine is set to automatically back up every hour, but if you would like to change it to every half hour, you can use the following Terminal (/Applications/Utilities) command: sudo defaults write /System/Library/LaunchDaemons/com.apple.backupd-auto StartInterval -int 1800 You will need to authenticate as an administrator, since this command is run under a "sudo." The time interval is measured in seconds, so you can enter any time you wish there; just make sure it is in seconds. By default, Time Machine backs up every 3600 seconds (every hour). If you wish to revert to the original, just replace "1800" with "3600."Want more tips and tricks like this? Visit TUAW's Terminal Tips section!

  • Terminal Tips: Play Tetris in Terminal

    by 
    Cory Bohon
    Cory Bohon
    10.01.2008

    Terminal boasts some cool, but hidden features that we like to call "Easter eggs." These "eggs" are hidden features that the developers build in (mostly for fun or laughs), that don't have anything to do with the functionality of the program.One of these "eggs" is the ability to play Tetris in Terminal. Here's how to do it. First, open a new Terminal.app (/Applications/Utilities) window and type "emacs," then hit enter. After the screen loads, press "escape," then "x." Type "tetris" (lower-case) and hit enter. There you have it, a fully playable game of Tetris. Use the arrow keys to control the blocks.Want more tips and tricks like this? Visit TUAW's Mac 101 and Terminal Tips sections.

  • Terminal Tips: Make extended print dialog show by default

    by 
    Cory Bohon
    Cory Bohon
    09.15.2008

    When you print something in Mac OS X, the standard print dialog window will pop up. However, if you always use the extended options (such as landscape/portrait orientation, number of copies, etc.) then you might have to click the blue arrow constantly. With this Terminal hack, the print dialog will open with the extended options already shown by default. Just open Terminal.app (/Applications/Utilities/) and type in the following command: defaults write -g PMPrintingExpandedStateForPrint -bool TRUEIf changing back to the original settings makes you happy, then replace "TRUE" with "FALSE" in the command above. Want more quick Mac tips like this? Visit TUAW's Mac 101 and Terminal Tips sections.

  • TUAW Tip: Highlight items in gridded stacks

    by 
    Giles Turnbull
    Giles Turnbull
    07.17.2008

    The Dock's Stacks feature lets Leopard users view a folder's worth of stuff with one click. You'll either love it or hate it, use it or not. If you do use it, here's a little tip that improves it slightly (in my opinion).When you've got a bunch of files from a Stack displayed in Grid View, it can be hard to spot the particular one you're looking for, especially if many of them look identical (such a collection of text files or word processor documents). Luckily, there's a highlight you can switch on, that puts a whiter background around the file you're mousing over. It makes it slightly easier to ensure you click on the correct file.The highlight appears normally if you use the arrow keys to move around a Grid, or if you type Command and the first letter of one of the files displayed. But this trick switches it on permanently, so that it is always in action whether or not you use these keyboard shortcuts.Read on for all the commands.

  • Terminal Tip: Command Line Calculator

    by 
    Erica Sadun
    Erica Sadun
    04.24.2007

    Mac OS X ships with a powerful and useful command-line calculator called bc. GNU bc provides an arbitrary precision calculator that allows you to type in expressions for immediate calculation. It uses the standard conventions for computer arithmetic, i.e. + and - are addition and subtraction, * and / are multiplication and division, ^ is exponentiation. So to multiple, say, 193 by two thirds, you'd enter 193 * 2 / 3 and press return. Parentheses set the order of evaluation, just as they would in a normal arithmetic statement or in a computer language. e.g. (20 / 3) ^ 5 performs the division before the exponentiation. You can also use variables with bc. Just assign them using an "=" command. For example, you can set your principal to 100 with principal=100. The special scale variable indicates the number of digits to show after the decimal point. Enter quit to leave bc. There's a lot more you can do with bc--it's really a full interactive programming language that goes way beyond the simple convenience of quick calculations. To learn about bc, type man bc from the command line.

  • Monday man page: curl

    by 
    Michael Rose
    Michael Rose
    03.05.2007

    Today's man page covers one of my favorite utilities: curl. No, it's not a haircare product -- it's one of the most flexible download tools in the kit bag, with the ability to handle almost any protocol that can be addressed via a URL (hence the name, short for "client for URLs"). If there's a server out there that's reachable via HTTP, HTTPS, FTP, SFTP, SCP, and lots of other alphabet soup, curl can talk to it. curl http://www.tuaw.com/2007/03/05/monday-man-page-curl/ -- display the source of this very article in Terminal curl ftp://ftp.panic.com -- list the contents of a remote FTP site, in this case one with a pretty good FTP client curl -o ~/Desktop/curl-man.html http://curl.haxx.se/docs/manpage.html -- copy the curl manpage to your desktop; if you use capital -O, the local file mirrors the remote filename curl has an excellent usage manual at its site, detailing examples of use and advanced techniques. While there are zillions of ways to use curl in site testing, analysis and uploading, my favorite way of using it is as a quick file downloader. Read on for the details.

  • Monday man page: open

    by 
    Michael Rose
    Michael Rose
    02.12.2007

    Just a quick hint for today's man page: the open command does just what you might think. It opens files, directories, applications or URLs; no muss, no fuss. For files, you can specify an application to open them with the -a flag (or just trust LaunchServices to pick the right app). If you want to, the -e flag will force them to open in TextEdit. open ~/Desktop/MyWordDoc.doc [will open in MS Word] open -e ~/Desktop/MyWordDoc.doc [will open in TextEdit] open ~/Desktop/*.doc [opens every Word document on the desktop, in Word] open http://tuaw.com [well, give it a go!] I use open in installation scripts or other situations where I want a GUI application to come up at the end of a process. For example, open /System/Library/CoreServices/Software\ Update.app/ launches Software Update and begins checking for available patches. Sure, you can force an update with 'softwareupdate -i -a' anytime, but maybe I want to give the person sitting at the console an opportunity to select the updates needed, or cancel out of the possibly-lengthy update cycle until it's more convenient. You could also use the URL functionality to take people to a 'readme' website... the possibilities are manifold.

  • Monday man page: lsof

    by 
    Michael Rose
    Michael Rose
    02.05.2007

    Happy hangover Monday everyone! To soothe those post-big-game blues, here's this week's man page -- lsof, the LiSt Open Files tool. If you're trying to figure out why a removable drive won't unmount or track down a stray outbound network connection, this is the tool for you. Note: If you want to stay out of the command line but still accomplish some of the same tasks, a reader suggests you check out Sloth. Written by Vic Abell of Purdue University (now retired), the power and flexibility of lsof has given it the distinction of reputedly having more command-line flags than any other tool: lsof [ -?abChlnNOPRstUvVX ] [ -A A ] [ -c c ] [ +c c ] [ +|-d d ] [ +|-D D ] [ +|-f [cfgGn] ] [ -F [f] ] [ -g [s] ] [ -i [i] ] [ -k k ] [ +|-L [l] ] [ +|-m m ] [ +|-M ] [ -o [o] ] [ -p s ] [ +|-r [t] ] [ -S [t] ] [ -T [t] ] [ -u s ] [ +|-w ] [ -x [fl] ] [ -z [z] ] [ -- ] [names] Yee-ikes. Let's get two quick tips taken care of before we move on to the details. First, you probably don't ever want to run lsof with no options specified, as that will generate a list of every open file on your machine (likely thousands of lines). Second, for a quick review of all those options, try lsof -h. More after the break...