Getting started with the command line
The command line is a way of telling the computer what to do by typing, instead of clicking. It looks old-fashioned and is still in daily use, because for many jobs it is faster, it can be repeated exactly, and it works when nothing else does. This guide gets you from never having opened it to running your first commands safely.
Opening it
| System | Program | How to open |
|---|---|---|
| Windows | Command Prompt | press the Windows key, type cmd, press Enter |
| Windows | PowerShell or Windows Terminal | press Win + X and choose Terminal |
| Mac | Terminal | press Cmd + Space, type terminal, press Enter |
| Linux | Terminal | press Ctrl + Alt + T on most desktops, or search for Terminal |
A window opens with a line of text ending in a symbol and a blinking cursor. That line is the prompt. It is the computer waiting for you.
Reading the prompt
On Windows it looks like C:\Users\asha>. On Linux and the Mac, something like asha@pc:~$. Either way it tells you which folder you are in. The ~ on Linux and the Mac means your home folder. Everything you type happens in that folder unless you say otherwise.
How a command is built
A command is a line of words, run when you press Enter.
command options arguments
- The command is the name of a program:
dir,ls,copy. - Options change how it behaves. On Windows they begin with a slash, as in
/b. On Linux and the Mac they begin with a dash, as in-l. - Arguments say what to act on, usually file or folder names.
Spaces separate the parts. That is why a name containing a space must go in quotation marks.
Make a practice folder first
Do your learning in a folder that holds nothing you care about. Then no mistake can cost you anything.
On Windows:
C:\Users\asha\demo>mkdir practice
C:\Users\asha\demo>cd practice
C:\Users\asha\demo\practice>echo hello > first.txt
C:\Users\asha\demo\practice>dir /b
first.txt
C:\Users\asha\demo\practice>type first.txt
hello On Linux or a Mac:
asha@pc:~/demo$ mkdir practice
asha@pc:~/demo$ cd practice
asha@pc:~/demo/practice$ echo hello > first.txt
asha@pc:~/demo/practice$ ls
first.txt
asha@pc:~/demo/practice$ cat first.txt
helloYou have made a folder, gone into it, created a file and read it back.
The first ten commands
| Job | Windows | Linux and Mac |
|---|---|---|
| where am I? | cd | pwd |
| list this folder | dir | ls |
| go into a folder | cd name | cd name |
| go up one level | cd .. | cd .. |
| make a folder | mkdir name | mkdir name |
| show a text file | type file | cat file |
| copy a file | copy a b | cp a b |
| move or rename | move a b, ren a b | mv a b |
| clear the screen | cls | clear |
| get help | command /? | man command |
Notice that deleting is not on the list. Leave it until the rest feels comfortable.
Keys that save effort
- Tab completes a file or folder name after you type its first letters. Use it constantly. It prevents spelling mistakes.
- Up arrow brings back the previous command, ready to run again or edit.
- Ctrl + C stops a command that is running or has gone wrong.
- Ctrl + L on Linux and the Mac, or
clson Windows, clears the screen.
Copying and pasting
In the Windows Command Prompt and Windows Terminal, Ctrl + C and Ctrl + V work, and a right-click pastes. On a Mac, use Cmd + C and Cmd + V. In Linux terminals, copy and paste are Ctrl + Shift + C and Ctrl + Shift + V, because Ctrl + C already means "stop".
When something goes wrong
Read the message. Command-line errors are short and usually exact.
| Message | Meaning |
|---|---|
| "is not recognized as an internal or external command" (Windows), "command not found" (Linux, Mac) | the command's name is misspelt, or the program is not installed or not on the PATH |
| "The system cannot find the file specified", "No such file or directory" | wrong name, or you are in a different folder from the one you think |
| "Access is denied", "Permission denied" | you are not allowed to do that to that file |
| nothing happens and the prompt does not return | the command is waiting or still working: press Ctrl + C |
Staying safe
The command line does exactly what it is told, at once, and mostly without asking. Four habits prevent nearly every accident.
- Know where you are before a command that changes anything. Look at the prompt, or run
cdon Windows andpwdelsewhere. - Look before you delete. List the files with the same pattern first.
- Do not paste commands you do not understand. Read our page on dangerous commands to see why.
- Practise on copies, in your practice folder.
Which command line?
Windows has two: the older Command Prompt, and PowerShell, which is more capable. The Windows pages on this site use the Command Prompt, since its commands are the ones most often quoted in instructions. The guide to PowerShell shows how they correspond. The Mac and Linux share almost all their commands, so one set of pages serves both.
Where to go next
Work through the pages in this order: listing files, moving between folders, copying and moving, reading text files, searching. By then the command line will feel like a tool and not a test.
Examples shown with output were run on 12 November 2026 in a practice folder: Windows commands in cmd.exe on Windows 11, Linux commands with the GNU tools of Git Bash. The folder path and user name were replaced with made-up ones. Commands marked "not run here" are shown as you would type them.
This is an independent learning site. It is not connected with Microsoft, Apple or any Linux distribution. Windows, macOS and other names belong to their owners. Try commands first in a practice folder, never on files you cannot afford to lose.