Monday, November 30, 2015

Edit the Host file in Mac OS X Yosemite

The hosts file is used by your computer to map hostnames to IP addresses. By adding or removing lines to your hosts file you can change where certain domains will point when you access them in a browser. This can be used used for web development purposes, i.e. to redirect domains to local addresses.

Step 1: Launch Terminal

Step 2: Type the following command at the prompt to backup hosts file to documents folder:

Always make a Backup of your host file before making any changes just in case you make a mistake or typo

sudo cp /private/etc/hosts ~/Documents/hosts-backup


Step 3: Type the following command at the prompt to open hosts file:


sudo nano /private/etc/hosts


Step 4: Enter the administrator password when requested

Step 5: Once the hosts file is loaded, navigate to the bottom of the hosts file to make your modifications

Step 6: When finished, hit Control+O followed by ENTER/RETURN to save changes to /private/etc/hosts, then hit Control+X to exit out of nano

Step 7: Verify your hosts modifications.

I recently used this to setup PressPi on my Raspberry Pi.

Wednesday, August 26, 2015

Securely Erasing Free Space in Mac OS X

There are two ways to erase free space in Mac OS X, one is using the GUI application Disk Utility, the other is using Terminal.

The one-line Terminal command to scrub free space of existing data is

diskutil secureErase freespace 3 /Volumes/"drive"

You can get the name of your drive by using the following two basic commands to look up the available system drives:

cd /Volumes/

ls


This will list the available drives, which you can copy and paste into the above command for the "drive" path. The command will write to each drive sector 35 times. Thirty-five passes is well above the U.S. Department of Defense’s own standard 7 pass standard for erasing data. Note that with large capacity drives, this process may take a very long time (perhaps hours or days) to complete due to the capacity and work that needs to take place to do a 35-pass wipe of the data. Though I used Yosemite 10.10 this should work no problem in Snow Leopard 10.6, Lion 10.7, Mountain Lion 10.8, Mavericks 10.9, or El Capitan 10.11

Monday, August 24, 2015

Changing screenshot file formats Mac OS X

Using terminal it is easy to change the file format that screen shots are captured by the Mac OS X system.  Simply open up terminal and enter the following command.

defaults write com.apple.screencapture type "extension"

Replace the "extension" word in the command above with the name of the file extension that you actually want as a screenshot. 

For JPG you could type the following command:

defaults write com.apple.screencapture type JPG

You can use PDF, GIF, PNG, and others

Though I used Yosemite 10.10 this should work no problem in Snow Leopard 10.6, Lion 10.7, Mountain Lion 10.8, Mavericks 10.9, or El Capitan 10.11

Saturday, August 22, 2015

Show Hidden Files in Mac OS X

To quickly show hidden files in Mac OS X open up terminal and enter this command. Warning any files that begin with a dot are flagged by UNIX as hidden files. These files can be system or preference files that are required by the system to handle folder and file management. Be careful and cautious before deleting or editing any files that don't look familiar to you. I recommend backing up your system or files before deleting hidden items


defaults write com.apple.finder AppleShowAllFiles TRUE

To hide these files again just change TRUE to FALSE


Though I used Yosemite 10.10 this should work no problem in Snow Leopard 10.6, Lion 10.7, Mountain Lion 10.8, Mavericks 10.9, or El Capitan 10.11