Mac Book Setup

From bibbleWiki
Jump to navigation Jump to search

MacBook Survival Guide for Linux/Windows Engineers

A practical cheat sheet for staying productive on macOS while keeping your Ubuntu/Windows muscle memory intact.

Modifier Keys: The Only Thing That Matters

macOS uses different modifier keys:

⌘ Command → Your new Ctrl

⌥ Option → Your new Alt

⌃ Control → Rarely used (right‑click)

⇧ Shift → Same as everywhere

Common shortcuts

Copy: ⌘C

Paste: ⌘V

Find: ⌘F

Close tab: ⌘W

Switch apps: ⌘Tab

Switch windows of same app: `⌘\`` (backtick)

Make macOS Feel Like Ubuntu

Terminal Install iTerm2 and core CLI tools:

brew install --cask iterm2
brew install git tmux ripgrep fd fzf wget curl
Optional shell upgrades:
brew install starship
brew install zsh-autosuggestions zsh-syntax-highlighting
Enable Starship:
eval "$(starship init zsh)"

Window Management (Windows‑Style Snapping)

Install Rectangle:

brew install --cask rectangle

Useful shortcuts:

Left half: ⌥⌘←

Right half: ⌥⌘→

Maximise: ⌥⌘↑

Make macOS behave more like Windows Alt‑Tab

If you want true Alt‑Tab behaviour (all windows, all apps), install:

brew install --cask alt-tab

Essential Developer Tools

Homebrew (package manager) Install:

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

Languages & Tools

brew install node python go ruby
brew install docker docker-compose
brew install kubectl k9s
brew install --cask visual-studio-code

Kubernetes Tools

brew install kubectx
brew install helm
brew install minikube

Homebrew Package Management

List installed packages

brew list
brew list --cask

Search for a package

brew search <name>

Show available versions

brew info <package>

This displays:

Installed version

Latest version

Dependencies

Whether it’s a cask or formula

The tap it comes from

Upgrade everything

brew update
brew upgrade

Remove a package

brew uninstall <package>

Clean old versions

brew cleanup

Homebrew Repository (Tap) Management

Homebrew supports additional repositories (“taps”).

List taps

brew tap

Add a tap

brew tap <user/repo>

Example:

brew tap homebrew/cask-fonts

Remove a tap

brew untap <user/repo>

Samsung Fold + Mac: Hands‑Free Integration

macOS doesn’t have Phone Link, but these work well:

Intel Unison (best overall)

brew install --cask intel-unison

Features:

Notifications

Calls

SMS

File transfer

Photos

KDE Connect (Linux‑style integration) Code

brew install --cask kdeconnect

Install KDE Connect on your Samsung Fold too.

Google Messages for Web For SMS only:

https://messages.google.com/web

Music Player (Phone + USB Workflow)

VLC (best all‑rounder)

brew install --cask vlc

Handles:

USB drives

Local files

Network streams

No iTunes lock‑in

USB Drive Support macOS supports:

exFAT

FAT32

NTFS (read‑only)

For NTFS write support:

brew install ntfs-3g

Phone → Mac audio Bluetooth

USB‑C audio (Fold supports it)

Smart Switch mode for file transfer

Optional: Make the Keyboard Feel Like Linux

Swap Caps Lock → Ctrl System Settings → Keyboard → Modifier Keys

Full remapping with Karabiner‑Elements

brew install --cask karabiner-elements

System Monitoring on macOS

macOS is UNIX under the hood, so most Linux commands work the same. A few tools have BSD‑style differences, but nothing that will trip you up.

Memory Usage

top

Sort by memory:

top -o mem

Sort by CPU:

top -o cpu

htop

Install:

brew install htop

Run:

htop

vm_stat

macOS‑specific memory stats:

vm_stat

Logging on macOS

macOS uses the unified logging system, plus classic BSD logs.

Unified Logging

Show recent errors:

log show --predicate 'eventMessage contains "error"' --last 1h

Live tail:

log stream

Filter by process:

log stream --process Safari

Classic Logs

Located in:

Code /var/log/ Tail system log:

sudo tail -f /var/log/system.log

Network Debugging

ifconfig

ifconfig

netstat

netstat -an | grep LISTEN

lsof (best for port usage)

List all listening ports:

sudo lsof -iTCP -sTCP:LISTEN -n -P

Find what is using a specific port:

sudo lsof -i :8080

nc (netcat)

Test connectivity:

nc -vz 192.168.1.10 5432

ping / traceroute

ping google.com
traceroute google.com

Install mtr:

brew install mtr

Firewall Testing

macOS uses an application firewall.

Check firewall status

sudo /usr/libexec/ApplicationFirewall/socketfilterfw --getglobalstate

List allowed/blocked apps

sudo /usr/libexec/ApplicationFirewall/socketfilterfw --listapps

Test inbound ports

From another machine:

nc -vz <mac-ip> 22

From the Mac:

sudo lsof -iTCP -sTCP:LISTEN -n -P

Port Usage

List all listening ports:

sudo lsof -iTCP -sTCP:LISTEN -n -P

netstat alternative:

netstat -an | grep LISTEN

Find what is using a specific port:

sudo lsof -i :3000

Packet Capture

tcpdump (built‑in)

Capture HTTPS traffic:

sudo tcpdump -i en0 port 443

Write to file:

sudo tcpdump -i en0 -w capture.pcap

Wireshark

Install:

brew install --cask wireshark

Getting Your IP Address

macOS

All interfaces (like ifconfig -a)

ifconfig

Clean, Linux‑style output Install iproute2mac:

brew install iproute2mac

Then:

ip addr

Just your primary IP

ipconfig getifaddr en0

(Use en1 if on Ethernet.)

Getting Your Current DNS Settings

macOS

The modern way (per‑interface DNS)

scutil --dns

This shows:

DNS servers

Search domains

Resolver order

mDNS / multicast DNS

The simple way

networksetup -getdnsservers Wi-Fi

Or for Ethernet:

networksetup -getdnsservers "Ethernet"

The Only Commands You Need for Ports, PIDs, Services, Logs

This is written so you can paste it straight into your wiki.

a) Check if a port is open

Test from the same machine (local)

sudo lsof -i :PORT

Example:

sudo lsof -i :3000

If nothing prints → nothing is listening.

Test from another machine Using nc (best)

nc -vz <ip> <port>

Example:

nc -vz 192.168.1.50 5432

Using telnet (old but works)

telnet <ip> <port>

b) Get PID for a port

This is the one you’ll use constantly.

sudo lsof -i :PORT

Example:

sudo lsof -i :5173

Output includes:

PID

Process name

User

Then kill it:

kill -9 <pid>

c) List services

macOS (launchd) List all services:

brew services list

System services:

launchctl list

Linux (systemd)

systemctl list-units --type=service

d) Restart a service

macOS (Homebrew services)

brew services restart <service>

Example:

brew services restart postgresql

Linux (systemd)

sudo systemctl restart <service>

e) Get / tail logs for a service

macOS unified logs Live stream:

log stream --process <name>

Example:

log stream --process nginx

macOS classic logs

sudo tail -f /var/log/system.log

Linux systemd logs

journalctl -u <service> -f

Example:

journalctl -u nginx -f

Bonus: The 5‑Command Mental Model

You only need to remember these:

1. Check port

sudo lsof -i :PORT

2. Test port from outside

nc -vz ip port

3. Kill process

kill -9 PID

4. Restart service

brew services restart name     # macOS
systemctl restart name         # Linux

5. Tail logs

log stream --process name      # macOS
journalctl -u name -f          # Linux

That’s it. You never need to remember netstat -tulnp again.

The Final “Oh Yeah, That’s Handy” Bits

Just a few more that often come up in real‑world dev work.

1. Flush DNS (macOS) Sometimes local dev + DNS caching = pain.

sudo dscacheutil -flushcache
sudo killall -HUP mDNSResponder

Equivalent to systemd-resolve --flush-caches.

2. Quick HTTP server (Python) Same as Linux:

python3 -m http.server 8000

3. Quick file sharing (macOS → Linux/Windows)

python3 -m http.server

Or AirDrop if it’s Mac ↔ Mac.

4. Check open files (macOS/Linux)

lsof | wc -l

Useful when something hits ulimit.

5. Increase file descriptor limit (macOS) macOS defaults are low.

ulimit -n 65536

Permanent changes require editing plist files, but for dev work this is enough.

6. Quick process tree (Linux‑style) macOS doesn’t have pstree by default.

Install:

brew install pstree

Run:

pstree -p

7. Open a file/folder from terminal (macOS‑only) This one is weirdly useful:

open .

Or open a file in its default app:

open myfile.pdf

Or open in VS Code:

code .

8. macOS has no watch — install it

brew install watch

Then:

watch -n 1 "lsof -i :3000"

9. Quick clipboard access Copy to clipboard:

echo "hello" | pbcopy

Paste from clipboard:

pbpaste

Equivalent to xclip on Linux.

10. macOS has built‑in curl + openssl + ssh Everything you expect works:

curl -I https://example.com
openssl s_client -connect example.com:443
ssh user@host

No surprises.