Here are some essential macOS commands for troubleshooting various issues. These commands can be executed in the Terminal, which you can open by searching for "Terminal" in Spotlight or navigating to Applications > Utilities > Terminal.
1. Check Disk Status
diskutil list
: Lists all disks and partitions.diskutil verifyDisk /dev/diskX
: Verifies the disk's integrity (replaceX
with the appropriate disk number fromdiskutil list
).diskutil repairDisk /dev/diskX
: Repairs disk issues.
2. Repair Disk Permissions
diskutil repairPermissions /
: Repairs the disk permissions of the startup disk.
3. Check System Logs
log show --predicate 'eventMessage contains "error"' --info
: Shows logs containing errors.tail -f /var/log/system.log
: Continuously monitors the system log for new entries.
4. Network Troubleshooting
ping www.example.com
: Tests connectivity to a website.ifconfig
: Displays network interface information.networksetup -listallhardwareports
: Lists all network hardware ports.networksetup -setdnsservers Wi-Fi 8.8.8.8
: Sets the DNS server for the Wi-Fi interface to Google’s DNS (8.8.8.8).
5. System Performance
top
: Displays real-time system processes and performance.ps -ax
: Lists all running processes.sudo killall processname
: Force quits a specific process (replaceprocessname
with the actual name).
6. Safe Mode
sudo nvram boot-args="-x"
: Enables Safe Mode.sudo nvram boot-args=""
: Disables Safe Mode.
7. Clear Caches
sudo rm -rf ~/Library/Caches/*
: Clears user cache.sudo rm -rf /Library/Caches/*
: Clears system cache.
8. Manage Startup Items
sudo defaults read /Library/Preferences/com.apple.loginwindow AutoLaunchedApplicationDictionary
: Lists all startup items.sudo defaults delete /Library/Preferences/com.apple.loginwindow AutoLaunchedApplicationDictionary
: Deletes a specific startup item.
9. Reset NVRAM/PRAM
sudo nvram -c
: Clears NVRAM.sudo nvram boot-args="reset"
: Resets PRAM.
10. Reset SMC
- For MacBooks with non-removable batteries:
- Shut down your Mac.
- Press and hold Shift + Control + Option on the left side and the power button simultaneously.
- Hold for 10 seconds, then release.
- Turn on your Mac.
11. Kill Unresponsive Applications
killall -9 Finder
: Force restarts Finder.killall -9 Dock
: Force restarts the Dock.
12. Backup Management
tmutil listbackups
: Lists all Time Machine backups.tmutil delete /Path/To/Backup
: Deletes a specific Time Machine backup.
13. System Information
system_profiler SPSoftwareDataType
: Displays detailed system information.
14. Memory Usage
vm_stat
: Displays virtual memory statistics.sudo purge
: Frees up inactive memory.
15. Update macOS
softwareupdate -l
: Lists all available software updates.softwareupdate -i "update-name"
: Installs a specific update (replace"update-name"
with the actual update name).
16. Force Restart
sudo shutdown -r now
: Forces an immediate restart.
17. Check System Integrity Protection (SIP) Status
csrutil status
: Checks if SIP is enabled or disabled.csrutil enable
orcsrutil disable
: Enables or disables SIP (requires reboot in recovery mode).
18. Flush DNS Cache
sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder
: Flushes DNS cache (works in macOS Mojave and later).
Using these commands can help you diagnose and fix common issues on your Mac. Be cautious when using commands with sudo
, as they can significantly alter system behavior.
0 Comments