Master these core commands for efficient filesystem navigation:
# List contents with details
ls -la
# Find files recursively
find ~/Projects -name "*.swift" -type f
# Quick directory jumps
cd - # toggle between last two dirs
pushd /path/to/project
popd
Powerful commands for controlling processes:
# List all processes with full details
ps aux
# Kill process by name
pkill -f "node server.js"
# Continuous monitoring
top
htop # requires brew install htop
# Continuous ping
ping -i 5 example.com
# Display network routes
netstat -nr
# Quick port check
nc -zv localhost 8080
# Detailed HTTP inspection
curl -v -X GET https://api.example.com/users
The unofficial macOS package manager:
# Install development tools
brew install node@16 python@3.9
# List installed packages
brew list --formula
# Upgrade all packages
brew upgrade
# Search through codebase
grep -r "import SwiftUI" ~/Projects/
# Count lines in all Swift files
find . -name "*.swift" | xargs wc -l
# Real-time log monitoring
tail -f /var/log/system.log
# Show macOS version
sw_vers
# List hardware overview
system_profiler SPHardwareDataType
# Check disk space
df -h
# Create secure temp password
openssl rand -base64 12
# SSH config management
cat ~/.ssh/config
# Quick Base64 encoding
echo "developers love cli" | base64
#!/bin/zsh
# Simple build script
xcodebuild clean build \
-project MyApp.xcodeproj \
-scheme MyApp \
-configuration Release
Mac OS X's UNIX foundation provides powerful terminal commands familiar to Linux users:
# List directory contents with details
ls -la
# Change directory with path autocompletion
cd ~/Documents/Projects/
# Show current working directory
pwd
# Search for files recursively
find /path/to/search -name "*.py"
Essential networking commands for troubleshooting and debugging:
# Check network connectivity
ping google.com
# Display network configuration
ifconfig
# Show active network connections
netstat -an
# DNS lookup with detailed output
dig example.com +trace
The unofficial package manager for macOS:
# Install Homebrew
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
# Search for packages
brew search python
# Install packages
brew install node@14
# List installed packages
brew list
Monitor and control running processes:
# List all running processes
ps aux
# Find and kill process by name
pgrep -i "chrome" | xargs kill
# Monitor system resources in real-time
top
Powerful commands for file manipulation:
# Search text in files recursively
grep -r "functionName" .
# Compare two files
diff file1.txt file2.txt
# Count lines in file
wc -l script.py
# Archive and compress files
tar -czvf archive.tar.gz /path/to/folder
Commands particularly useful for programming tasks:
# Check Python version
python --version
# Run JavaScript file
node script.js
# Initialize Git repository
git init
# Build Xcode project from command line
xcodebuild -scheme MyApp -workspace MyApp.xcworkspace
Retrieve detailed system information:
# Show macOS version
sw_vers
# Display CPU architecture
uname -m
# List all hardware overview
system_profiler SPHardwareDataType
# Check disk usage
df -h
Combine commands for powerful automation:
#!/bin/bash
# Backup script example
backup_dir="/path/to/backup"
timestamp=$(date +"%Y%m%d_%H%M%S")
tar -czf "${backup_dir}/backup_${timestamp}.tar.gz" "/path/to/source"
echo "Backup completed: backup_${timestamp}.tar.gz"
Important commands for security-conscious developers:
# Change file permissions recursively
chmod -R 755 /path/to/directory
# Change file ownership
chown username:groupname file.txt
# Verify file checksum
shasum -a 256 file.iso
# Check for open ports
nmap localhost