Skip to content
Laviyx Learn

Try

Linux and Bash course menu

How to Get a Linux Terminal on Windows or Mac

Practise Linux without leaving Windows: install WSL, use a virtual machine, a free cloud shell, or the Mac terminal, and open your first Bash prompt.

Beginner4 min readUpdated
On this page

You do not need to replace Windows to learn Linux. Choose one of these.

OptionGood forEffort
WSL (Windows)Most Windows usersLow
Virtual machineA full, separate Linux desktopMedium
GitHub CodespacesTrying Linux in a browserLow
Mac TerminalMac users, for most lessonsNone
Linux serverPractising real server workMedium, may cost money

Windows: install WSL#

WSL (Windows Subsystem for Linux) runs a real Linux system inside Windows. Open PowerShell as administrator, and run:

Terminal
wsl --install

Restart when asked. Ubuntu then opens and asks you to create a username and password. This Linux user is separate from your Windows account.

To open it later, search for Ubuntu in the Start menu. Update it once:

Terminal
sudo apt update
sudo apt upgrade

Your Windows drives are available under /mnt/c. Keep practice files in your Linux home folder, where commands run faster.

macOS#

Open Terminal. macOS is based on Unix, so most commands work, but its default shell is zsh, and some tools have different options. The lessons on systemd, apt and some sed options need a real Linux system, so use a virtual machine or Codespaces for those.

Virtual machine#

Install VirtualBox, download the Ubuntu LTS image from ubuntu.com, and create a new machine with at least 4 GB of memory and 25 GB of disk.

GitHub Codespaces#

With a GitHub account, open any repository and choose Code, then Codespaces, then Create codespace. You get a Linux terminal in your browser, and GitHub's free plan includes a monthly allowance.

Check your terminal#

Run these three commands:

Terminal
whoami
hostname
echo $SHELL
Output
asha
laviyx
/bin/bash

You will see your own username and computer name. If the last line ends in bash, you are ready.

The prompt#

Before each command, the terminal shows a prompt:

Text
asha@laviyx:~$
PartMeaning
ashaYour username
laviyxThe computer's name
~Your current folder; ~ means your home folder
$You are a normal user; # means you are the administrator (root)

In this course, the prompt is left out, so that you can copy the commands directly.

Keyboard shortcuts#

KeysAction
TabComplete a command or file name
↑ and ↓Go through earlier commands
Ctrl+CStop the running command
Ctrl+LClear the screen
Ctrl+RSearch your command history
Ctrl+DLog out of the shell

Use Tab all the time. It saves typing and prevents mistakes.

Common mistakes#

Key takeaway#

Next: Your First Commands.

Finished this lesson?