Computing and Networks
Command Line Basics for Beginners
Beginner · Skill · 6 min read · Updated October 30, 2026
Most of the time you give a computer instructions by clicking. You open a folder by double-clicking it and copy a file by dragging it. There is a second way to do the same work: typing short instructions into a text window. That window is the command line, and professionals in IT, development and security use it every day, because typing is often faster, repeatable and possible on machines that have no screen at all.
This entry is a hands-on introduction. It shows how to open a command line on each major system and how to practice three safe skills: finding out where you are, looking at what is there, and moving around. Every command used here only reads information or creates one empty practice folder. Nothing is deleted.
What the command line is
The command line is a way to control the computer by typing commands and reading the text that comes back. The window you type into is called a terminal. The program inside it that reads your typing and runs your commands is called a shell. People mix up these words, and in everyday talk they mean nearly the same thing.
A command is usually a short word, sometimes followed by details. Those details are called arguments when they say what to act on, and options (or flags) when they change how the command behaves. You press Enter to run it, and the shell prints a result or just returns to a new line.
Why bother when there are menus?
- Speed for repeated tasks. One typed line can replace many clicks.
- Precision. You can say exactly what you want.
- Automation. Commands can be saved in a file and run again, which is the base of scripting.
- Access to servers. Many servers and cloud machines have no desktop, only a command line.
The idea matters more than the tool. The skills you learn here carry across systems, even though the words differ a little. For the layers underneath, see what an operating system does.
Opening a terminal
| System | What to open | How |
|---|---|---|
| Windows | Command Prompt or PowerShell | Search the Start menu for "Command Prompt" or "PowerShell" |
| macOS | Terminal | Search with Spotlight for "Terminal" |
| Linux | Terminal | Look in the applications menu, or use the system's terminal shortcut, which varies |
Windows has two shells. Microsoft describes Command Prompt as the older one and PowerShell as a newer one that extends it. For the basic commands below, both work on Windows. PowerShell also runs on macOS and Linux, but the default shell there is a different one, and the commands in this entry work with it.
When the window opens, you see a prompt, a short piece of text that waits for you. It often shows your user name and your current folder. The exact shape differs, and it does not matter yet. You type after it.
Three first questions
The commands you will use most answer three questions: where am I, what is here, and how do I go somewhere else?
Where am I?
The place the shell is currently working in is called the working directory (a directory is a folder). Commands that use files act on this folder unless you say otherwise.
| System | Command to show the current folder |
|---|---|
| Windows Command Prompt | cd |
| Windows PowerShell | pwd |
| macOS and Linux | pwd |
pwd stands for "print working directory". It prints the full path of your current folder. If paths are new to you, files, folders and file systems explains them.
What is here?
| System | Command to list the contents |
|---|---|
| Windows Command Prompt | dir |
| Windows PowerShell | ls or dir |
| macOS and Linux | ls |
On macOS and Linux, ls -l lists the files with more details, such as sizes and dates, and ls -a also shows hidden items. Hidden items on those systems usually have names that start with a dot.
How do I move?
cd means "change directory". Put the folder's name after it:
cd Documents
Two shortcuts help you travel. Two dots stand for the folder one level above, and you can move up with cd ... On macOS, Linux and PowerShell, cd ~ takes you to your home folder.
If a folder name contains spaces, put quotation marks around it, for example cd "My Photos". Otherwise the shell reads the pieces as separate arguments.
A safe practice session
This short exercise creates one empty folder, moves into it and comes back. It is safe to run.
On macOS and Linux (or PowerShell):
pwd
ls
mkdir practice
cd practice
pwd
cd ..
ls
On Windows Command Prompt:
cd
dir
mkdir practice
cd practice
cd
cd ..
dir
What each step does:
- The first command shows where you are. On Linux the answer might look like
/home/sam, and on macOS like/Users/sam. - The listing shows the files and folders in that place.
mkdir practicemakes a new folder namedpractice. The name is short for "make directory".cd practicemoves you into it. The location command now shows a path ending inpractice.cd ..takes you back up, and the final listing now includespractice.
Notice that little or nothing appeared on screen after mkdir or cd. (PowerShell prints a short summary of the new folder.) Many commands print nothing when they succeed. Silence is normal and usually means "done".
Habits that save time
- Press Tab to complete names. Type the first letters of a file or folder and press Tab. The shell fills in the rest if it can. This saves typing and prevents spelling mistakes.
- Use the Up arrow. It brings back earlier commands, so you can repeat or fix one.
- Read the error message. Messages such as "No such file or directory" or "The system cannot find the path specified" often say exactly what is wrong, and the usual cause is a typo or the wrong folder.
- Ask for help. In Command Prompt,
help direxplains a command. On macOS and Linux,man lsopens its manual page, and you pressqto leave it.
Staying safe
The command line does what you tell it, immediately, and often without asking for confirmation. Some commands can delete or overwrite files without sending them to a recycle bin. This entry does not use any of those on purpose. As you learn more, follow a few rules:
- Do not paste a command from the internet unless you understand what each part does.
- Be careful with commands that start with a word like
sudoon macOS and Linux, or with "Run as administrator" on Windows. They grant extra power, and a mistake can affect the whole system. - Practice in a folder you created for learning, such as
practice, and keep backups of anything valuable.
Common mistakes
- Typing the command in the wrong place. If a file command says the file is missing, check your working directory first.
- Mixing up system words.
dirworks in Windows, andlsis the usual choice on macOS and Linux. PowerShell accepts both. - Forgetting spaces.
cd ..needs a space between the command and the two dots in most shells. - Ignoring uppercase and lowercase. Names on Linux treat
Photosandphotosas different folders. Windows and macOS usually do not, although macOS can be set up to. - Running commands you do not understand. If you cannot explain a line, do not run it on a machine you care about.
FAQ
Is the command line the same as the terminal?
They are closely related. The terminal is the window, the shell is the program that reads your commands, and "command line" describes the way of working. In daily conversation people use the words interchangeably.
Do I need to know the command line for an IT job?
It comes up often in support, system administration, development and security work. Basic comfort with it is useful in many roles, though how much you need depends on the job.
Can the command line break my computer?
Safe commands such as the ones here cannot. Some other commands change or remove things, so learn each command before you use it and practice in a spare folder.
What is the difference between Command Prompt and PowerShell?
Both are shells on Windows. PowerShell is the newer one and can do more, while Command Prompt is the older, simpler tool. Basic commands work in either.
What should I learn next?
Try creating files and folders, then read about networking tools such as the lookup command in what DNS is. More topics are in the Computing and Networks area.
Sources
- Windows commands (opens in a new tab) — Microsoft Learn. Reference for Command Prompt commands such as dir and cd
- What is PowerShell? (opens in a new tab) — Microsoft Learn
- Terminal User Guide for Mac (opens in a new tab) — Apple Support
- GNU Coreutils manual (opens in a new tab) — GNU Project (Free Software Foundation). Documents ls, pwd, mkdir and other standard commands on Linux and similar systems