IPv4 Client Connecting...
IP Address: Searching... (home)
Reverse DNS: -
Provider / ASN: -
IPv6 Client Connecting...
IP Address: Searching... (home)
Reverse DNS: -
Provider / ASN: -
Connection & Security HTTPS
SSL / TLS: Searching...
Protocol: HTTP/1.1
⬅ Back to Notes

macOS Initial Setup, CLI Tools & Dotfiles Cheatsheet

📅 Published: 2026-08-15
#macos #zsh #dotfiles #cli #security #productivity

Når en ny Mac tages i brug, sikrer denne bootstrap-guide en standardiseret, sikker og produktiv opsætning af terminal, værktøjer og shell-miljø.


1. Xcode Command Line Tools & Homebrew

Start med at installere Apples kommandolinjeværktøjer og package manageren Homebrew:

BASH
# 1. Installer Xcode CLI Tools
xcode-select --install

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

# 3. Tilføj Homebrew til PATH (Apple Silicon)
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.zprofile
eval "$(/opt/homebrew/bin/brew shellenv)"

2. Essentielle CLI- og Netværksværktøjer

Installer standardværktøjer til systemadministration, netværksanalyse og automatisering:

BASH
brew install \
  git \
  rsync \
  openssl \
  jq \
  wget \
  curl \
  mtr \
  nmap \
  iperf3 \
  tmux \
  python3 \
  pipx

# Klargør pipx til isolerede Python CLI værktøjer
pipx ensurepath

3. Password Generation & xkcdpass

Til hurtig generering af stærke kodeord og læsevenlige passphrases anvendes to værktøjer:

1. openssl: Til vilkårlige base64-kodede tokens og adgangskoder.
2. xkcdpass: Genererer huskbare passphrases bestående af ordbogsord adskilt af bindestreger (inspireret af XKCD #936 ↗).

Installer xkcdpass via pipx:

BASH
pipx install xkcdpass

4. Konfiguration af ~/.zshrc (Aliaser & Hjælpefunktioner)

Åbn din shell-konfiguration:

BASH
vi ~/.zshrc

Tilføj følgende sektioner til bunden af filen:

BASH
# ==========================================
# 🔐 Password & Token Generation
# ==========================================

# Generer tilfældigt 32-byte base64 password (f.eks. til API tokens og system passwords)
alias randpasswd='openssl rand -base64 32'

# Standard xkcdpass (4 tilfældige ord)
alias xp='xkcdpass'

# Generer 5 ord med acrostic og bindestreg (f.eks. c-h-a-o-s mønster)
alias xp5="xkcdpass --count=5 --acrostic='chaos' --delimiter='-' --min=5 --max=6 --valid-chars='[a-z]'"


# ==========================================
# 🔄 System Updates & Maintenance
# ==========================================

# Kør samlet systemopdatering (Homebrew, Mac App Store, pipx, VS Code, OS)
# Kræver klonet repo — se guide: [macOS All-In-One Update Guide](/?mode=notes&id=macos-all-in-one-update-guide)
alias update-all='~/CloudStation/Develop/fromGIT/macos-all-in-one-update-script/update-all.sh'


# ==========================================
# 🌐 Netværk & Diagnostics Shortcuts
# ==========================================

# Vis offentlig IPv4 og IPv6
alias myip="curl -s https://ipv4.ekg.dk/ip.php | jq -r .ip"
alias myip6="curl -s https://ipv6.ekg.dk/ip.php | jq -r .ip"

# Hurtig ping og DNS flush
alias flushdns="sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder; echo '✅ DNS Cache Flushed'"
alias pingg="ping 1.1.1.1"


# ==========================================
# 📁 Fil- og Mappe-navigation
# ==========================================
alias ll='ls -lahG'
alias ..='cd ..'
alias ...='cd ../..'
💡 Tip: > Læs den fulde opsætning og kloningsvejledning til update-all i guiden:
🔗 macOS All-In-One Update Script & Vedligeholdelses-workflow ↗

Genindlæs konfigurationen i din aktuelle terminal:

BASH
source ~/.zshrc


5. SSH Nøgler & Klientkonfiguration

Generer en moderne ED25519 nøgle (hurtigere og sikrere end RSA) samt en backup RSA 2048/4096-bit nøgle til ældre legacy hardware (f.eks. ældre Cisco IOS):

BASH
# Primær moderne nøgle
ssh-keygen -t ed25519 -C "workstation-main" -f ~/.ssh/id_ed25519

# Legacy nøgle til ældre netværksudstyr
ssh-keygen -t rsa -b 2048 -C "workstation-legacy" -f ~/.ssh/id_rsa

Konfigurer standard SSH-adfærd i ~/.ssh/config:

SSH-CONFIG
# Standard indstillinger for alle hosts
Host *
    AddKeysToAgent yes
    UseKeychain yes
    IdentityFile ~/.ssh/id_ed25519
    IdentityFile ~/.ssh/id_rsa
    ServerAliveInterval 60
    ServerAliveCountMax 3

6. Løbende Vedligeholdelse af Scripts

For at holde dine scripts og konfigurationer synkroniseret og dokumenteret:

1. Saml dine scripts: Gem dem i en dedikeret mappe, f.eks. ~/scripts/ eller dit repository.
2. Dokumentér nye aliaser: Opret en lille note under notes/ på denne portal, hver gang du laver et nyt nyttigt one-liner script.
3. Deployment: Brug ./push.sh til lynhurtigt at skubbe nye guides og scripts live.

Copied: