TExcelTAD
Home › Terminal & Command Line › Opening a Terminal

Opening a Terminal

Before you can type a command you need a terminal window. This lesson lists the quickest ways to open one on each OS, how to open it in a specific folder, how to get an administrator shell when you need one, and the reverse trick: opening a folder in the file manager from the terminal.

Windows

Method What opens
Right-click the Start button (or Win+X) → Terminal Windows Terminal with your default profile (PowerShell)
Win+R, type wt, Enter Windows Terminal
Win+R, type cmd or pwsh, Enter CMD or PowerShell 7 directly
Start menu, type terminal, cmd or powershell the matching app
In File Explorer, right-click inside a folder → Open in Terminal Windows Terminal already in that folder
In File Explorer, click the address bar, type cmd or wt, Enter a shell in that folder
In VS Code: Terminal → New Terminal (Ctrl+Shift+Backquote) a terminal in the project folder

For an administrator shell, right-click Start → Terminal (Admin), or right-click the app in the Start menu → Run as administrator. Windows shows a UAC prompt, and the title bar says Administrator. CMD's default admin folder is C:\Windows\system32, which is a handy hint that you're elevated:

cmd
C:\Windows\system32>

Windows 11 (24H2 and later) also has an optional sudo command that you switch on in Settings → System → Advanced; it elevates a single command, like on Linux and macOS. Only use an admin shell for tasks that need it (installing for all users, changing services). See Admin Rights & Permissions.

macOS

Method What opens
Cmd+Space, type Terminal, Enter Terminal.app
Finder → Applications → Utilities → Terminal Terminal.app
Finder: right-click a folder → Services → New Terminal at Folder Terminal in that folder (enable it once in System Settings → Keyboard → Keyboard Shortcuts → Services)
Drag a folder onto the Terminal icon in the Dock Terminal in that folder
Drag a file or folder into a Terminal window pastes its full path at the cursor

Admin rights on macOS come from sudo in front of a single command, not from a separate window (more in a later lesson).

Linux

Method What opens
Ctrl+Alt+T (Ubuntu, Mint and others) the default terminal
Super key, type terminal, Enter the default terminal
Files (Nautilus): right-click inside a folder → Open in Terminal terminal in that folder
Ctrl+Alt+F3 … F6 a full-screen text console (Ctrl+Alt+F1 or F2 returns to the desktop)

Like macOS, Linux uses sudo for individual admin commands.

Where does a new terminal start?

A new terminal starts in your home folder unless you opened it from a folder. Every shell can tell you where home is. In the CMD playground the user is learner:

cmd · try it yourself
@echo off
echo Home: %USERPROFILE%
echo User: %USERNAME%
cd
Home: C:\Users\learner
User: learner
C:\Users\learner

On a real Windows PC you would see C:\Users\<your name>. PowerShell calls the same folder $HOME (and also understands ~). The PowerShell playground runs on Linux with its home set to /tmp, so you see Unix paths:

powershell · try it yourself
"Home: $HOME"
Set-Location ~
(Get-Location).Path
Home: /tmp
/tmp

In bash and zsh, ~ and $HOME are your home folder. ($USER holds your user name in a normal login shell; whoami works everywhere.) The playground's user is learner; on a Mac it would be /Users/ada, on Linux /home/ada:

bash · try it yourself
echo "Home: $HOME"
echo "User: $(whoami)"
cd ~
pwd
Home: /home/learner
User: learner
/home/learner

Opening a folder the other way round

Sometimes you are in the terminal and want to see the folder in the graphical file manager, or open a file in its default app. Each OS has a command for that (these need a desktop, so they're shown as sessions):

cmd
C:\Users\ada\projects>start .
C:\Users\ada\projects>start report.pdf
powershell
PS C:\Users\ada\projects> Invoke-Item .
PS C:\Users\ada\projects> explorer.exe .
zsh
ada@macbook ~/projects % open .
ada@macbook ~/projects % open report.pdf
ada@macbook ~/projects % open -a "Visual Studio Code" .
bash
ada@ubuntu:~/projects$ xdg-open .
ada@ubuntu:~/projects$ xdg-open report.pdf
Task CMD PowerShell macOS (zsh) Linux (bash)
Open current folder in file manager start . ii . (Invoke-Item) open . xdg-open .
Open a file in its default app start file.pdf ii file.pdf open file.pdf xdg-open file.pdf
Open a new terminal window start cmd Start-Process pwsh open -a Terminal . depends on the terminal app (gnome-terminal)
Open VS Code here (if installed) code . code . code . code .

Closing a terminal

Type exit (works in all four shells) or close the window. Closing the window also stops programs still running in it. On Linux and macOS, Ctrl+D on an empty line means "end of input" and closes the shell too.

Learn more: The Prompt & Command Syntax · The Terminal on Windows · The Terminal on macOS

Test yourself

Which command opens the current folder in Finder on macOS?

  1. start .
  2. xdg-open .
  3. open .
  4. explorer .

How do you get an elevated (administrator) PowerShell on Windows 11?

  1. Press Ctrl+Shift+Esc
  2. Right-click Start and choose Terminal (Admin)
  3. Press Ctrl+Alt+T
  4. Run exit twice

Where does a newly opened terminal start by default?

  1. In the root of the drive
  2. In your home folder
  3. In the system folder
  4. In the last folder you used