← Back to Tutorials

Beginner’s Guide: Getting Started (Step-by-Step)

beginner guidegetting startedbasicsstep by stephow to

Beginner’s Guide: Getting Started (Step-by-Step)

This tutorial is a practical, step-by-step “getting started” guide for people who are new to working in a command line environment and want to build a solid foundation. You’ll learn what the terminal is, how to navigate your computer using commands, how to create and edit files safely, how to install tools, and how to start a simple project with version control (Git). All examples include real commands you can run.


Table of Contents

  1. What You’ll Learn
  2. Prerequisites and Setup
  3. Step 1 — Open a Terminal
  4. Step 2 — Understand Where You Are (pwd, ls)
  5. Step 3 — Move Around (cd)
  6. Step 4 — Create Folders and Files (mkdir, touch)
  7. Step 5 — View and Read Files (cat, less, head, tail)
  8. Step 6 — Copy, Move, Rename, Delete (cp, mv, rm)
  9. Step 7 — Search and Filter Output (grep, find, pipes)
  10. Step 8 — Understand Permissions (chmod, chown basics)
  11. Step 9 — Install Tools (macOS, Linux, Windows)
  12. Step 10 — Start a Project Folder
  13. Step 11 — Git Basics (init, add, commit, status, log)
  14. Step 12 — Create and Run a Tiny Program
  15. Step 13 — Troubleshooting and Safety Tips
  16. Next Steps

What You’ll Learn

By the end, you should be able to:

This guide focuses on commands that work on macOS and Linux (Bash/Zsh) and also provides Windows options (PowerShell and/or WSL). If you’re on Windows and want the most Linux-like experience, consider using WSL (Windows Subsystem for Linux).


Prerequisites and Setup

You’ll need:

A note about “shells”

A shell is the program that reads your commands and runs them. Common shells include:

Most commands below target Bash/Zsh. When Windows differs, you’ll see alternatives.


Step 1 — Open a Terminal

macOS

Linux

Windows

Option A (recommended for Linux-like commands): WSL

  1. Install WSL (run in PowerShell as Administrator):
    wsl --install
  2. Reboot if prompted.
  3. Open “Ubuntu” (or your installed distro) from the Start menu.

Option B: Use PowerShell (commands differ from Linux/macOS for some tasks).


Step 2 — Understand Where You Are (pwd, ls)

When you open a terminal, you’re “in” a directory (folder). You need two core commands:

Run:

pwd

Example output:

/Users/alex

Now list files:

ls

You might see:

Desktop Documents Downloads Pictures

Useful ls options

Try:

ls -la

You’ll likely see entries like .zshrc or .bash_profile. Files beginning with . are hidden by default because they’re usually configuration files.

Concept: Paths (absolute vs relative)

Understanding paths is essential for not getting lost.


Step 3 — Move Around (cd)

cd means change directory.

Go into Documents:

cd Documents

Confirm:

pwd

Go back up one level:

cd ..

.. means “parent directory”.

Go to your home directory from anywhere:

cd ~

~ is a shortcut for your home folder (like /Users/alex).

Go to the previous directory:

cd -

This toggles between your current and last directory—very handy.

Tip: Use Tab completion

Start typing a folder name and press Tab:

cd Doc<Tab>

The shell will auto-complete if there’s a unique match. This reduces typing and prevents mistakes.


Step 4 — Create Folders and Files (mkdir, touch)

Create a new folder for practice:

cd ~
mkdir cli-practice
cd cli-practice

Create nested folders:

mkdir -p projects/demo

Create an empty file:

touch notes.txt

List to confirm:

ls -l

Write text into a file (redirects)

You can write text using output redirection:

echo "Hello, terminal!" > notes.txt

Append a second line:

echo "This is my second line." >> notes.txt

Step 5 — View and Read Files (cat, less, head, tail)

cat (quick display)

cat notes.txt

Good for small files.

less (scrollable viewer)

less notes.txt

In less:

head and tail

Show the first 10 lines:

head notes.txt

Show the last 10 lines:

tail notes.txt

Follow a file as it grows (common for logs):

tail -f notes.txt

Press Ctrl + C to stop following.


Step 6 — Copy, Move, Rename, Delete (cp, mv, rm)

These commands are powerful. Be careful—especially with deletion.

Copy a file: cp

cp notes.txt notes-copy.txt

Copy a folder recursively:

cp -r projects projects-backup

Move or rename: mv

Rename a file:

mv notes-copy.txt notes-renamed.txt

Move a file into a folder:

mkdir archive
mv notes-renamed.txt archive/

Delete: rm

Delete a file:

rm archive/notes-renamed.txt

Delete an empty folder:

rmdir archive

Delete a folder and everything inside:

rm -r projects-backup

Important safety note: rm does not move items to the trash by default. It removes them immediately.

Safer deletion habit

Before deleting many files, list what you’re about to delete:

ls projects-backup

Or use interactive mode:

rm -ri projects-backup

Step 7 — Search and Filter Output (grep, find, pipes)

Searching is where the command line becomes extremely efficient.

Search inside files with grep

Add more content:

echo "error: something went wrong" >> notes.txt
echo "info: all good" >> notes.txt

Search for “error”:

grep "error" notes.txt

Case-insensitive search:

grep -i "ERROR" notes.txt

Show line numbers:

grep -n "info" notes.txt

Pipes: connect commands with |

A pipe takes the output of the left command and feeds it into the right command.

List files and filter for .txt:

ls -la | grep "\.txt"

Find files by name with find

From your cli-practice directory:

find . -name "notes.txt"

Find all .txt files:

find . -name "*.txt"

Find files modified in the last day (Linux/macOS):

find . -mtime -1

Combine find + grep (search text across many files)

Search for “error” in all .txt files:

find . -name "*.txt" -print0 | xargs -0 grep -n "error"

Explanation:


Step 8 — Understand Permissions (chmod, chown basics)

On Unix-like systems (macOS/Linux), every file has permissions:

Run:

ls -l

You might see something like:

-rw-r--r--  1 alex  staff  85 Mar 21 10:00 notes.txt

The first part -rw-r--r-- means:

Make a script executable: chmod

Create a simple script:

cat > hello.sh <<'EOF'
#!/usr/bin/env bash
echo "Hello from a script!"
EOF

Try running it:

./hello.sh

You may get “Permission denied” because it’s not executable yet. Fix:

chmod +x hello.sh

Now run again:

./hello.sh

Numeric chmod (common in tutorials)

Example:

chmod 755 hello.sh

Ownership (basic idea)

chown changes owner (often requires admin privileges). Example (Linux):

sudo chown youruser:youruser somefile

If you don’t understand why you need chown, don’t use it yet—incorrect ownership changes can create confusing permission problems.


Step 9 — Install Tools (macOS, Linux, Windows)

Installing tools is a key part of getting started. Below are common approaches.

macOS: Homebrew

Install Homebrew (package manager):

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Then install packages, e.g. Git:

brew install git

Verify:

git --version

Linux: apt (Debian/Ubuntu)

Update package lists:

sudo apt update

Install Git and curl:

sudo apt install -y git curl

Verify:

git --version
curl --version

Linux: dnf (Fedora)

sudo dnf install -y git curl

Windows: winget (PowerShell)

Install Git:

winget install --id Git.Git -e

Verify:

git --version

Windows: WSL package install

Inside WSL (Ubuntu):

sudo apt update
sudo apt install -y git
git --version

Step 10 — Start a Project Folder

A good project structure prevents confusion later. Create a new project directory:

cd ~
mkdir -p projects/first-project
cd projects/first-project

Create a few standard files:

touch README.md .gitignore
mkdir src

Write a README:

cat > README.md <<'EOF'
# First Project

This is my first command-line project.

## Goals
- Practice terminal commands
- Learn Git basics
- Run a small script
EOF

Add a .gitignore to avoid committing junk files:

cat > .gitignore <<'EOF'
# OS files
.DS_Store

# Editor folders
.vscode/
.idea/

# Logs
*.log
EOF

Step 11 — Git Basics (init, add, commit, status, log)

Git tracks changes to files over time. Think of it as a “history system” for your project.

Configure Git identity (do once)

git config --global user.name "Your Name"
git config --global user.email "you@example.com"

Check settings:

git config --global --list

Initialize a repository

Inside your project folder:

git init

Check status:

git status

You’ll see untracked files like README.md.

Stage files (prepare a commit)

git add README.md .gitignore

Check status again:

git status

Commit changes

git commit -m "Initial commit with README and gitignore"

View history:

git log --oneline

Common Git mental model

This extra “staging” step is why Git can be precise about what goes into each commit.


Step 12 — Create and Run a Tiny Program

You can do this with several languages. Below are two common options: Bash and Python. Choose one (or try both).

Option A: Bash script

Create a script in src:

cat > src/run.sh <<'EOF'
#!/usr/bin/env bash
set -euo pipefail

name="${1:-world}"
echo "Hello, ${name}!"
EOF

Make it executable:

chmod +x src/run.sh

Run it:

./src/run.sh

Run with an argument:

./src/run.sh Alice

Explanation:

Commit it:

git add src/run.sh
git commit -m "Add a simple runnable script"

Option B: Python script

Check Python:

python3 --version

Create a Python file:

cat > src/app.py <<'EOF'
import sys

def main():
    name = sys.argv[1] if len(sys.argv) > 1 else "world"
    print(f"Hello, {name}!")

if __name__ == "__main__":
    main()
EOF

Run it:

python3 src/app.py
python3 src/app.py Alice

Commit it:

git add src/app.py
git commit -m "Add a tiny Python app"

Step 13 — Troubleshooting and Safety Tips

1) “Command not found”

If you run something like:

git --version

…and get command not found, it means:

Fix by installing via your package manager (Homebrew/apt/winget) and reopening the terminal.

2) Spaces in file names

If you create a file like My Notes.txt, commands may treat it as two arguments. Use quotes:

touch "My Notes.txt"
ls -l "My Notes.txt"

Or escape spaces:

ls -l My\ Notes.txt

3) Permission denied

If you see:

4) Be careful with sudo

sudo runs commands as an administrator. This is sometimes necessary (installing packages, changing system files), but it also makes it easier to damage your system if you run the wrong command.

A good habit: if you don’t understand what a command does, don’t run it with sudo.

5) Learn to read help pages

Most commands have built-in help:

ls --help

Or manual pages:

man ls

In man:

6) Use echo to test expansions

If you’re unsure what a wildcard will match, test it:

echo *.txt

This prints what *.txt expands to before you run something destructive like rm.

7) Understand wildcards

Example:

ls *.md

Lists all Markdown files in the current directory.


Next Steps

Once you’re comfortable with the basics above, here are practical directions to continue:

  1. Learn a text editor
    • Terminal-based: nano, vim
    • GUI: VS Code
  2. Practice Git workflows
    • Branching: git branch, git switch -c feature-x
    • Merging: git merge
  3. Learn environment basics
    • PATH, shell profiles (~/.bashrc, ~/.zshrc)
  4. Try a real project
    • Create a small CLI tool
    • Write a script that organizes files
    • Build a simple web server (Python http.server, Node.js, etc.)

A simple branching exercise (optional)

Inside your project:

git switch -c add-usage

Edit README.md to add usage instructions (use cat >> to append):

cat >> README.md <<'EOF'

## Usage

### Bash
./src/run.sh Alice

### Python
python3 src/app.py Alice
EOF

Commit:

git add README.md
git commit -m "Document usage examples"

Merge back to main (your default branch might be master or main):

git switch main
git merge add-usage

View log:

git log --oneline --graph --decorate

Summary Checklist

You can now:

If you tell me your operating system (macOS/Linux/Windows) and what you want to build (scripts, web apps, data analysis, etc.), I can suggest a focused “next tutorial” with the exact tools and commands to install.