Top 20 OS X command-line secrets for power users

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

$ scp filename userID@remotesystem:/path/to/filename

To copy from the remote system to the local current directory:

$ scp userID@remotesystem:/path/to/filename ./

To copy an entire directory (the -r option indicates recursion):

$ scp -r directoryname userID@remotesystem:/path/to/directory

14. scutil: Set the computer host name

Sometimes you want to change the name of a computer, but there doesn't seem to be an easy way to do this through any system preference or other graphical utility. You can do it with the very powerful scutil tool, although you must run the command three times to change the name in the three places where it resides.

You can do a lot more with scutil in the same way you can do a ton more than drive your car with a gallon of gasoline. Unless you know what you're doing, it's best to let scutil's other abilities stay in drawer.

$ sudo scutil --set ComputerName "newname"

$ sudo scutil --set LocalHostName "newname"

$ sudo scutil --set HostName "newname"

15. shutdown: Restart the Mac

System administrators sometimes have to restart computers when the owner isn't around. Sharing the screen isn't always convenient -- or even enabled. If you can get a remote command-line access to the target machine (such as via the ssh Secure Shell command), rebooting remotely is a cinch using the shutdown command. The -r option indicates you want to restart; without it, the Mac will power off. The now argument means just what it says: Do it now. You can also specify a date and time, in the form yymmddhhmm, to preset a delayed reboot.

$ shutdown -r now

16. sysctl: Get CPU information and other internal secrets

The official purpose of the sysctl utility is to get or set kernel state values. Unless you know what you're doing, you don't want to set kernel state values. But looking at them is harmless -- and can be informative.

For example, the example below displays the machine CPU type, which can be useful to know for certain system administration chores. You can use sysctl to control decisions in a Bash script as well. Run sysctl -a to get a list of all the kernel variables available for inspection. You might find some others you'd like to inspect.

For example:

$ sysctl -n machdep.cpu.brand_string

might display:

Intel(R) Core(TM) i5 CPU 750 @ 2.67GHz

17. systemsetup: Perform various system configuration operations

The systemsetup command lets you retrieve and alter a wide range of configuration values normally set from the graphical System Preferences application. Run systemsetup help to get a complete list of options.


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

Twitter

Pinterest

Tumblr

LinkedIn

Google+

SoftwareWhite Papers & Webcasts

See more White Papers | Webcasts

Answers - Powered by ITworld

Join us:
Facebook

Twitter

Pinterest

Tumblr

LinkedIn

Google+

Ask a Question