Mac OS X - Terminal Tips and Tricks

1 1 1 1 1 Rating 3.83 (6 Votes)

This article covers some useful tips and tricks in the Mac OS X terminal. Search for hidden files, Switch between the 32 bit and 64 bit kernel, fixing kernel extensions, enabling NTFS support and more.

 

  1. Finding absolutely anything on your Macintosh
  2. How to tell if you’re running the 32 bit or 64 bit kernel in Mac OS X Snow Leopard
    1. Method 1
    2. Method 2
  3. How to switch between 32-bit and 64-bit kernel mode in Mac OS 10.6
    1. Method 1 - Startup key combination (for current startup only)
    2. Method 2 - On-disk setting (persistent)
  4. Delete all files anywhere on your Mac which match a search term
  5. Working with Kernel Extensions
    1. Load kext
    2. Unload kext
    3. Troubleshooting kext (Mac OS 10.6.2 and above)
    4. Change Ownership of kext
  6. Enable NTFS drive support in OSX Snow Leopard or Lion
  7. Show hidden files in the finder

    Finding absolutely anything on your Mac

    The Spotlight feature doesn't search the Library or hidden locations.


    Aside from Spotlight feature, OSX also has a Find feature. Unlike Spotlight you can configure OSX's Find feature (CMD+F) look for system files by performing the following:

     

    1. Press CMD+F to open the Find window.
    2. Towards the left of the window, just above where the search results would appear, you'll a pull-down menu which says (by default) Kind. Click this, and choose Other.
    3. In the window that opens, scroll down, find, and check off System files.
    4. Click OK to close the window.
    5. Now, you can perform searches which will include System files in the results. To do this, select the following criteria for your search:
      System files include.


    However, even this will not search all files on your Mac (i.e. items in hidden folders). To search all locations for a file, perform the following:

     

    1. Open Macintosh HD > Applications > Utilities > Terminal.
    2. In the window that opens, type the following, then press Enter:

      sudo find / -name "*Bicycles*"

      ...where in-place of Bicycles you enter your search term.

    3. You will be presented with a list of file-paths to any items whose file name contains your search term. The search can take a long time to complete. When the command prompt is displayed again (the same one which initially appeared at the top of the Terminal window when you first opened it), you'll know the search has completed.

     

    How to tell if you’re running the 32 bit or 64 bit kernel

    Summary

    Snow Leopard 10.6 was the first Mac OS X version to ship with a 64 bit kernel. While our Mac has to have a 64 bit processor to utilize that kernel, some 64 bit Macintoshes do not default to using the 64 bit kernel.


    Note: Not all applications support the 64 bit kernel. When using applications which only support 32-bit kernel mode, be sure you are running your computer using the 32-bit kernel.

     

    Method 1

    1. In the upper-left of the screen, select the Apple menu, and choose About this Mac.
    2. In the window that opens, click the More Info button.
    3. In the Contents pane on the left-hand side of the window that opens, select Software.

      On the right, under System Software Overview, if 64-bit Kernel and Extensions is set to No, you are running a 64-bit kernel.

     

    Method 2

    1. Open Macintosh HD > Applications > Utilities > Terminal.

    2. In the window that opens, type the following, then press Enter:

      uname -a

    3. If you’re using a 32 bit Kernel in Mac OS X, you'll see:

      Darwin iMac.local 10.0.0 Darwin Kernel Version 10.0.0: Fri Jul 31 22:47:34 PDT 2009; root:xnu-1456.1.25~1/RELEASE_I386 i386

      If you’re using a 64 bit Kernel in Mac OS X, you'll see:

      Darwin iMac.local 10.0.0 Darwin Kernel Version 10.0.0: Fri Jul 31 22:47:34 PDT 2009; root:xnu-1456.1.25~1/RELEASE_X86_64 x86_64

     

    How to switch between 32-bit and 64-bit kernel mode

    Summary

    On hardware that supports the 64-bit kernel, you can choose whether to start up (boot) your Mac using the new 64-bit kernel or the earlier 32-bit kernel.


    Products Affected

    Mac OS X Server 10.6, Mac OS X 10.6, Mac Pro (Mid 2010)

     

    Method 1 - Startup key combination (for current startup only)

    • If your Mac uses the 32-bit kernel by default, but supports the 64-bit kernel, you can start up using the 64-bit kernel by holding the 6 and 4 keys during startup.
    • If your Mac uses the 64-bit kernel by default, you can start up with the 32-bit kernel by holding the 3 and 2 keys during startup.

      Note:Your Mac will revert to the default kernel the next time you reboot it.

     

    Method 2 - On-disk setting (persistent)

    • To select the 64-bit kernel for the current startup disk, perform the following:

      1. Open Macintosh HD > Applications > Utilities > Terminal.

      2. In the window that opens, type the following, then press Enter

        sudo systemsetup -setkernelbootarchitecture x86_64

      3. Restart your computer.

    • To select the 32-bit kernel for the current startup disk, perform the following:

      1. Open Macintosh HD > Applications > Utilities > Terminal.

      2. In the window that opens, type the following, then press Enter

        sudo systemsetup -setkernelbootarchitecture i386

      3. Restart your computer.

        Note: This setting is stored in the /Library/Preferences/SystemConfiguration/com.apple.Boot.plist file and will take effect every time you start up from this disk. If you start up from a different disk, the setting on that disk, or the hardware default, will take effect.

     

    Delete all files anywhere on your Mac which match a search term

    Be very careful with this one. There's almost no reason you'd need to do this. If you're trying to delete something, you should try any and all of the following first (listed in order):

     

    1. If you're deleting an application, just find it, drag it to the trash, and empty the trash.
    2. Finding the file using Spotlight, the OSX Find Feature, or the method described above. Then delete it yourself.
    3. AppZapper - Free utility which aids in completely uninstalling programs.
    4. AppCleaner - Free utility which aids in completely uninstalling programs and can catch files that Appzapper may miss.
    5. DesInstaller - Simple Macintosh utility for uninstalling device drivers. Be careful not to delete the wrong file(s).
    6. Leopard Cache Cleaner - Powerful Utility Useful for Installation Problems


    If these don't accomplish what you needed, and your problem is serious enough, consider reinstalling your Mac OS, or using Time Machine to revert to a previously saved working state (You are using Time Machine right?).


    The main point here is that the procedure below should be used at-your-own-risk, with extreme caution, and as an absolute last resort. Anything deleted using this method is not undo-able. If you delete the wrong file, worst-case-scenario, you could remove a critical system file, preventing your Mac from booting.

     

    1. Open Macintosh HD > Applications > Utilities > Terminal.

    2. In the window that opens, type the following, then press Enter:

      sudo find / -name "*Bicycles*" –delete

      ...where in-place of Bicycles you enter your search term.

    3. Any items whose file name contains your search term will be permanently deleted from your computer. The operation can take a long time to complete. When the command prompt is displayed again (the same one which initially appeared at the top of the Terminal window when you first opened it), you'll know the operation has completed.

     

    Working with Kernel Extensions

    Load kext

    1. Open Macintosh HD > Applications > Utilities > Terminal.

    2. In the window that opens, type the following, then press Enter:

      sudo kextload /System/Library/Extensions/Bicycles.kext/

      ...where in-place of Bicycles you enter the name of the Kernel Extension you'd like to load.

     

    Unload kext

    1. Open Macintosh HD > Applications > Utilities > Terminal.

    2. In the window that opens, type the following, then press Enter:

      sudo kextunload /System/Library/Extensions/Bicycles.kext/

      ...where in-place of Bicycles you enter the name of the Kernel Extension you'd like to unload.

     

    Troubleshooting kext (Mac OS 10.6.2 and above)

    1. Open Macintosh HD > Applications > Utilities > Terminal.

    2. In the window that opens, type the following, then press Enter:

      sudo kextutil /System/Library/Extensions/Bicycles.kext

      ...where in-place of Bicycles you enter the name of the Kernel Extension you'd like to look at.

      You'll be presented with information on the status of the extension.

     

    Change Ownership of kext

    Often, using the troubleshooting step above, you'll find that you have ownership issues with a kext.

    1. Open Macintosh HD > Applications > Utilities > Terminal.

    2. In the window that opens, type the following, then press Enter:

      sudo chown -R root:wheel /System/Library/Extensions/Bicycles.kext

      ...where in-place of Bicycles you enter the name of the Kernel Extension you'd like to change.

     

    1. Open Macintosh HD > Applications > Utilities > Terminal
    2. In the window that opens, type the following, then press Enter:

      sudo chmod -R 755 /System/Library/Extensions/Bicycles.kext

      ...where in-place of Bicycles you enter the name of the Kernel Extension you'd like to change.

     

    Enable NTFS drive support in OSX Snow Leopard or Lion

    1. Open Macintosh HD > Applications > Utilities > Terminal.

    2. In the window that opens, type the following, then press Enter:

      diskutil info /Volumes/volname

      ...where volname is the name of the NTFS volume.

    3. From the output, copy the Volume UUID value to the clipboard.

    4. Type the following, then press Enter:

      sudo nano /etc/fstab

    5. Then Type the following:

      UUID=111-111-111 none ntfs rw

      ...where 111-111-111 is the UUID you copied.

    6. Save and quit the nano function by typing Ctrl+X, Y, and then Enter.

    7. Restart your system.

     

    Show hidden files in the finder

    1. Open Macintosh HD > Applications > Utilities > Terminal.

    2. In the window that opens, type the following, then press Enter:

      defaults write com.apple.finder AppleShowAllFiles TRUE

    3. Restart your computer.

    4. To hide them again, type the following, then press Enter:

      defaults write com.apple.finder AppleShowAllFiles FALSE

    Popular

    Latest Articles