Useful OS X Yosemite Commands
Manipulating files and viewing folder content is fun, but the command line in OS X Yosemite is capable of so much more! Focus your attention on some of the other useful tasks that you can perform with the command line.
OS X comes stocked with a full set of useful commands. You can discover many of the commands that are installed by viewing the files in /usr/bin. Type cd /usr/bin to navigate there. Other locations to peruse include /bin and /usr/local/bin.
A favorite command line functions is the cal command, which displays a calendar in text form. Simply entering cal at the prompt displays a calendar for the current month.
Append a number to the cal command to display a 12-month calendar for a specific year. For example, to view a calendar for 1970, type cal 1970.
Append a month number and a year number to display the calendar for that month. For example, to view a calendar for April 2014, type cal 04 2014.
Another useful command that’s related to the cal command is date. Type date at the command line to display the day, date, time, and year based on your computer’s settings.
WHITEDRAGON:~ markchambers$ date Sun May 18 11:32:20 CDT 2014
Processes in OS X
Have you ever been curious about why your hard drive seems to spin and grind on occasion while your system is seemingly inactive? OS X sometimes has lots of stuff going on behind the scenes.
To discover what your computer is busy doing at any time, use the top command to display all the actions that your computer is currently performing. These activities are processes; some are created when you launch applications, and others are simply tasks that OS X has to take care of to keep things running smoothly.
Besides listing the names of the various processes currently in use, top tells you how much of your CPU is being devoted to each process. This lets you know what process is currently hogging all your computing power.
Sometimes a process stalls, effectively freezing that action. By using the top command to find the Process ID (PID) of the offending process, you can halt the process. Simply use the kill command followed by the PID of the process you want to stop. (The man help page for the kill command gives more options that may help terminate stubborn processes with prejudice.)
Do not take a cavalier attitude when killing processes! Although OS X is extremely stable, removing the wrong process — such as init or machinit — is rather like removing a leg from one of those deep-sea drilling platforms: the very definition of Not Good. You could lock up your system and lose whatever you’re doing in other applications.
If you simply want to shut down a misbehaving program, go graphical again (at least for a moment) and use the Force Quit menu command from the Apple menu.
Like top, another handy command for examining process info is ps (short for process status). Most often, you’ll want to append a few flags to the ps command to get the information that you desire. For example, try the following command, which displays additional information for each process:
The man page for ps explains what each flag means.