<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Art Of Geek &#187; Terminal</title>
	<atom:link href="http://artofgeek.com/tag/terminal/feed/" rel="self" type="application/rss+xml" />
	<link>http://artofgeek.com</link>
	<description>Technology from the geek perspective.</description>
	<lastBuildDate>Thu, 18 Mar 2010 18:48:30 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=abc</generator>
		<item>
		<title>Toggle display of hidden files in Finder with keyboard shortcut [Update 2]</title>
		<link>http://artofgeek.com/2009/09/16/toggle-display-of-hidden-files-in-finder-with-keyboard-shortcut/</link>
		<comments>http://artofgeek.com/2009/09/16/toggle-display-of-hidden-files-in-finder-with-keyboard-shortcut/#comments</comments>
		<pubDate>Thu, 17 Sep 2009 00:23:43 +0000</pubDate>
		<dc:creator>madgunde</dc:creator>
				<category><![CDATA[Mac OS X]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[Automator]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[bsd]]></category>
		<category><![CDATA[Finder]]></category>
		<category><![CDATA[hint]]></category>
		<category><![CDATA[keyboard shortcut]]></category>
		<category><![CDATA[Services]]></category>
		<category><![CDATA[Snow Leopard]]></category>
		<category><![CDATA[Terminal]]></category>
		<category><![CDATA[tip]]></category>

		<guid isPermaLink="false">http://artofgeek.com/?p=460</guid>
		<description><![CDATA[<p>[Update 2] Still in early Mac OS X 10.6 Snow Leopard discovery mode, I&#8217;ve started revisiting MacOSXHints.com much more regularly to find out what handy undocumented or at least not widely known tricks the new OS has up it&#8217;s sleeve. Today I came across this fantastic tip about how you can toggle the display of [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignright size-medium wp-image-483" title="Toggle Hidden Files" src="http://artofgeek.com/wp-content/uploads/2009/09/Toggle-Hidden-Files-300x141.png" alt="Toggle Hidden Files" width="300" height="141" /><a href="http://artofgeek.com/2009/09/16/toggle-display-of-hidden-files-in-finder-with-keyboard-shortcut/#update_2">[Update 2]</a> Still in early Mac OS X 10.6 Snow Leopard discovery mode, I&#8217;ve started revisiting <a href="http://www.macosxhints.com/">MacOSXHints.com</a> much more regularly to find out what handy undocumented or at least not widely known tricks the new OS has up it&#8217;s sleeve. Today I came across <a href="http://www.macosxhints.com/article.php?story=20090915152215383">this fantastic tip</a> about how you can toggle the display of hidden files in any standard open/save dialog box just by hitting &#8220;Shift+Command+. (period)&#8221;. My first reaction of course was, &#8220;wow, what a great idea!&#8221;, followed quickly by, &#8220;about freaking time!&#8221; and ultimately, &#8220;wtf?, why didn&#8217;t they implement this in the Finder?!?&#8221;.</p>
<p>Well as the old saying goes, give a man a fish and he can feed himself for a day, teach a man to fish and he can get rich selling fish to other suckers (or something of the sort). So it is that Apple has given us the tools in Snow Leopard to fend for ourselves.<span id="more-460"></span> Once again, Automator, Services, a custom keyboard shortcut and the good old bash Terminal are all we need to get the job done. Read on for the step by step instructions on how to make &#8220;Shift+Command+. (period)&#8221; toggle the display of hidden files in Finder.</p>
<div id="attachment_439" class="wp-caption alignright" style="width: 310px"><a href="http://artofgeek.com/wp-content/uploads/2009/09/Automator-Service-Selection.png" target="_blank"><img class="size-medium wp-image-439 " title="Automator Service Selection" src="http://artofgeek.com/wp-content/uploads/2009/09/Automator-Service-Selection-300x278.png" alt="Choosing a template for your Automator workflow (click to enlarge)" width="300" height="278" /></a><p class="wp-caption-text">Choosing a template for your Automator workflow</p></div>
<ol>
<li>Open Automator (in your Applications folder) and choose Service from the list of templates provided and click the Choose button.</li>
<li>In the left hand column under Library, select Utilities.</li>
<li>In the second column, drag &#8220;Run Shell Script&#8221; to the right hand pane.</li>
<li>At the top of the right hand pane where you dragged the Run Shell Script action, click on the right-hand popup menu and change &#8220;any application&#8221; to &#8220;Finder&#8221;. This sets the service so it only appears and can be activated by the keyboard shortcut when Finder is the active application.</li>
<li>Then click on the popup menu next to &#8220;Service receives&#8221; and choose &#8220;no input&#8221;. It&#8217;s important you do this step after step 4 because if you do the reverse, Finder won&#8217;t be available as an option in the right hand menu.</li>
<li>Copy and paste the following text into the empty text area of the Run Shell Script action:</li>
<blockquote><p><code><span style="color: #0000ff;">osascript -e 'tell application "Finder" to quit'<br />
SHOWHIDDEN=`defaults read com.apple.finder AppleShowAllFiles`<br />
if [ $SHOWHIDDEN -eq 1 ]; then<br />
defaults write com.apple.finder AppleShowAllFiles -bool FALSE<br />
else<br />
defaults write com.apple.finder AppleShowAllFiles -bool TRUE<br />
fi<br />
osascript -e 'tell application "Finder" to activate'<br />
</span></code></p></blockquote>
<div id="attachment_504" class="wp-caption alignright" style="width: 310px"><a href="http://artofgeek.com/wp-content/uploads/2009/09/Toggle-Hidden-Files-Automator-Action.png" target="_blank"><img class="size-medium wp-image-504 " title="Toggle Hidden Files Automator Action" src="http://artofgeek.com/wp-content/uploads/2009/09/Toggle-Hidden-Files-Automator-Action-300x230.png" alt="Completed Automator action, ready to save (click to enlarge)" width="300" height="230" /></a><p class="wp-caption-text">Completed Automator action, ready to save (click to enlarge)</p></div>
<li>Choose File&#8211;&gt;Save, and give the new service a meaningful name like &#8220;Toggle Hidden Files&#8221; that will appear in the Services menu. Once you&#8217;ve done that, you can go to the Services menu (located in the current application menu, next to the Apple menu) and your newly created service should appear there. You can even run it, it&#8217;s already fuctional, just lacking a keyboard shortcut.</li>
<li>Open System Preferences&#8211;&gt;Keyboard&#8211;&gt;Keyboard Shortcuts and select Services in the left column.</li>
<div id="attachment_467" class="wp-caption alignright" style="width: 310px"><a href="http://artofgeek.com/wp-content/uploads/2009/09/Toggle-Hidden-Files-Keyboard-Shortcut.png" target="_blank"><img class="size-medium wp-image-467 " title="Toggle Hidden Files Keyboard Shortcut" src="http://artofgeek.com/wp-content/uploads/2009/09/Toggle-Hidden-Files-Keyboard-Shortcut-300x271.png" alt="Setting the keyboard shortcut (click to enlarge)" width="300" height="271" /></a><p class="wp-caption-text">Setting the keyboard shortcut (click to enlarge)</p></div>
<li>Scroll down to the bottom and under the General category, you should see your newly created service listed there. Select it, then Double-click close to the right side of the selected line to reveal a field where you can enter a custom keyboard shortcut. Enter &#8220;Shift+Command+.&#8221; (might as well keep it consistent with the shortcut used in open/save dialog boxes), and then quit System Preferences.</li>
</ol>
<p>That&#8217;s all there is to it. The really nice thing is built-in keyboard shortcuts override custom ones, so pressing  &#8220;Shift+Command+. (period)&#8221; in an open/save dialog will not execute this service.<br />
<div id="attachment_515" class="wp-caption alignright" style="width: 310px"><a href="http://artofgeek.com/wp-content/uploads/2009/09/Finder-Busy-Error.png"><img src="http://artofgeek.com/wp-content/uploads/2009/09/Finder-Busy-Error-300x143.png" alt="Finder Busy Error (click to enlarge)" title="Finder Busy Error" width="300" height="143" class="size-medium wp-image-515" /></a><p class="wp-caption-text">Finder Busy Error (click to enlarge)</p></div><br />
<div id="attachment_516" class="wp-caption alignright" style="width: 310px"><a href="http://artofgeek.com/wp-content/uploads/2009/09/Service-Execution-Error.png"><img src="http://artofgeek.com/wp-content/uploads/2009/09/Service-Execution-Error-300x139.png" alt="Service Execution Error (click to enlarge)" title="Service Execution Error" width="300" height="139" class="size-medium wp-image-516" /></a><p class="wp-caption-text">Service Execution Error (click to enlarge)</p></div>The way the script works is to toggle the state of a hidden Finder preference and restart the Finder so the changes take effect. So you will see Finder disappear momentarily when executing this service.</p>
<p>Since the Finder will be restarted cleanly (using an AppleScript call to request it to quit), any tasks it is currently executing such as  a copy operation, emptying the trash, etc. will prevent Finder from quitting and pop up the two error messages displayed on the right, without any modification to Finder&#8217;s preference plist file. If this happens, simply click &#8220;OK&#8221; to clear the two messages, wait for the Finder operation to complete (or cancel it) and try again.</p>
<p>I&#8217;ll reiterate how dumb it is that we have to implement this ourselves, but this oversight seems completely insignificant when we consider that instead of implementing a single keyboard shortcut that less than 1% of users will ever use, Apple have given all users a powerful and easy to use set of tools to add a keyboard shortcut for almost anything they could ever want to accomplish with one. Now go fish! <img src='http://artofgeek.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p><a name="update_1"></a></p>
<hr /><a name="update_1"></a><strong><em>Update 1 &#8211; 9/17/2009, 11:20 pm:</em></strong> I&#8217;ve made a slight modification to the instructions, adding step 4 which makes the service (and keyboard shortcut) only active when Finder is the frontmost app. This greatly reduces the chances that the keyboard shortcut will interfere with one already assigned to an application, but also keeps the Services menu less cluttered when not in Finder. This also makes it impossible to accidentally activate the service unintentionally unless Finder is the active app. Seeing as you&#8217;d only really want/need to use this trick while using Finder, this made the most sense, but of course you&#8217;re welcome to leave this step out if you think you might want to toggle this while running any app.</p>
<p>I also added two extra lines at the end of the shells script to improve usabiliy. Previously, after the action was executed, Finder would in most cases not end up being the frontmost application anymore since upon quitting Finder, the next application that is running would now become frontmost. The added two lines simply add a quarter second pause so Finder has a chance to relaunch before running the open command which brings Finder back to the front if it isn&#8217;t already.</p>
<p><a name="update_2"></a></p>
<hr /><a name="update_2"></a><strong><em>Update 2 &#8211; 10/2/2009, 11:57 am:</em></strong> Special thanks to commenter &#8220;GlowingApple&#8221; for a suggested improvement to use the osascript command to politely quit the Finder rather than the killall command. The benefit is now Finder will throw up an error if it&#8217;s in the middle of doing something rather than simply imploding taking your copy or empty trash command with it. <img src='http://artofgeek.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>I also changed the execution order a little bit so that the Finder is quit first before the plist modification takes place. That way if the Finder can&#8217;t be quit because it&#8217;s busy, no change will take place. This will prevent the state of hidden file display from unexpectedly changing between reboots or logouts if you unsuccessfully executed the service and Finder couldn&#8217;t be quit. </p>
]]></content:encoded>
			<wfw:commentRss>http://artofgeek.com/2009/09/16/toggle-display-of-hidden-files-in-finder-with-keyboard-shortcut/feed/</wfw:commentRss>
		<slash:comments>66</slash:comments>
		</item>
		<item>
		<title>Lock your Mac&#8217;s screen like in Windows, Snow Leopard edition</title>
		<link>http://artofgeek.com/2009/09/08/lock-your-macs-screen-like-in-windows-snow-leopard-edition/</link>
		<comments>http://artofgeek.com/2009/09/08/lock-your-macs-screen-like-in-windows-snow-leopard-edition/#comments</comments>
		<pubDate>Thu, 01 Jan 1970 00:00:00 +0000</pubDate>
		<dc:creator>madgunde</dc:creator>
				<category><![CDATA[Computing]]></category>
		<category><![CDATA[Mac OS X]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[Automator]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[bsd]]></category>
		<category><![CDATA[hint]]></category>
		<category><![CDATA[keyboard shortcut]]></category>
		<category><![CDATA[login window]]></category>
		<category><![CDATA[Services]]></category>
		<category><![CDATA[Snow Leopard]]></category>
		<category><![CDATA[Terminal]]></category>
		<category><![CDATA[tip]]></category>

		<guid isPermaLink="false">http://artofgeek.com/?p=438</guid>
		<description><![CDATA[<p>Wow. Didn&#8217;t take long for Snow Leopard to render my previous hint on how to lock your Mac&#8217;s screen utterly obsolete.</p>
<p>This is one of the things I love most about Mac OS X: Apple just keeps adding features that often eliminate the need for third party solutions to simple problems. In this particular case, we&#8217;re [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignleft size-full wp-image-446" title="Snow-Leopard-and-Friends" src="http://artofgeek.com/wp-content/uploads/2009/09/Snow-Leopard-and-Friends.png" alt="Snow-Leopard-and-Friends" width="300" height="233" />Wow. Didn&#8217;t take long for Snow Leopard to render <a href="http://artofgeek.com/2009/06/23/lock-your-macs-screen-like-in-windows/">my previous hint</a> on how to lock your Mac&#8217;s screen utterly obsolete.</p>
<p>This is one of the things I love most about Mac OS X: Apple just keeps adding features that often eliminate the need for third party solutions to simple problems. In this particular case, we&#8217;re going to use a combination of Automator, a terminal command, Snow Leopard&#8217;s new improved Services and a system-wide keyboard shortcut to enable a hotkey that will suspend the currently logged in user session and display the Login Window as though you had chosen the &#8220;Login Window…&#8221; option from the Fast User Switching menu extra.<span id="more-438"></span></p>
<p>I know, enough with the chatter, get on with the tutorial!  Just follow these steps and you&#8217;ll be locking your Mac running Mac OS X 10.6 Snow Leopard like it&#8217;s running Windows XP! Wait, did I just write that? <em>Shudder.</em> Sorry, I think I just threw up a little bit in my mouth. Here&#8217;s the tutorial:</p>
<div id="attachment_439" class="wp-caption alignright" style="width: 310px"><a href="http://artofgeek.com/wp-content/uploads/2009/09/Automator-Service-Selection.png" target="_blank"><img class="size-medium wp-image-439 " title="Automator Service Selection" src="http://artofgeek.com/wp-content/uploads/2009/09/Automator-Service-Selection-300x278.png" alt="Choosing a template for your Automator workflow (click to enlarge)" width="300" height="278" /></a><p class="wp-caption-text">Choosing a template for your Automator workflow</p></div>
<ol>
<li>Open Automator (in your Applications folder) and choose Service from the list of templates provided and click the Choose button.</li>
<li>In the left hand column under Library, select Utilities.</li>
<li>In the second column, drag &#8220;Run Shell Script&#8221; to the right hand pane.</li>
<li>At the top of the right hand pane where you dragged the Run Shell Script action, click on the menu next to &#8220;Service receives&#8221; and choose &#8220;no input&#8221;.</li>
<li>Copy and paste the following Terminal command into the empty text area of the Run Shell Script action:<br />
<blockquote><p><code><span style="color: #0000ff;">/System/Library/CoreServices/Menu\ Extras/User.menu/Contents/Resources/CGSession -suspend</span></code></p></blockquote>
<p>The entire command should be entered on a single line and note there is a space after &#8220;/Menu\&#8221;.</li>
<div id="attachment_441" class="wp-caption alignright" style="width: 310px"><a href="http://artofgeek.com/wp-content/uploads/2009/09/Automator-Action.png" target="_blank"><img class="size-medium wp-image-441 " title="Automator Action" src="http://artofgeek.com/wp-content/uploads/2009/09/Automator-Action-300x199.png" alt="Completed Automator action, ready to save (click to enlarge)" width="300" height="199" /></a><p class="wp-caption-text">Completed Automator action, ready to save (click to enlarge)</p></div>
<li>Choose File&#8211;&gt;Save, and give the new service a meaningful name like &#8220;Lock Computer&#8221; that will appear in the Services menu. Once you&#8217;ve done that, you can go to the Services menu (located in the current application menu, next to the Apple menu) and your newly created service should appear there.</li>
<li>Next open System Preferences &#8211;&gt; Keyboard &#8211;&gt; Keyboard Shortcuts and select Services in the left column.</li>
<div id="attachment_443" class="wp-caption alignright" style="width: 310px"><a href="http://artofgeek.com/wp-content/uploads/2009/09/Setting-the-keyboard-shortcut.png" target="_blank"><img class="size-medium wp-image-443 " title="Setting the keyboard shortcut" src="http://artofgeek.com/wp-content/uploads/2009/09/Setting-the-keyboard-shortcut-300x271.png" alt="Setting the keyboard shortcut (click to enlarge)" width="300" height="271" /></a><p class="wp-caption-text">Setting the keyboard shortcut (click to enlarge)</p></div>
<li>Scroll down to the bottom and under the General category, you should see your newly created service listed there. Select it, then Double-click close to the right side of the selected line to reveal a field where you can enter a custom keyboard shortcut. Enter an easy to remember but unique keyboard shortcut (I decided to go with ctrl+option+command+L), and then quit System Preferences.</li>
</ol>
<p>That&#8217;s it! Go ahead and test your keyboard shortcut!</p>
<p>Welcome back! As you should have just seen, pressing the assigned keyboard shortcut fast user switches to the login screen leaving all your programs running in the background waiting for you to log back in again. If you&#8217;re more mouse inclined, you can of course also lock your screen by choosing your Automator action from the Services menu. All accomplished with the awesome customization tools included with Mac OS X 10.6 Snow Leopard!</p>
]]></content:encoded>
			<wfw:commentRss>http://artofgeek.com/2009/09/08/lock-your-macs-screen-like-in-windows-snow-leopard-edition/feed/</wfw:commentRss>
		<slash:comments>102</slash:comments>
		</item>
		<item>
		<title>Lock your Mac&#8217;s screen like in Windows [Update 1]</title>
		<link>http://artofgeek.com/2009/06/23/lock-your-macs-screen-like-in-windows/</link>
		<comments>http://artofgeek.com/2009/06/23/lock-your-macs-screen-like-in-windows/#comments</comments>
		<pubDate>Tue, 23 Jun 2009 13:14:26 +0000</pubDate>
		<dc:creator>madgunde</dc:creator>
				<category><![CDATA[Computing]]></category>
		<category><![CDATA[Mac OS X]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[fast user switching]]></category>
		<category><![CDATA[hint]]></category>
		<category><![CDATA[lock screen]]></category>
		<category><![CDATA[Mac]]></category>
		<category><![CDATA[Terminal]]></category>

		<guid isPermaLink="false">http://artofgeek.com/?p=421</guid>
		<description><![CDATA[<p>[Update 1] Anyone who uses Windows at work is probably familiar with the old Ctrl-Alt-Del &#60;return&#62; trick to quickly lock your screen when you step away from your computer. This displays a &#8220;This computer is in use and has been locked.&#8221; message which instructs you to press Ctrl-Alt-Del again to unlock the computer. Doing so [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignright size-full wp-image-423" title="LockSystem" src="http://artofgeek.com/wp-content/uploads/2009/06/LockSystem.png" alt="LockSystem" width="128" height="128" /><a href="http://artofgeek.com/2009/06/23/lock-your-macs-screen-like-in-windows/#update_1">[Update 1]</a> Anyone who uses Windows at work is probably familiar with the old Ctrl-Alt-Del &lt;return&gt; trick to quickly lock your screen when you step away from your computer. This displays a &#8220;This computer is in use and has been locked.&#8221; message which instructs you to press Ctrl-Alt-Del again to unlock the computer. Doing so presents you with a username/password prompt, which looks very much like the login screen.</p>
<p>In Mac OS X, the closest thing we have is the &#8220;Require password to wake this computer from sleep or screen saver&#8221; check box in the Security system preference pane (in Mac OS X 10.5 Leopard). Then what a lot of people do is set a screen corner to activate the screen saver (via the Exposé system preference pane). Then just before they walk away, they move the mouse into the designated corner, wait for the screensaver to kick in, then walk away.<span id="more-421"></span></p>
<p>If you have OS X&#8217;s Fast User Switching enabled (via the Accounts system preference pane), there&#8217;s a second way to lock your screen which is a bit more like the Windows method. By selecting the &#8220;Login Window…&#8221; option from the Fast User Switching (FUS) menu in the top-right corner of your screen, you are taken back to the login screen while your user session continues to run in the background.</p>
<p>While the Mac OS X solutions works fine, some of us regular Windows users just prefer a more direct method of locking the screen similar to what is offered in Windows. I was one of those people. I liked the Fast User Switching method for locking my screen, but didn&#8217;t want to have to enable FUS to get it because I&#8217;m the only person who uses my Mac, and I didn&#8217;t want to give up the extra menu bar real estate to the FUS menu. In addition, the FUS method requires two clicks, which is one too many clicks! Ideally I wanted a single click solution or one which can be quickly activated with a hotkey.</p>
<p>In my searching, I found a Terminal command on <a title="Mac OS X Hints" href="http://www.macosxhints.com/" target="_blank">MacOSXHints</a> (it&#8217;s been posted so many times in different hints and comments too numerous to give credit to individually) which activates the &#8220;Login Window…&#8221; function from the FUS menu, even if FUS isn&#8217;t enabled! The command is as follows:</p>
<pre>/System/Library/CoreServices/Menu\ Extras/User.menu/Contents/Resources/CGSession -suspend</pre>
<p>&#8220;Now we&#8217;re getting somewhere&#8221;, I thought to myself upon finding that little gem. If I could turn that into a double-clickable script or application, I could add it to the Dock and could lock my system with a single click of the mouse. Even better, using keyboard automation software <a href="http://www.shadowlab.org/softwares/spark.php">like Spark</a> or similar, you could even map a keyboard shortcut that would launch the script or app with the press of a couple of keys.</p>
<p>So to cut an already long story short, I figured out how to create a shell script and using XCode bundled it as an application. I won&#8217;t go into details on exactly how I did either, mainly because I did it a long time ago, and frankly can&#8217;t exactly remember, and that wasn&#8217;t the point of this post. Not being an artist, I borrowed Apple&#8217;s icon from Mac OS X&#8217;s Security Preference pane (thanks Apple!) and made it the icon for my new application bundle which I called simply &#8220;Lock System&#8221;. You can download the Lock System application from the link at the end of this article.</p>
<p>Once you&#8217;ve downloaded and extracted the zip file. Just move the Lock System application to your Applications folder (or anywhere else you want to keep it). I keep mine in ~/Library/Scripts so I can access it via the AppleScript menu. Then add it to your Dock or put an Alias on your Desktop for quick access. Finally, create a keyboard shortcut in <a href="http://www.shadowlab.org/softwares/spark.php">Spark</a> (or similar) for launching Lock System (I like Command+Shift+L), and that&#8217;s it! You can now lock your Mac like you do on Windows. Enjoy!</p>
<h6><em>Lock System should be compatible with Mac OS X 10.3, 10.4 and 10.5. <del datetime="2009-09-09T01:35:52+00:00">Anyone out there who can confirm if it still works in Mac OS X 10.6 Snow Leopard, please post your results in the comments, thanks!</del><em> [Edit: See <a href="http://artofgeek.com/2009/06/23/lock-your-macs-screen-like-in-windows/#update_1">my update</a> at the end of the article. - madgunde]</em> This software is presented as is and with no guarantees. You use it at your own risk, so don&#8217;t be coming back to me to complain that it&#8217;s hosed your system (which would be hard to believe anyway). I&#8217;ve been using it for years now and am only sharing because I thought others might appreciate it.</em></h6>
<p><img class="size-full wp-image-423 alignnone" title="LockSystem" src="http://artofgeek.com/wp-content/uploads/2009/06/LockSystem.png" alt="LockSystem" width="128" height="128" /></p>
<p><a href="http://artofgeek.com/wp-content/uploads/2009/06/Lock-System.zip">Download Lock System (12KB .zip)</a></p>
<hr />
<a name="update_1" ></a><strong><em>Update 1 &#8211; 9/8/2009, 9:30 pm:</em></strong> If you&#8217;re running Mac OS X 10.6 Snow Leopard, there&#8217;s an <a href="http://artofgeek.com/2009/09/08/lock-your-macs-screen-like-in-windows-snow-leopard-edition/">even more elegant solution</a> that doesn&#8217;t require any third party software to accomplish the same task. If you&#8217;re not running Snow Leopard, you better have a darn good reason, like your Mac doesn&#8217;t have an Intel processor or something. <img src='http://artofgeek.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://artofgeek.com/2009/06/23/lock-your-macs-screen-like-in-windows/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Useful Mac OS X Terminal Commands</title>
		<link>http://artofgeek.com/2006/09/22/useful-mac-os-x-terminal-commands/</link>
		<comments>http://artofgeek.com/2006/09/22/useful-mac-os-x-terminal-commands/#comments</comments>
		<pubDate>Fri, 22 Sep 2006 15:01:28 +0000</pubDate>
		<dc:creator>madgunde</dc:creator>
				<category><![CDATA[Mac OS X]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[command line]]></category>
		<category><![CDATA[hints]]></category>
		<category><![CDATA[Terminal]]></category>
		<category><![CDATA[Terminal commands]]></category>
		<category><![CDATA[Unix]]></category>
		<category><![CDATA[Unix commands]]></category>

		<guid isPermaLink="false">http://artofgeek.com/2006/09/22/useful-mac-os-x-terminal-commands/</guid>
		<description><![CDATA[<p>Mac OS X is a very powerful OS.  One of it&#8217;s most amazing traits is how well it scales from being dead easy to use for novice users to allowing power users near unlimited capabilities.  The former comes from the excellent UI design and GUI tools that Apple has built, the latter from [...]]]></description>
			<content:encoded><![CDATA[<p><img id="image51" src="http://artofgeek.com/wp-content/uploads/2006/09/terminal-icon.jpg" class="alignright" alt="Terminal.app icon" />Mac OS X is a very powerful OS.  One of it&#8217;s most amazing traits is how well it scales from being dead easy to use for novice users to allowing power users near unlimited capabilities.  The former comes from the excellent UI design and GUI tools that Apple has built, the latter from Mac OS X&#8217;s FreeBSD Unix underpinnings.  While most users will never have to touch the Mac OS X Terminal application to go about their day to day computing, those who like to push the limits of what they can do will most likely spend at least a bit of time at the command prompt.  This article is for those aspiring command line gurus, like myself.</p>
<p>I&#8217;ve been using Mac OS X since the Public Beta was released in 2000.  Over the years, as I&#8217;ve delved further into learning about the operating system&#8217;s Unix underpinnings, I&#8217;ve always kept a Stickies note handy where I would paste terminal commands that I thought might come in handy at some point in the future.<span id="more-50"></span>  Every one of these commands required countless Google searches and time scouring the results to find solutions to the problem I had at the time.  It&#8217;s in the interest of saving others from spending too much time searching that I present my Stickies Mac OS X terminal command list.  I hope these help all of you as much as they have helped me.</p>
<h3>A warning for newbies:</h3>
<p>If you&#8217;re not familiar with the Mac OS X Terminal, it&#8217;s an application that allows a user to directly execute Unix commands by typing them into text based command prompt.  You can find the Terminal application in /Applications/Utilities on your hard disk.  <strong>Please be aware that the terminal and Unix commands are very unforgiving.  A simple typo or misplaced punctuation can mean the difference between your command working and you deleting or overwriting something important, especially when executing commands with administrator rights (via the <code>sudo</code> command).</strong>  If you aren&#8217;t sure what you&#8217;re doing, it&#8217;s better to take the time to research the answer than to simply guess and possibly mess something up you won&#8217;t know how to fix.  This article is not meant to be a tutorial on how to use the Terminal.  If have never used the terminal, may I suggest you visit O&#8217;Reilly&#8217;s MacDevCenter which has <a href="http://www.macdevcenter.com/pub/ct/51">some good tutorials</a> to get you started.</p>
<h3>The Commands</h3>
<p><strong><u>Disclaimer:</u></strong> Please note that I cannot be held responsible for anything bad you do to your computer while attempting to use any of these commands.  Use them at your own risk!</p>
<h4>Eject Stubborn CDs</h4>
<ul>
<code>disktool -e disk#</code></ul>
<p>I found myself one day with a CDROM stuck in my CDROM drive, but no way to eject it.  It didn&#8217;t show up in the Finder or on the Desktop, and hitting the &#8220;Eject&#8221; button on the keyboard did nothing.  I found and tried two or three other terminal and GUI based solutions from sites like Mac OS X Hints, but none of them worked except this little gem.  I haven&#8217;t had to use it for years and it may not work for every stuck CD, but this one saved me from having to reboot my computer to get a bad CD out.  Type <code>disktool</code> by itself to get help.</p>
<h4>Unmount Stubborn Network Volumes</h4>
<ul>
<code>umount -f /Volumes/volumename</code></ul>
<p>Like the stuck CD issue above, I have once or twice come across a network volume that I could not disconnect.  Substitute the stuck network share&#8217;s name in place of &#8220;volumename&#8221; in this command.    You can view the pdisk man page to get help by typing <code>man umount</code> at the prompt and hitting return.</p>
<h4>Delete partition table on iPod</h4>
<ul>
<code>pdisk</code></ul>
<p>This menu based terminal app saved a dead iPod.  I once made the mistake of formatting my iPod as an external FireWire drive as some non-standard format (maybe NTFS or Unix File System).  After doing that, I couldn&#8217;t re-initialize the iPod using the latest iPod updater.  While I don&#8217;t remember exactly the steps I used to get the iPod working again (it had to do with deleting the partition table), this tool is what did the trick for me.  You can view the pdisk man page to get help by typing <code>man pdisk</code> at the prompt and hitting return.</p>
<h4>Restart Bonjour service</h4>
<ul>
Stop Bonjour service:<br />
<code>sudo launchctl unload /System/Library/LaunchDaemons/com.apple.mDNSResponder.plist</code></ul>
<ul>
Start Bonjour service:<br />
<code>sudo launchctl load /System/Library/LaunchDaemons/com.apple.mDNSResponder.plist</code></ul>
<p>A while back I had a problem where one of my Macs would periodically fail to broadcast it&#8217;s Bonjour name for things like print and file serving.  Rebooting the computer would resolve the problem for a time, but it would always come back.  Rather than having to reboot my computer all the time, I searched for and found this handy set of commands for stopping and starting the Bonjour service which would do the trick until the problem occurred again.  Since this was a service, it was great not having to reboot.  I eventually solved the problem, which if memory serves was caused by my router, but I felt it was handy to hold onto this in case I ever needed to stop or restart the Bonjour service again.  These commands need to be run as administrator, which is why they are prefixed with the <code>sudo</code> command.  You will be prompted to enter your admin password to execute them.</p>
<h4>Restart Apple Remote Desktop (ARD) service</h4>
<ul>
<code>sudo /System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Resources/kickstart -restart -agent -menu</code><br />
<em>Note: This is a very long command that should all be typed or copied/pasted as one line.</em></ul>
<p>I had a problem with Apple Remote Desktop once where if I left a remote control session running for too long (say overnight), the remote display would no longer refresh automatically.  In my quest to avoid rebooting my server, I found this handy command that restarts the ARD service, which listens for and manages remote control requests.  This has to be run on the machine you want to control normally.  Since I was having problems remote controlling said computer, I would log in remotely via SSH by typing <code>ssh ip_address</code> and execute the command while logged in remotely.  Very handy indeed.  Being able to remotely login via SSH is no doubt one of the most useful reasons to learn the command line.  All terminal commands that are covered in this article can be executed remotely.  You can view the SSH man page to get help by typing <code>man ssh</code> at the prompt and hitting return.</p>
<h4>Reset Network Interface</h4>
<ul>
Shut down network interface:<br />
<code>sudo ifconfig en0 down</code></ul>
<ul>
Start up network interface:<br />
<code>sudo ifconfig en0 up</code></ul>
<ul>
<em>Note: Substitute en0 for appropriate network interface id (a.k.a. BSD device name).  You can use System Profiler (in the /Applications/Utilities folder) to find the BSD device name for the network connection you want to reset.</em></ul>
<p>I can&#8217;t remember why I needed to do this.  Might have been while I was troubleshooting that Bonjour service issue, or maybe I was trying to change the connection&#8217;s MAC hardware address.  Doesn&#8217;t really matter.  The point is you can use this combination of commands to restart a network interface.  These commands use the SUDO command to run using administrator rights and so you will be prompted for your admin password.</p>
<p>[Edit: Thanks to commenter "why o why" for pointing out, <em>"it should be noted that if you remotely shutdown the ethernet interface you are using, it will be difficult to get it back up remotely <img src='http://artofgeek.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  "</em>]</p>
<h4>Restart Apache Webserver</h4>
<ul>
<code>sudo apachectl graceful</code></ul>
<p>While restarting Mac OS X&#8217;s built-in Apache web server is as easy as toggling the &#8220;Personal Web Sharing&#8221; service&#8217;s status in the Sharing preference pane, you can&#8217;t do this easily remotely unless you can remote control the server in question.  Over a modem connection, this can be near impossible or at least very painful.  This command comes in handy if you&#8217;ve modified the Apache configuration file via a remote SSH connection as the changes only take effect after the Apache service is restarted.</p>
<h4>Restart MySQL Server</h4>
<ul>
Stop MySQL Server<br />
<code>sudo /Library/StartupItems/MySQLCOM/MySQLCOM stop</code></ul>
<ul>
Start MySQL Server<br />
<code>sudo /Library/StartupItems/MySQLCOM/MySQLCOM start</code></ul>
<p>Not so long ago I installed the MySQL open source SQL database on my web server so I could run a phpBB based forum site.  MySQL also happens to be the database that runs the Art Of Geek blog.  These two commands are useful for stopping or restarting the MySQL service via SSH, or if like me you have ever broken your MySQL installation just enough for the MySQL preference pane to stop working.</p>
<h4>Change a file&#8217;s type code to make an AAC file an iTunes/iPod audio book</h4>
<ul>
<code>/Developer/Tools/SetFile -t 'm4b ' filename.m4b</code><br />
<em>Note: You must have the Mac OS X developer tools installed for this command to work!</em></ul>
<p>This gem of a command will set the type code of a file to &#8216;m4b &#8216; (there is a space after the &#8216;b&#8217;), which tells iTunes it&#8217;s an audio book.  This is required if you have ever ripped an audio book from CD, and want iTunes to see it as an audio book.  The file must be an AAC file, and you need to change the file extension to .m4b.  The truth is, this command can come in handy any time you need to implicitly set a file&#8217;s &#8216;type&#8217; or &#8216;creator&#8217; codes.  You can view the SetFile man page for help by typing <code>man SetFile</code> at the terminal prompt and hitting return.</p>
<p>That&#8217;s all the time (and commands) we have for today folks!  I&#8217;ll post more in a future article!</p>
]]></content:encoded>
			<wfw:commentRss>http://artofgeek.com/2006/09/22/useful-mac-os-x-terminal-commands/feed/</wfw:commentRss>
		<slash:comments>32</slash:comments>
		</item>
	</channel>
</rss>
