How-To

Open a Command Prompt or Terminal to a Specific Folder in Windows, Mac or Linux

file-folder-system-feature

Work with folders and files often in the Command or Terminal window in Windows, Mac or Linux? You’ll save time by opening it directly to a specific folder.

To go to a specific folder on the command line, generally, you must use the cd command and know the exact complete path to the folder you want. But there’s an easier way. You can open a PowerShell window, Command Prompt window, or a Terminal window to a specific folder from within the file manager. Today, we’ll show you how to do this in Windows, Mac, and Ubuntu Linux.

Windows 10

On Windows, you can press the Shift key and right-click on a folder to open a PowerShell window directly to that folder.

Open PowerShell window here option in Windows

Or you can add the ‘Open command window here’ from the context menu and use that to open a Command Prompt window to the folder.

Open command window here option in Windows

The article linked to above also shows you how to add the “Open command window here” option to the context menu when you’re in a folder.

Open command window here option on the Windows context menu in a folder

A Command Prompt (or PowerShell) window opens directly to the selected folder.

Command Prompt window open to a specific folder in Windows

macOS

To open a Terminal window to a specific folder from Finder, you must make sure the New Terminal at Folder and New Terminal Tab at Folder services are activated.

To activate these two services, select System Preferences from the Apple menu.

Open System Preferences on a Mac

Click Keyboard on the System Preferences dialog box.

Click Keyboard in System Preferences on a Mac

On the Keyboard dialog box, click the Shortcuts tab at the top and then select Services on the left.

Under Files and Folders on the right, check the New Terminal at Folder and New Terminal Tab at Folder boxes.

You can add shortcuts to these two services to make it faster to open a Terminal window to a folder. Click None to the right of the service you want to add a shortcut to.

Click None to add a shortcut to the New Terminal at Folder service on a Mac

Click Add Shortcut and then press the shortcut you want to use for the service. Make sure you select a shortcut not used by the system. We found it hard to find a unique shortcut because there are so many shortcuts already set up in macOS.

Also, you may have to click Add Shortcut again and then press Enter to get your shortcut to stick.

Click Add Shortcut for the New Terminal at Folder service on a Mac

To open a Terminal window from within a folder in Finder, navigate to the folder you want. Do not go into the folder.

Select the folder, right-click on it, and go to Services > New Terminal at Folder to open a new Terminal window to the selected folder. If you want to open a new tab in an open Terminal window, go to Services > New Terminal Tab at Folder on the right-click menu. Opening a new tab on an existing Terminal window requires the window to be active, not minimized.

If you set up shortcuts for the two options, select the folder and press the shortcut for the option you want to use.

Select New Terminal at Folder on a Mac

A new Terminal window opens directly to the selected folder if you selected the New Terminal at Folder option.

Terminal window open to a folder on a Mac

Selecting the New Terminal Tab at Folder option opens a new tab on the active Terminal window directly to the selected folder.

New tab on a Terminal window opened to a folder on a Mac

To remove the New Terminal options from the Services menu, go back to Apple menu > System Preferences > Keyboard > Shortcuts > Services and uncheck the two options on the right.

Linux

Here I’m using Ubuntu to open a Terminal window to a specific folder in Linux. The procedure may vary a bit on other Linux distros like Linux Mint, Zorin, and Fedora.

Open the Files app (which used to be called Nautilus), from the left sidebar. Go to the folder you want to open in a Terminal window, but don’t go into the folder.

Select the folder, right-click on it, and then select Open in Terminal.

Select Open in Terminal in Ubuntu Linux

A new Terminal window opens directly to the selected folder.

Terminal window open to a specific folder in Ubuntu Linux

Save Time Navigating to Folders in a Command or Terminal Window

You can use the cd command to navigate to a folder on all three systems. Or, you can copy a full path to a folder and paste it into the Command or Terminal window. But if you do that, remember to insert backslashes in front of all the spaces in the path.

But the options we showed you here are easier and faster. And if you work with folders and files often in the Command or Terminal window, you’ll save time and be more productive.

2 Comments

2 Comments

  1. maynalysa

    July 10, 2019 at 4:51 pm

    Thank you

  2. Patrick Callahan

    April 7, 2021 at 6:17 am

    I’m looking for how to open a terminal from the command line, positioned in a specific directory. This is similar to opening a terminal with the right-click option but using only the command line to open a new command window. This is useful when you want to set up a desktop icon that brings you to a specific folder.

Leave a Reply

Your email address will not be published. Required fields are marked *

 

To Top