macOS Terminal

Essential commands for developers

File Management

Navigate & List Files

ls

List files in current directory

ls -la

List all files with details

cd /Users/YourName/Documents

Change to specific directory

cd ..

Go up one directory

pwd

Show current directory path

Copy, Move & Delete

cp file.txt backup.txt

Copy a file

cp -r folder backup_folder

Copy entire folder

mv file.txt /Users/YourName/Desktop/

Move file to another location

rm file.txt

Delete a file

rm -rf folder

Delete folder and contents (use carefully!)

Network Commands

IP Configuration

ifconfig

Show network configuration

ifconfig en0

Show specific interface (WiFi)

Test Connectivity

ping google.com

Test connection to website

ping -c 5 192.168.1.1

Ping 5 times to local device

Development Tools

Python Web Server

python3 -m http.server 8000

Start a simple web server on port 8000

Access at: http://localhost:8000

Archive Files (TAR)

tar -czf archive.tar.gz folder/

Create compressed archive

tar -xzf archive.tar.gz

Extract compressed archive

tar -tf archive.tar.gz

List contents of archive

Secure Copy (SCP)

scp file.txt user@server:/path/to/destination

Copy file to remote server

scp user@server:/path/file.txt .

Copy file from remote server to current directory

scp -r folder user@server:/path/

Copy entire folder to remote server

Git Version Control

Basic Git Workflow

git init

Initialize a new repository

git clone https://github.com/user/repo.git

Clone a repository

git status

Check current status

git add .

Stage all changes

git commit -m "Your message"

Commit changes

git push

Push to remote repository

git pull

Pull latest changes

Branch Management

git branch

List branches

git branch dev

Create dev branch

git checkout dev

Switch to dev branch

git checkout -b feature-branch

Create and switch to new branch

git merge dev

Merge dev into current branch

Common Dev/Prod Workflow

git checkout dev

Switch to development branch

git pull origin dev

Get latest dev changes

git checkout -b feature-xyz

Create feature branch from dev

# Make your changes, then:
git add .
git commit -m "Add feature XYZ"
git push -u origin feature-xyz

Push feature branch

# After review, merge to dev:
git checkout dev
git merge feature-xyz
git push origin dev

Merge feature into dev

# Deploy to production:
git checkout prod
git merge dev
git push origin prod

Merge dev into production

Stash & Rebase

git stash

Save changes temporarily

git stash pop

Apply stashed changes

git stash list

List all stashes

git rebase main

Rebase current branch onto main

git rebase -i HEAD~3

Interactive rebase last 3 commits

Worktrees (Multiple Working Directories)

git worktree add ../project-dev dev

Create worktree for dev branch

git worktree add ../project-prod prod

Create worktree for prod branch

git worktree list

List all worktrees

git worktree remove ../project-dev

Remove a worktree

Other Useful Commands

Search & Find

grep "text" file.txt

Search for text in file

grep -r "text" .

Search recursively in all files

find . -name "*.txt"

Find all .txt files

which python3

Find location of executable

Data Transfer

curl https://api.github.com/users/username

GET request to API

curl -o file.zip https://example.com/file.zip

Download file

References & Citations