Your First Commands
Table of Contents
- Your First Few Commands
- The Anatomy of a Command
- Options (Flags)
- Arguments
- Shortcuts That Save You Hours
- Getting Help
- Reading Error Messages
- Try It Yourself
1. Your First Few Commands
Open a terminal and try these, one at a time. Type each one and press Enter.
whoami
Prints your username.
date
Prints the current date and time:
Thu Oct 1 09:41:12 +07 2026
echo Hello, terminal
echo simply prints back whatever you give it:
Hello, terminal
That sounds useless, but you'll use echo constantly — to check the
value of a variable, to write a line into a file, or to print messages
from a script.
clear
Clears the screen. Your earlier commands aren't gone, they've just scrolled out of view.
Notice the rhythm: you type, press Enter, the command runs and prints something (or nothing), and the prompt comes back. When the prompt is back, the shell is ready for the next command.
2. The Anatomy of a Command
Almost every command you'll ever type follows the same shape:
command -options arguments
For example:
ls -l Documents
ls— the command: the name of the program to run ("list")-l— an option (also called a flag): changes how the command behaves ("use the long format")Documents— an argument: tells the command what to work on ("list this folder")
The parts are separated by spaces. That matters: ls -l and
ls-l are completely different — the second one looks for a program
literally called ls-l, which doesn't exist.
Commands are also case-sensitive. ls works; LS and Ls don't.
Almost all commands are lowercase.
3. Options (Flags)
Options switch features on and off. They come in two styles:
- Short options: a single dash and a single letter, like
-lor-a. - Long options: two dashes and a whole word, like
--versionor--help. Easier to read, longer to type.
Try them:
ls
ls -a
ls -l
-a shows all files, including hidden dotfiles. -l shows the
long format, with sizes, dates, and permissions.
Short options can be combined behind one dash. These two commands are identical:
ls -l -a
ls -la
And here's a long option you can try on any system:
bash --version
Some options need a value of their own. For example, head -n 5
means "show the first n lines, where n is 5". The value goes right
after the option. You'll use head in chapter 5.
4. Arguments
Arguments are the things a command works on — usually file or folder names. Some commands take none, some take one, some take many:
ls # no argument: list the current folder
ls Documents # one argument: list Documents
ls Documents Desktop # two arguments: list both
Everything after a # is a comment. The shell ignores it, so you
can copy those lines exactly as they are. We'll use comments in code
blocks to explain what each line does.
What if a file name contains a space, like My Photos? The shell splits
arguments on spaces, so ls My Photos means "list My, then list
Photos". To keep it as one argument, wrap it in quotes:
ls "My Photos"
This is why developers tend to name files my-photos instead of
My Photos. Chapter 4 covers this in more depth.
5. Shortcuts That Save You Hours
Experienced developers rarely type out long commands in full. These shortcuts are worth learning on day one:
| Key | What it does |
|---|---|
Tab | Autocomplete a command, file, or folder name |
Tab Tab | Show all possible completions when there's more than one |
↑ / ↓ | Scroll back and forth through commands you've already run |
Ctrl + C | Stop the running command, or cancel the line you're typing |
Ctrl + L | Clear the screen (same as clear) |
Ctrl + A / Ctrl + E | Jump to the start / end of the line |
Ctrl + R | Search your command history — start typing part of an old command |
The two you should use constantly:
Tab: type ls Doc and press Tab. The shell fills in
Documents/ for you. It's faster, and it can't make typos — if Tab
doesn't complete a name, it probably doesn't exist where you think it
does.
Ctrl + C: your emergency stop. If a command seems stuck, prints
forever, or you started something by mistake, press Ctrl + C and the
prompt comes back. You'll use it every time you stop a development
server with npm run dev.
To see everything you've typed recently:
history
Copy and paste: in most terminals,
Ctrl + Cmeans "stop", not "copy". UseCtrl + Shift + C/Ctrl + Shift + Von Linux and in Windows Terminal, and the usualCmd + C/Cmd + Von macOS. You can also right-click.
6. Getting Help
Nobody remembers every option of every command. What experienced developers do remember is how to look things up.
--help
Most commands print a short summary of their options when you pass
--help:
ls --help
On macOS, many of the built-in commands don't support --help and will
just print an error with a one-line usage hint. Use man instead.
man — the manual
Almost every command has a full manual page:
man ls
This opens the manual in a viewer that fills the screen. Use the arrow
keys or Space to scroll, type / followed by a word to search for it,
and press q to quit. That last one is important — beginners often
get stuck here, not knowing how to get out.
Manual pages are thorough but dry. Git Bash on Windows doesn't include
man at all; use --help there.
tldr — the short version
tldr.sh is a community project with short,
example-based pages for thousands of commands — often exactly what you
need. Look up tar on man and you'll get pages of options; look it up
on tldr and you'll get the five commands people actually use.
Search engines and AI assistants
Searching "how to rename a file in bash" works well. So do AI
assistants. Just follow the rule from chapter 1: understand a command
before you run it, especially one that deletes things or starts with
sudo.
7. Reading Error Messages
When something goes wrong, the shell tells you why — but beginners often skip right past the message. Read it. A few you'll see a lot:
zsh: command not found: lss
The shell couldn't find a program with that name. Usually a typo. If you just installed a tool and get this, chapter 9 explains why.
ls: Documnets: No such file or directory
The command worked, but the argument points at something that
doesn't exist. Check the spelling and which folder you're in — or use
Tab so it can't be wrong.
ls: invalid option -- 'z'
The command doesn't have that option. Check --help or man.
bash: ./setup.sh: Permission denied
The file exists, but you aren't allowed to do that with it. Chapter 10 covers permissions.
Notice the pattern: most error messages start with the name of the program that's complaining, followed by what it was trying to work on, then what went wrong. Read them left to right and they usually tell you exactly what to fix.
8. Try It Yourself
- Run
echowith your own name:echo Hello, Dara. Then run it again with your name in quotes. Is there a difference in the output? - Run
ls, thenls -a, thenls -lain your home folder. Which hidden files appear with-a? - Type
ls Dand pressTabtwice. What options does the shell suggest? - Press
↑a few times to bring back an earlier command, and run it again without retyping it. - Run
man ls, search for-aby typing/-aand pressing Enter, then pressqto quit. (On Git Bash, usels --helpinstead.) - Make a typo on purpose —
ls Documnets— and read the error message word by word.
You now know how to talk to the shell and how to look things up when you're stuck. Next, let's use that to move around the file system.
Buy Me a Coffee
Found this tutorial helpful? Consider buying me a coffee to support more free content!