From my blog at: http://mikesalsbury.com/mambo/content/view/162/2/
Like any UNIX based operating system, OS X has a pretty versatile command line. You can do quite a lot with it. For example, I've written scripts that backup an OS X system to a server. Using the SSH capability, I can connect to a Macintosh in another building and run that script, causing the machine to run a backup any time I need it to. Sometimes, as a system administrator, I need to deal with programs that are hanging on the user's Mac and causing problems. Fortunately, I can kill a program like that without ever having to leave my desk. Here's how...
First, you have to have already setup an environment where you can remotely connect to the other Macintosh via the command line. If you haven't done that, or don't know how, here's all it takes:
Now, to connect to a computer setup as above, do the following:
Let's assume that a user has called us to tell us that Internet Explorer seems to be locked up on their Macintosh. We'd like to terminate Internet Explorer for them so that they can save the data in their other programs and reboot the Mac (just to be safe). We connect to their computer via SSH and get to the command line. Now we need to find Internet Explorer in their process list. To do that, we issue the command:
ps -aux
This results in the Macintosh displaying a list of running processes that resembles the following:
USER PID %CPU %MEM VSZ RSS TT STAT STARTED TIME COMMAND
root 1 0.0 0.0 18072 132 ?? Ss 28Jun05 0:00.09 /sbin/init
root 2 0.0 0.0 18608 188 ?? Ss 28Jun05 0:36.65 /sbin/mach_init
root 78 0.0 0.0 18092 184 ?? Ss 28Jun05 0:05.11 /usr/sbin/syslogd -s -m 0
.
.
.
user 8735 0.0 1.2 179316 18452 ?? S 1:23PM 0:09.86 /Applications/Internet Explorer.app/Contents/MacOS/Internet Explorer /Applications/Internet Explorer.app/Contents/MacO
admin 8736 0.0 0.2 150340 2736 ?? S 1:23PM 0:00.26 /Applications/Timbuktu Pro/Timbuktu Pro.app/Contents/SharedSupport/Timbuktu Host Menu.app/Contents/MacOS/Timbuktu Host
admin 8744 0.0 0.2 151164 3040 ?? S 1:23PM 0:00.35 /Library/Application Support/Norton Solutions Support/SymQuickMenu/SymQuickMenu.app/Contents/MacOS/SymQuickMenu -psn_0
root 8745 0.0 0.1 28548 1496 ?? S 1:23PM 0:00.16 /Library/Application Support/Norton Solutions Support/Norton AntiVirus/DiskMountNotify.app/Contents/MacOS/DiskMountNot
admin 8746 0.0 0.1 98788 1300 ?? S 1:23PM 0:00.12 /Library/Application Support/Norton Solutions Support/Norton AntiVirus/ScanNotification.app/Contents/MacOS/ScanNotific
admin 8747 0.0 0.1 98676 1216 ?? S 1:23PM 0:00.15 /Library/Application Support/Norton Solutions Support/Scheduler/SymSecondaryLaunch.app/Contents/MacOS/SymSecondaryLaun
root 8837 0.0 0.3 30740 5488 ?? Ss 1:31PM 0:00.38 /usr/sbin/sshd -i
Notice the line which reads:
user 8735 0.0 1.2 179316 18452 ?? S 1:23PM 0:09.86 /Applications/Internet Explorer.app/Contents/MacOS/Internet Explorer /Applications/Internet Explorer.app/Contents/MacO
This tells us that Internet Explorer has the process ID number 8735 associated with it. Now all we need to do is tell the user's machine to terminate that process. To do that, we issue the command:
kill 8735
This immediately terminates the Internet Explorer process on the user's machine, and should result in them regaining control of their system.
Like any UNIX based operating system, OS X has a pretty versatile command line. You can do quite a lot with it. For example, I've written scripts that backup an OS X system to a server. Using the SSH capability, I can connect to a Macintosh in another building and run that script, causing the machine to run a backup any time I need it to. Sometimes, as a system administrator, I need to deal with programs that are hanging on the user's Mac and causing problems. Fortunately, I can kill a program like that without ever having to leave my desk. Here's how...
First, you have to have already setup an environment where you can remotely connect to the other Macintosh via the command line. If you haven't done that, or don't know how, here's all it takes:
- Go to the Apple menu and choose System Preferences.
- Click the "Show All" icon.
- Under "Internet & Network" click the "Sharing" icon.
- Place a checkmark in the "Remote Login" box.
- Close the System Preferences window. You're done!
Now, to connect to a computer setup as above, do the following:
- Launch a Terminal window.
- Enter the command "ssh <admin>@<machinename>" where "<admin>" is the short name of an administrator account on the remote computer and "<machinename>" is the remote computer's name or IP address.
- If you're prompted about an "RSA key", just enter "yes" at the prompt to continue connecting.
- When the "Password:" prompt appears, enter the password for the administrator account you specified in your SSH command.
- When the next command prompt appears, you are connected to the remote computer and are issuing commands that are running on THAT computer, not yours.
Let's assume that a user has called us to tell us that Internet Explorer seems to be locked up on their Macintosh. We'd like to terminate Internet Explorer for them so that they can save the data in their other programs and reboot the Mac (just to be safe). We connect to their computer via SSH and get to the command line. Now we need to find Internet Explorer in their process list. To do that, we issue the command:
ps -aux
This results in the Macintosh displaying a list of running processes that resembles the following:
USER PID %CPU %MEM VSZ RSS TT STAT STARTED TIME COMMAND
root 1 0.0 0.0 18072 132 ?? Ss 28Jun05 0:00.09 /sbin/init
root 2 0.0 0.0 18608 188 ?? Ss 28Jun05 0:36.65 /sbin/mach_init
root 78 0.0 0.0 18092 184 ?? Ss 28Jun05 0:05.11 /usr/sbin/syslogd -s -m 0
.
.
.
user 8735 0.0 1.2 179316 18452 ?? S 1:23PM 0:09.86 /Applications/Internet Explorer.app/Contents/MacOS/Internet Explorer /Applications/Internet Explorer.app/Contents/MacO
admin 8736 0.0 0.2 150340 2736 ?? S 1:23PM 0:00.26 /Applications/Timbuktu Pro/Timbuktu Pro.app/Contents/SharedSupport/Timbuktu Host Menu.app/Contents/MacOS/Timbuktu Host
admin 8744 0.0 0.2 151164 3040 ?? S 1:23PM 0:00.35 /Library/Application Support/Norton Solutions Support/SymQuickMenu/SymQuickMenu.app/Contents/MacOS/SymQuickMenu -psn_0
root 8745 0.0 0.1 28548 1496 ?? S 1:23PM 0:00.16 /Library/Application Support/Norton Solutions Support/Norton AntiVirus/DiskMountNotify.app/Contents/MacOS/DiskMountNot
admin 8746 0.0 0.1 98788 1300 ?? S 1:23PM 0:00.12 /Library/Application Support/Norton Solutions Support/Norton AntiVirus/ScanNotification.app/Contents/MacOS/ScanNotific
admin 8747 0.0 0.1 98676 1216 ?? S 1:23PM 0:00.15 /Library/Application Support/Norton Solutions Support/Scheduler/SymSecondaryLaunch.app/Contents/MacOS/SymSecondaryLaun
root 8837 0.0 0.3 30740 5488 ?? Ss 1:31PM 0:00.38 /usr/sbin/sshd -i
Notice the line which reads:
user 8735 0.0 1.2 179316 18452 ?? S 1:23PM 0:09.86 /Applications/Internet Explorer.app/Contents/MacOS/Internet Explorer /Applications/Internet Explorer.app/Contents/MacO
This tells us that Internet Explorer has the process ID number 8735 associated with it. Now all we need to do is tell the user's machine to terminate that process. To do that, we issue the command:
kill 8735
This immediately terminates the Internet Explorer process on the user's machine, and should result in them regaining control of their system.