How to use the terminal on Linux, Mac, and Windows (PowerShell)
Learn how to open the terminal on each system, read the prompt, and use the essential commands to move around and work with files on Linux, macOS, and Windows PowerShell.
Beginner$ pwd && ls▍A black screen with blinking text is intimidating at first, but the terminal is just another way of talking to your computer: instead of clicking, you type. With a dozen commands you can already move between folders, create files, and find what you need, and that knowledge carries over to Linux, macOS, and Windows.
How to open the terminal
- Linux: on many distributions, such as Ubuntu, the shortcut is
Ctrl + Alt + T. You can also search for “Terminal” in the applications menu. - macOS: press
Cmd + Spaceto open Spotlight, type “Terminal,” and hit Enter. It’s also in Applications > Utilities. - Windows: search for “Terminal” or “PowerShell” in the Start menu. Windows Terminal comes with Windows 11 and can be installed from the Microsoft Store on Windows 10; by default, it opens PowerShell.
Want a real Linux inside Windows? See the article on WSL.
Understanding the prompt
The prompt is the text that appears before the cursor, telling you the terminal is ready for a command. It varies from system to system:
your-user@my-pc:~/projects$ # Linux (bash)
your-user@MacBook ~ % # macOS (zsh)
PS C:\Users\your-user> # Windows (PowerShell)
In the Linux example: your-user is your user, my-pc is the computer’s name, ~/projects is the current folder (~ is a shortcut for your home folder), and $ means a regular user. If you see # instead of $, you’re logged in as root, the administrator, and should be extra careful.
Behind the terminal there’s a shell, the program that interprets what you type. To understand the difference, read what is a shell and shell scripting.
Essential commands: Linux/macOS vs. PowerShell
| Task | Linux and macOS (bash/zsh) | Windows (PowerShell) |
|---|---|---|
| Where am I? | pwd |
Get-Location |
| List files | ls |
Get-ChildItem (or ls) |
| Go into a folder | cd projects |
cd projects |
| Go up one folder | cd .. |
cd .. |
| Create a folder | mkdir tests |
mkdir tests |
| Create an empty file | touch notes.txt |
New-Item notes.txt -ItemType File |
| Copy | cp notes.txt copy.txt |
Copy-Item notes.txt copy.txt |
| Move or rename | mv copy.txt old.txt |
Move-Item copy.txt old.txt |
| Remove a file | rm old.txt |
Remove-Item old.txt |
| Show contents | cat notes.txt |
Get-Content notes.txt |
| Search for text | grep "error" log.txt |
Select-String "error" log.txt |
| Clear the screen | clear |
Clear-Host (or cls) |
| Get help | man ls |
Get-Help Get-ChildItem |
Fun fact: on Windows, PowerShell has aliases like ls, cd, cat, cp, and rm that point to the equivalent commands. That helps a lot, but the options are different: ls -la, for example, doesn’t work the way it does on Linux.
Hands-on
This walkthrough creates a test folder and only touches things inside it. It works on Linux and macOS:
cd ~ # goes to your home folder
mkdir terminal-practice # creates a test folder
cd terminal-practice
touch notes.txt # creates an empty file
echo "my first line" > notes.txt
cat notes.txt # shows the contents
cp notes.txt copy.txt
ls -l # detailed listing
pwd # confirms where you are
The same idea in PowerShell:
cd ~
mkdir terminal-practice
cd terminal-practice
New-Item notes.txt -ItemType File
Set-Content notes.txt "my first line"
Get-Content notes.txt
Copy-Item notes.txt copy.txt
Get-ChildItem
Get-Location
Shortcuts that save time
- Tab: completes command, folder, and file names. Type
cd terand press Tab. - Up arrow: brings back previous commands.
- Ctrl + C: stops the command that’s running. In the terminal, it’s not “copy”!
- Ctrl + R: searches your command history (bash and zsh; modern PowerShell has something similar).
- Copy and paste: on Linux, usually
Ctrl + Shift + CandCtrl + Shift + V; on macOS,Cmd + CandCmd + V; in Windows Terminal,Ctrl + Ccopies when text is selected andCtrl + Vpastes.
Safety: habits that save you headaches
- Be careful with
rmandRemove-Item: there’s no recycle bin in the terminal. Once it’s deleted, it’s gone. Check the path withpwdandlsbefore removing anything. - Don’t paste commands you don’t understand: tutorials and forums sometimes include dangerous commands. Read, look them up, and only then run them.
- Use
sudoor “Run as administrator” only when needed: with administrator rights, a single typo can affect the whole system.
Installing software from the terminal
Each system has a package manager, a kind of app store that works through commands:
sudo apt install htop # Ubuntu and Debian (apt)
brew install htop # macOS (Homebrew)
winget install Git.Git # Windows (winget)
apt ships with Ubuntu and Debian, and winget comes with current versions of Windows 10 and 11. Homebrew has to be installed separately on macOS: follow the instructions on the official site (brew.sh) and read what the install command does before running it.
Try it yourself
- Open your system’s terminal and identify each part of the prompt
- Run
pwd(orGet-Location) and find out which folder you start in - Follow the “Hands-on” walkthrough from start to finish
- Use Tab to complete the name of the
terminal-practicefolder - Press the up arrow and rerun a previous command
- Open the help for a command with
man lsorGet-Help Get-ChildItem - Install a simple program with your system’s package manager
Next steps
The terminal doesn’t bite: every command you learn today is one less click tomorrow.