Top 20 OS X command-line secrets for power users

By Mel Beckman, InfoWorld |  Software, command line, Mac OS X

When you click the Wi-Fi icon in OS X's menu bar (called AirPort before OS X Lion), you get a list of available wireless networks. The airport command-line utility does the same and a lot more. It shows you the numeric signal strength for every access point, the channel used, and the encryption level, if any.

Alas, the airport command-line utility is buried deep in the System directory (aka System folder when using OS X's GUI). But you can create a symbolic link to it using the one-time command below. Then just type airport -s in the Terminal's command line to get the detailed scan report. (Hint: If you don't get any output, turn Wi-Fi on in the Network system preference.)

To create a symbolic link to the airport command:

$ sudo ln -s /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport /usr/sbin/airport

To run a wireless scan:

$ airport -s

Sample results:

SSID BSSID RSSI CHANNEL HT CC SECURITY (auth/unicast/group)

air4 90:84:0d:c2:c2:c2 -74 1 Y US WPA2 (PSK/TKIP/TKIP)

MY408G1 00:26:b8:c2:c2:c2 -82 6 Y US WEP

air4 00:24:36:c2:c2:c2 -27 11 Y US WPA (PSK/TKIP/TKIP)

G00NOO7 00:18:01:c2:c2:c2 -70 11 N US WEP

air4 5G 90:84:0d:c2:c2:c2 -87 36,+1 Y US WPA2 (PSK/AES,TKIP/TKIP)

air4 5G 00:24:36:c2:c2:c2 -35 157,+1 Y US WPA2 (PSK/AES,TKIP/TKIP)

2. caffeinate: Prevent a system from sleeping

This command is new in OS X Mountan Lion. Let's say you started a long-running file transfer just before lunch and don't want your system to go to sleep. What do you do? Give it some caffeine! That's what caffeinate does. You can explicitly specify an elapsed period of wakefullness, in seconds, with the -u and -t options, or you can use caffeinate to invoke a command-line utility that you want to not be interrupted by sleep.

To prevent your Mac from sleeping for one hour (3,600 seconds):

$ caffeinate -u -t 3600

To prevent your Mac from sleeping until the secure file copy (scp) completes:

$ caffeinate -s scp bigfile me:myserver/bigfile

3. curl: Download a URL from the command line (copy URL)

A powerhouse of a command-line utility, curl lets you do many things, but the most handy capability is retrieving a file from a website. Just pass the URL to curl and tell it where to deliver the load via the --output option, as demonstrated below. You'll find curl can rename the file at the same time, or it can download entire website directories -- recursively, even. Copy the entire Internet if you want. The U.S. government does (via archive.org).

$ curl http://manuals.info.apple.com/en_US/ipad_user_guide.pdf --output ipad.pdf


Originally published on InfoWorld |  Click here to read the original story.
Join us:
Facebook

Twitter

Pinterest

Tumblr

LinkedIn

Google+

Answers - Powered by ITworld

ITworld Answers helps you solve problems and share expertise. Ask a question or take a crack at answering the new questions below.

Join us:
Facebook

Twitter

Pinterest

Tumblr

LinkedIn

Google+

Ask a Question