terminal

Latest

  • A (slightly) simpler command-line Spotlight search

    by 
    Brett Terpstra
    Brett Terpstra
    01.04.2008

    Erica mentioned mdfind a little while ago. It's not a brand new tool, but there hasn't been a great deal of discussion surrounding it. For shell scripters and Terminal junkies, it's a goldmine of search goodness that can make you never want to key out find . -name "letsgogetcoffeewhilewewait.rb" or even locate didcronupdatethedb.yet again. There are two mdfind options mentioned at Mac OS X Hints that are worth a mention, one found only in the man page, and one found only in the usage info. The former being "-interpret", which allows the advanced Spotlight query syntax to be used on the command line as if typed into the Spotlight window, turning mdfind "kMDItemContentType == 'public.jpeg'" into mdfind -interpret "kind:jpeg". Its opposing force would be "-literal", which forces a literal interpretation of the query string. Any qualified Spotlight query should be usable with "-interpret", so go ahead with mdfind -interpret "kind:image flash:1 modified:<=1/1/08 ex-girlfriend" to find those late-night pictures of last year's special someone. That would take a lot of metadata work to pull off without "-interpret". The second option mentioned isn't in the man page, but you'll see it in the usage info if you run mdfind with no parameters. It's the "-s" option that loads saved searches. It will look in ~/Library/Saved Searches unless a path is specified. So you can save a search in Spotlight called "PDFs from yesterday" and run mdfind -s "PDFs from yesterday" to launch the same search at the command line. See, I had to throw a "normal" search in there to keep you on your toes. Terminal jockeys can mix these up with a few pipes, stir in some perl and sprinkle in a little awk to get some really great Spotlight soufflé. Of course, if you don't like the command line and you're still reading this, you're a downright hardy trooper and I commend you. Go have a cup of coffee, you deserve it. [via Mac OS X Hints]

  • Secure your Mac: Crouching user, hidden folder

    by 
    Dave Caolo
    Dave Caolo
    09.17.2007

    Here are a few very simple steps you can take to enhance your Mac's security - not exactly the U.S. Government's Advanced Encryption Standard (AES) algorithm, but enough to thwart many end-users.Create a guest user accountOccasionally, someone will ask me, "May I quickly check my email on your computer? Just real quick..." (often these are Windows users who need an excuse to play with the MacBook Pro). "Sure," I say, but before I hand over the reigns, I switch to my guest user account. Here's how you can create one. Click System Preferences, then Accounts Click the small "+" icon at the bottom of the window In the sheet that appears, set up your guest account. I got fancy and named mine "guest," with a password of "guestpw," but you can choose whatever you like. De-select "Allow user to administer this computer." Now, when someone "borrows" my computer to check their mail, they see an empty home folder, blank email client...the works. Even the rude ones who try to quickly peek won't find anything.Create a hidden folderMac OS X automatically hides a folder that begins with a period. We can use this to our advantage and create a secret folder. However, it's not as easy as creating a folder in the Finder and naming it ".MyPrivateStuff." But it's not difficult, either. Open Terminal. By default, you're in your Home directory Create a new folder with a "." as the first character using the "mkdir" command, like this: mkdir .MyPrivateStuff Hit return. You're done! So how do you access that folder from the Finder? Navigate to your Home folder (open a new window and click the little house in the left sidebar). Now, select "Go to folder..." from the menu bar. Enter the name of the folder you created, including the period (in my case, .MyPrivateStuff). Presto! Your hidden folder appears in the Finder window. Now populate it with your "secret" stuff (financial in nature, of course). One caveat: The Finder "remembers" the last folder you visited with this method, so be sure to "Go to..." a benign folder before you walk away.Combine the two tipsIf you really want to get fancy, combine the two tips: Create a new user account that does nothing but store your secret folder(s). Again, this isn't military-grade security, but simple techniques that you can use as an extra layer of protection for some of your stuff. Good luck.

  • iPhone software: the community hacks, Apple improves

    by 
    Chris Ziegler
    Chris Ziegler
    08.03.2007

    It's been a heckuva few weeks for iPhone devs, has it not? We've gone all the way from the crushing depression of knowing we'd have to play within the web sandbox, to the first hints of compiled goodness, to this -- the first true, native 3rd party app with useful functionality. As the name implies, MobileTerminal is a terminal emulator (and yes, it does actually install a new icon on the home screen) that should let the more 1337 among us execute arbitrary commands to their portable bundles of Mac OS X joy; as the Google Code page astutely notes, it's not a telnet or ssh client, though an ssh client can be fired up from the terminal. The code is open and development seems to be going fast and furious, so keep an eye out for updates, like, hourly!But wait, there's more: it turns out Apple covertly sneaked in some goodies of its own when it rolled out the nebulously-described 1.01 firmware earlier this week. Uncle Walt himself discovered that the Phone app's Favorites tab has been upped from 20 entries to a more usable 50, the option to BCC yourself when sending email has been added, and a number of external audio devices with iPod docks that the iPhone previously rejected are now miraculously working, it seems. So much for "bug fixes" only, eh, Apple?[Thanks, Tom K.]Read - MobileTerminalRead - Walt's discoveries in 1.01

  • Apple IIc as a serial terminal to a Mac Mini

    by 
    Mike Schramm
    Mike Schramm
    07.25.2007

    Hot on the heels of the Apple IIe-into-a-Linux-terminal tutorial we posted the other day, here's another mix of retro and modern-- Byte Cellar has hooked up an old Apple IIc (or //c if you spin that way) to work as a terminal to a Mac Mini. It's pretty neat-- sounds like they frankensteined the IIc's serial port to a USB connection, put ModemMGR on the IIc (which is three whole floppies), and now are using the old "luggable" as an IRC client, which is a perfect use for it, and, as Blake says, makes it feel "great to twiddle the //c's keys in a meaningful way every workday."There's also a photo gallery of the whole setup, which shows the spliced cable, as well as the whole setup in all its glory (yeah the XP box mars it a bit, but no one's perfect). Very cool. Makes me wish I still had one of those old clunky Apple IIs, if only to run IRC as it's mean to be run-- with nothing but green text on a black screen.[via Digg]

  • Mac 101: Reset your Mac OS X password

    by 
    Dave Caolo
    Dave Caolo
    07.17.2007

    We've all done this.* It's time to install something or run Software Update, but first we've got to enter our password. What was it again? Oops.You can reset your password with the CD (or DVD) that came with your Mac, but if you don't have it, try this tip from Hackszine. Restart your machine while holding down the Command Key (or "Apple Key") and the "S" key. This will start your Mac up in "Single User Mode."Now it's command line time.** Don't worry, it's just three lines: #sh /etc/rc #passwd yourusername #reboot Ta-dah! You may return to what you were originally doing. Just write that new password down first.*Well, not us, but, you know...our "friend."[Via Lifehacker]**Update: this post has raised some understandable security concerns among our readers. Our own Mike Rose had this to say:"Not this caveat, from a commenter at Hackazine: if you have a FileVault-protected home directory, you cannot use this hack. Changing your password from the command line will render your home directory completely inaccessible, probably permanently."

  • SSH shell for iPhone

    by 
    Dave Caolo
    Dave Caolo
    07.06.2007

    We know what you've been thinking. "Gee, I wish I could SSH into my Mac with my iPhone." Well, now you can.WebShell is simple enough to install (just two commands in Terminal) and configure. Once it's all set up, point your iPhone to http://localhost:8022 in Safari and you're good to go!The folks who are working on this are asking for your input. Send them your screenshots and experiences so they can make it even better. WebShell is free.

  • ChangeShortName updated to 1.3

    by 
    Michael Rose
    Michael Rose
    05.30.2007

    A few weeks ago, in discussing some things not to do with your Mac, one of our commenters asked why changing the shortname (the abbreviated version of your username you see in Terminal, as the name of your 'home folder' or in Get Info windows) is such a nasty bit of business on Mac OS X. Shouldn't it be easy as pie, on the 'computer for the rest of us,' to make this quick and trivial modification? Well... it isn't. In part due to Mac OS X's UNIX heritage and in part due to NetInfo (a chunk of the NeXT operating system that hopefully won't be around forever), the shortname gets tucked away in a lot of tricky wee places, and getting them all updated manually is a path to disaster.Fortunately, as Scott mentioned way back in ought-five, there's a somewhat easier way: James Bucanek & Dan Frakes' handy-dandy and free ChangeShortName utility. This tool, now updated to version 1.3 and featuring an all-new Cocoa interface, will give timid people the strength to do what must be done and change your shortname for you, as an absolute last resort. Seriously, you are not allowed to use this program without reading the included (and well-written) manual, and you should heed the FAQ that asks "Q: Should I be scared of ChangeShortName? A: YES." The authors suggest learning to live with your hella lame shortname, or creating a new account and migrating your data instead of changing the name; if something goes wrong in the process, your efforts at account aesthetics might render your machine unusable. You've been warned!Thanks Dan & James

  • Terminal Tip: Interactive Command-line File Encryption

    by 
    Erica Sadun
    Erica Sadun
    05.22.2007

    In OS X, you can always toss a file onto the command line instead of laboriously typing out a complete path name because Terminal supports drag and drop. Over at Murphymac, Murphy has posted a video showing you how to create a shell script using DES3 encryption to protect your files. It takes advantage of this drag and drop support so you can basically run the script and drop the file you want to encrypt. Even if you're not all that interested in encrypting your files, this videocast shows how to think about creating shell scripts with a particularly interactive OS X flare flair.

  • Terminal Tip: Finding by Time

    by 
    Erica Sadun
    Erica Sadun
    04.27.2007

    Have you ever lost track of a file that you were just working on? Or were you ever curious about which files an installer has just added or modified? The command line find command offers a simple way to track down any files created or updated within the last few minutes. Its amin and cmin flags tells find to locate files that changed with a certain number of minutes, e.g. to search within 10 minutes: find / -cmin -10 or find /Users/ericasadun/ -amin -3. The - before the time says to find within the time period (with, say, the last three minutes) rather than to look for exact time matches (at 3 minutes ago exactly).

  • Terminal Tip: Accessing built-in calendars

    by 
    Erica Sadun
    Erica Sadun
    04.12.2007

    On Sunday, I posted about the built-in calendars found in /usr/share/calendar. These calendars include listings of events from around the world and for religions, e.g. calendar.history and calendar.christian. Today, I thought I'd share some ways to access those calendars from the command line. On pretty much any version of Mac OS X, you can use the built-in calendar command to list the events of the day. The -f flag allows you to select which calendar you want to access. The calendar.world file references all the other English-language calendars. % calendar -f /usr/share/calendar/calendar.world Apr 13 Thomas Jefferson born, 1743 Apr 12 Confederate troops fire first shots of Civil War at Ft Sumter, 1861 Apr 12 Space Shuttle Columbia launched, 1981 Apr 12 Yuri Gagarin becomes the first man in space, 1961 Apr 13 Laotian New Year (3 days) in Laos Apr 13 National Day in Chad Apr 13 Songkron Day in Thailand and so forth... % You can embed this command into your startup files like ~/.bashrc so the events of the day display whenever you open a new shell. Unfortunately, the calendar command does not seem to work properly on my Intel-based Mac Mini; Mike reports that it works just fine on his MacBook Pro. If your Intel Mac is balking at the calendar command, you can use grep as a workaround: grep `date +%m/%d` /usr/share/calendar/calendar.*

  • Quickly find your EMI music

    by 
    Dave Caolo
    Dave Caolo
    04.10.2007

    Last week we asked if you will upgrade the EMI tracks you currently own to the new DRM-free versions when they become available in iTunes next month. Just over 2,500 of you said you would, so now the question becomes: How do I easily find my EMI music?MacOSXHints has the answer. Just launch Terminal and enter the following:"mdfind -onlyin ~/Music/iTunes/iTunes Music "kMDItemCopyright == '*Emi*' kMDItemCodecs == '*protected*' "Note that this trick assumes your music lives in the default location. You can output the result to a handy text file by appending > ~/Desktop/myEMI.txt to the end of the command above. Cool!

  • 15 Nifty command line tricks to set various options

    by 
    Erica Sadun
    Erica Sadun
    03.20.2007

    UK website MacOSXTips has put together a list of 15 of their favorite command line preferences tricks. The tricks, which all use the defaults command, range from deactivating Dashboard, to showing hidden files in the Finder, to displaying all mail as plain text. I had a blast rediscovering some old preferences tricks and learning some new ones.

  • GeekTool: Run UNIX Commands on the Desktop

    by 
    Mat Lu
    Mat Lu
    03.15.2007

    Today I ran across this excellent tutorial on lifehacker about using GeekTool, and I was amazed to discover we haven't mentioned it here at TUAW. GeekTool is a cool little preference pane which allows you to run terminal commands, show logs, or even display pictures (e.g. from the net) directly on your desktop. Common uses include running the command top which displays which processes are utilizing the most system resources, displaying the console log, or even putting a live weather map (from the net) on your desktop. As I mentioned before, Gina at lifehacker has an extensive discussion of how it can be used. So, TUAWers, what sort of commands do you like to run in GeekTool?GeekTool is open source and a free download from Tynsoe; donations are requested.

  • Monday man page: curl

    by 
    Michael Rose
    Michael Rose
    03.05.2007

    Today's man page covers one of my favorite utilities: curl. No, it's not a haircare product -- it's one of the most flexible download tools in the kit bag, with the ability to handle almost any protocol that can be addressed via a URL (hence the name, short for "client for URLs"). If there's a server out there that's reachable via HTTP, HTTPS, FTP, SFTP, SCP, and lots of other alphabet soup, curl can talk to it. curl http://www.tuaw.com/2007/03/05/monday-man-page-curl/ -- display the source of this very article in Terminal curl ftp://ftp.panic.com -- list the contents of a remote FTP site, in this case one with a pretty good FTP client curl -o ~/Desktop/curl-man.html http://curl.haxx.se/docs/manpage.html -- copy the curl manpage to your desktop; if you use capital -O, the local file mirrors the remote filename curl has an excellent usage manual at its site, detailing examples of use and advanced techniques. While there are zillions of ways to use curl in site testing, analysis and uploading, my favorite way of using it is as a quick file downloader. Read on for the details.

  • Monday man page: open

    by 
    Michael Rose
    Michael Rose
    02.12.2007

    Just a quick hint for today's man page: the open command does just what you might think. It opens files, directories, applications or URLs; no muss, no fuss. For files, you can specify an application to open them with the -a flag (or just trust LaunchServices to pick the right app). If you want to, the -e flag will force them to open in TextEdit. open ~/Desktop/MyWordDoc.doc [will open in MS Word] open -e ~/Desktop/MyWordDoc.doc [will open in TextEdit] open ~/Desktop/*.doc [opens every Word document on the desktop, in Word] open http://tuaw.com [well, give it a go!] I use open in installation scripts or other situations where I want a GUI application to come up at the end of a process. For example, open /System/Library/CoreServices/Software\ Update.app/ launches Software Update and begins checking for available patches. Sure, you can force an update with 'softwareupdate -i -a' anytime, but maybe I want to give the person sitting at the console an opportunity to select the updates needed, or cancel out of the possibly-lengthy update cycle until it's more convenient. You could also use the URL functionality to take people to a 'readme' website... the possibilities are manifold.

  • Monday man page: lsof

    by 
    Michael Rose
    Michael Rose
    02.05.2007

    Happy hangover Monday everyone! To soothe those post-big-game blues, here's this week's man page -- lsof, the LiSt Open Files tool. If you're trying to figure out why a removable drive won't unmount or track down a stray outbound network connection, this is the tool for you. Note: If you want to stay out of the command line but still accomplish some of the same tasks, a reader suggests you check out Sloth. Written by Vic Abell of Purdue University (now retired), the power and flexibility of lsof has given it the distinction of reputedly having more command-line flags than any other tool: lsof [ -?abChlnNOPRstUvVX ] [ -A A ] [ -c c ] [ +c c ] [ +|-d d ] [ +|-D D ] [ +|-f [cfgGn] ] [ -F [f] ] [ -g [s] ] [ -i [i] ] [ -k k ] [ +|-L [l] ] [ +|-m m ] [ +|-M ] [ -o [o] ] [ -p s ] [ +|-r [t] ] [ -S [t] ] [ -T [t] ] [ -u s ] [ +|-w ] [ -x [fl] ] [ -z [z] ] [ -- ] [names] Yee-ikes. Let's get two quick tips taken care of before we move on to the details. First, you probably don't ever want to run lsof with no options specified, as that will generate a list of every open file on your machine (likely thousands of lines). Second, for a quick review of all those options, try lsof -h. More after the break...

  • Monday man page: dig, host & nslookup

    by 
    Michael Rose
    Michael Rose
    01.29.2007

    For this week's Monday man page, it's a triple threat: dig, host, and nslookup. All three utilities are included with the BIND (Berkeley Internet Name Domain) version 9 package, part of every Mac OS X 10.4 installation, and all three do pretty much the same task: translate hostnames to IP addresses and vice versa. In 10.3.9 and earlier, the Network Utility 'lookup' tab was a front-end for nslookup, with an option via checkbox to use dig instead; starting in 10.4 the checkbox is gone and the utility is dig-only. If you want a good introduction to how DNS works, the MacDevCenter has an excellent primer, and I can also heartily recommend DNS and BIND, possibly the most comprehensible book about a complicated subject that I've ever read. After the jump, we'll talk a bit more about how DNS lookup tools are useful, and why you might prefer one of this troika to the others.

  • Sshfs the Easy Way

    by 
    Mat Lu
    Mat Lu
    01.16.2007

    Just earlier today we pointed out Jay Savage's great MacFUSE tutorial on Download Squad. For the lazy (or more terminal wary) among us (including me), there is a perhaps easier option: sshfs for Darwin which comes as a nice downloadable binary. Like the MacFUSE tip, this should allow you to "mount [a] remote server filesystem via ssh (using sftp protocol)." Some terminal work is still required to mount and unmount the remote server, but this seems to be substantially easier (and slightly less cool) than the MacFUSE method. Two sshfs tips in one day for the price of one![Via Daring Fireball]

  • AppleScript Shell: Command Line AppleScripting

    by 
    Mat Lu
    Mat Lu
    01.03.2007

    This one is probably going to be of limited interest, but it's still pretty nifty. Daniel Jalkut points us toward the AppleScript Shell by Cameron Hayne. It lets you run AppleScript commands directly from a command line interface for immediate execution. Ash (a la bash) is implemented as a perl script. Daniel's post has a neat application in which he used ash to access some address book information on a remote Mac. Incidentally, already built into OS X is osascript which allows you to execute a pre-built AppleScript from the command line. If I'm not mistaken, however, I don't think it will allow you to execute AppleScript commands directly. This is worth checking out for the geekier among us.[Edit: both my colleague Erica and the commentators below have pointed out that it is possible to execute AppleScript commands with osascript, but it does seem that the syntax is a bit cleaner with ash][Via red sweater blog]

  • Joystiq on Terminal emacs games

    by 
    Michael Rose
    Michael Rose
    12.28.2006

    Our brothers-in-arms at Joystiq have a cute video up of the 'hidden' Terminal games you can play. These games are part of the GNU emacs text editor, which is bundled on virtually every Unix-like OS and can be had for pretty much any OS out there.Granted, they aren't pretty or fast, but they might be worth a few minutes while stuck at the Denver airport... again...[via digg/powerpage/joystiq]Thanks Brandon!