How to Open Any Folder from the Mac Terminal

Open Folder Mac Terminal Featured 2

The standard way to open any directory within macOS is to open a Finder window and use it to navigate to a specific location on your hard drive. But there’s also another way to open folders on a Mac: the built-in Terminal. It may not be something you use every day unless you’re a developer, but the power is there if you need to call on it.

How to Open Any Folder from the Mac Terminal

To begin, open the Terminal through the Application -> Utilities folder.

Mac Terminal 1

Alternatively, type “Terminal” in Spotlight. Once it’s open, you won’t need any dependencies to open any folder from the Mac Terminal – only the open command. The general syntax is:

open /path/to/Directory/

For example, to open the Pictures folder, use:

open /Users/<username>/Pictures

This will open the Pictures folder in a Finder window, which can be used to access its files.

Remember to replace <username> with your Mac username. If you are not sure what your username is, look at the bottom of your Finder window.

Mac Finder Username

There are also other short commands that allow access to specific folders:

Mac Terminal
  • To open the Root directory, use open /.
  • For your Home folder (i.e., the folder containing Desktop, Documents, and other folders specific to the user), type open ~.
  • To open the current working folder within Finder, use open ..

While the commands so far open specific folders, you can also launch (and update) applications from the Terminal without using Finder. For example, to open Safari, type open /Applications/Safari.app.

Of course, you can open any app on your system, as long as you know its file name.

Open a Folder in Terminal from a Shortcut Menu

It may be that you want to reverse the situation and open a Finder directory in the Terminal. In other words, make it the current working directory. Carry this out by adding a right-click shortcut.

Head to System Preferences -> Keyboard.

Mac System Preferences Keyboard

Navigate to the Shortcuts tab. Select the Services menu, and scroll down to Files and Folders -> New Terminal at Folder.

Mac New Terminal At Folder

If you select any folder within Finder, open the Services menu from the Toolbar and choose New Terminal at Folder.

Screenshot

This is ideal if you often switch between the Mac user interface and the Terminal.

Why You’d Want to Open a Folder From the Mac Terminal

As noted, the preferred way of opening a folder is by using Finder. This is a Graphical User Interface (GUI), and it’s macOS’s default directory navigation. But it’s not the only way to access files or folders within macOS.

Admittedly, using the Terminal to open folders isn’t a natural way to get around macOS. Though, you’ll find it handy in the following situations:

  • It may be something in your toolbox if you’re a command line user.
  • Developing for Mac often means working within the Terminal. It may be the path of least resistance.
  • In a rare situation of macOS acting as server software, you may only be able to use the Terminal to navigate the Operating System (OS).

The Mac Terminal isn’t something you’ll encounter often, unless you’re a developer or system admin. Yet, opening a folder is a basic task that can keep you on the command line as long as possible. All you need is the open command and the path to your folder. But most Mac users will simply open a folder the old-fashioned way: by clicking on it.

If you’re looking for more to do with the Terminal, try searching the Web without a browser, direct from the command line.

Image credit: Unsplash. All screenshots by Mark O’Neill.

Subscribe to our newsletter!

Our latest tutorials delivered straight to your inbox

Mark O'Neill
Mark O'Neill - Staff Writer

Mark O'Neill is a freelance tech journalist, editor, and bestselling spy fiction author. Originally from Scotland, he now lives in Germany with his wife and his dog.