how to logoff, restart, and shutdown macOS systems<\/a>.<\/p>\n\n\n\n6. Get and Manage System Information<\/h3>\n\n\n\n
Executing the system_profiler<\/kbd> command via the Terminal will provide detailed information about the hardware, software, and network settings of your Mac. It\u2019s a great tool for gathering system information quickly.<\/p>\n\n\n\n\n- To display detailed hardware information:
system_profiler SPHardwareDataType<\/code><\/li>\n\n\n\n- To display software-related details:
system_profiler SPSoftwareDataType<\/code><\/li>\n<\/ul>\n\n\n\nThe top<\/kbd> command displays a real-time summary of system processes, including CPU, memory, and disk usage. This command is useful for monitoring system performance.<\/p>\n\n\n\n\n- To view a live process list:
top<\/code><\/li>\n\n\n\n- To sort the processes by CPU usage:
top -o cpu<\/code><\/li>\n<\/ul>\n\n\n\n7. View Networking and Connectivity Information<\/h3>\n\n\n\n
The ifconfig<\/kbd> command is used to display or configure network interfaces on your Mac. It provides detailed information about network interfaces, IP addresses, and their statuses.<\/p>\n\n\n\n\n- To display all network interfaces:
ifconfig<\/code><\/li>\n\n\n\n- To configure a network interface (e.g., enabling\/disabling):
sudo ifconfig en0 up<\/code><\/li>\n<\/ul>\n\n\n\nThe ping<\/kbd> command checks network connectivity by sending packets to a specified remote host and measuring the round-trip time. It\u2019s useful for diagnosing network connectivity issues.<\/p>\n\n\n\n\n- To ping a remote host (e.g., Google):
ping google.com<\/code><\/li>\n<\/ul>\n\n\n\nThe netstat<\/kbd> command displays network connections, routing tables, interface statistics, and other network-related information. It\u2019s useful for monitoring network activity.<\/p>\n\n\n\n\n- To view all active network connections:
netstat<\/code><\/li>\n\n\n\n- To display routing tables:
netstat -r<\/code><\/li>\n<\/ul>\n\n\n\nThe command ipconfig getifaddr en0<\/kbd> retrieves the IP address of a specific network interface (in this case, en0<\/kbd>, typically the primary Ethernet or Wi-Fi interface).<\/p>\n\n\n\n\n- To get the IP address of the en0 interface:
ipconfig getifaddr en0<\/code><\/li>\n<\/ul>\n\n\n\n8. Troubleshooting and Diagnostics<\/h3>\n\n\n\n
The log show<\/kbd> command displays detailed system logs, which are invaluable for diagnosing and debugging issues. You can filter the logs to find specific events or errors.<\/p>\n\n\n\n\n- To show all logs containing the word “error”:
log show –predicate ‘eventMessage contains “error”‘ –info<\/code><\/li>\n<\/ul>\n\n\n\nThe sudo killall<\/kbd> command terminates a running application or process by name. It\u2019s particularly useful when an application becomes unresponsive and needs to be force-quit.<\/p>\n\n\n\n\n- To terminate a specific process (replace process_name with the application or process name):
sudo killall process_name<\/code><\/li>\n<\/ul>\n\n\n\nThe traceroute<\/kbd> command is used for network diagnostics. It maps the route packets take to reach a destination, identifying any network bottlenecks or failures. This command can also be accessed via the Network Utility application.<\/p>\n\n\n\n\n- To trace the route to a website (e.g., Google):
traceroute google.com<\/code><\/li>\n<\/ul>\n\n\n\nThe sudo lsof<\/kbd> command lists open files and network connections, making it an excellent tool for network troubleshooting.<\/p>\n\n\n\n\n- To list all open network connections:
sudo lsof -i -n -P<\/code><\/li>\n<\/ul>\n\n\n\n9. Locate Files by Name or Type<\/h3>\n\n\n\n
The find<\/kbd> command is a versatile tool for locating files and directories based on various criteria such as name, date, or type. It\u2019s particularly useful for quickly pinpointing specific files within a directory structure.<\/p>\n\n\n\n\n- To find a file by name (e.g., “file.txt”) starting from the current directory:
find . -name “file.txt”<\/code><\/li>\n\n\n\n- To find files modified within the last 7 days:
find . -mtime -7<\/code><\/li>\n\n\n\n- To find all files of a specific type (e.g., .log files):
find . -type f -name “*.log”<\/code><\/li>\n<\/ul>\n\n\n\n10. Clear Terminal of All Commands<\/h3>\n\n\n\n
The clear<\/kbd> command removes all previously typed commands and output from the Terminal window, providing a clean workspace. It\u2019s especially helpful when working on long sessions to declutter your screen.<\/p>\n\n\n\n\n- To clear the Terminal:
clear<\/code><\/li>\n<\/ul>\n\n\n\nAlternatively, you can use the keyboard shortcut: Command + K<\/kbd><\/p>\n\n\n\n