Open Command Prompt or Terminal to Specific Folder in Windows, Mac or Linux
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.
On Windows, you can press the Shift key and right-click on a folder to open a PowerShell window directly to that folder.
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.
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.
A Command Prompt (or PowerShell) window opens directly to the selected folder.
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.
Click Keyboard on the System Preferences dialog box.
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 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.
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.
A new Terminal window opens directly to the selected folder if you selected the New Terminal at Folder option.
Selecting the New Terminal Tab at Folder option opens a new tab on the active Terminal window directly to the selected folder.
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.
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.
A new Terminal window opens directly to the selected folder.
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.