The standard way to open any directory on a Mac is by opening a Finder window and using it to navigate to a specific location on your hard drive. However, there’s also an alternate way to open folders – by using Terminal. While this isn’t something that will be used in your daily routine, if you are a developer (or someone who uses the Terminal frequently), this trick can be very useful.
Here we’ll show you how to use the
open command to open any directory directly from Terminal, bypassing Finder.
1. Open Terminal on your Mac. This can be done by using Spotlight or by navigating to “Applications -> Utilities.”
2. In Terminal, we’ll now use the
open command. The general syntax for this command is as follows:
For example, if I want to open the Documents folder directly from Terminal, my syntax would look like:
This will open the Documents folder in a Finder window, which you can then use to access the files in it.
To open the Root Directory in Finder, use the following command:
Similarly, to open the User Home folder (which contains the Desktop, Documents, Pictures folders, etc.), simply type in the following command in Terminal:
If you’re a programmer and are using Terminal to navigate through various system files and suddenly find the need to open a specific file you’ve found in Terminal, you can easily use the following command to do so:
This will open the specific folder directly in Finder where you can make any modifications you may need to.
All the commands mentioned above can be used to open specific directories or system resources, but you can also directly launch applications or utilities from the Terminal command line without using Finder. For example, if I wanted to open Safari directly from Terminal, I’d type in:
Use similar commands specifying the application location and name followed by “.app” to open any application on your Mac.
Open Folder in Terminal
Conversely, if you are in a folder in Finder and want to open it in Terminal, you can easily add a right-click shortcut to do so.
1. Open System Preferences on your Mac.
2. Navigate to “Keyboard -> Shortcuts.”
3. From the Services menu, enable “New Terminal at Folder.” This will automatically add the option to open the folder in Terminal to the Services menu. You can also set a keyboard shortcut for this for quicker access.
4. Now whenever you select any folder you’d like to open in Terminal, simply select “New Terminal at Folder,” and it’ll open the folder location in Terminal.
Using the commands and shortcuts above, you’ll hopefully be able to use Terminal more efficiently. Let us know of any questions or comments in the below.