A bootable USB drive is a handy tool if you need to reinstall OS X Yosemite on your Mac, or if you're updating other Macs. To create this drive, download the OS X Yosemite installer from the App store and then use a specific command in Terminal to load it onto the USB disk.
You need a USB disk that is 8GB or larger. OS X formats the drive as part of the process, so make sure to copy any files that are already on the USB drive.
Launch the App Store app on your Mac computer and download the OS X Yosemite installer. To find the installer, type "Yosemite" in the Search field and click the OS X Yosemite "Download" button.
When a dialog box opens warning that you already have Yosemite, click "Continue." Enter your Apple ID password if prompted. The download can take an hour or more, depending on your Internet speed.
Close the Install OS X utility as soon as it opens by pressing "Command-X" or by selecting "Quit Install X" from the File menu.
Note that the OS X Yosemite installer is located in the Applications folder. Don't move this file until you have finished creating your USB boot disk.
Insert the USB disk into your Mac and launch Terminal. To launch it quickly, just type "Terminal" in Spotlight search.
Copy this single line of code and paste it in Terminal:
sudo /Applications/Install\ OS\ X\ Yosemite.app/Contents/Resources/createinstallmedia --volume /Volumes/Untitled --applicationpath /Applications/Install\ OS\ X\ Yosemite.app --nointeraction
This command creates an installation disk from the USB drive using the Yosemite.app file. The option "--nointeraction" sets Terminal to not to prompt you for action, such as requiring you to press "Y" to continue.
Press the "Enter" key. Note that this command requires that the "Yosemite.app" file be in the Applications folder. To copy the files and configure the drive takes about a half an hour.
Close Terminal when it is finished creating the drive and returns you to the command prompt. Click the "Eject" button beside the USB drive in Finder. Turn off the Mac, insert the USB drive and re-power on the Mac. The Mac will boot from the USB drive and prompt you to install OS X Yosemite.
If Terminal responds that an untitled volume doesn't exist, launch "Disk Utility," select the USB drive and click the "Erase" button. This formats the drive as an "Untitled" volume, which Terminal will recognize.
The terminal command used here is specifically for OS X Yosemite. If you have a copy of Mavericks, put that file in the Applications folder and replace "Yosemite" with "Mavericks" to create a bootable Mavericks disk.
If you insert the bootable USB disk and a Mac computer doesn't boot from it, try putting it in a different USB port.
Never try to install an older operating system onto a Mac with a newer version already installed.
Familiarize yourself with OS X sudo terminal commands and root user permissions before attempting to modify this code for other purposes.