What built-in utilities are available in macOS for managing/monitoring process/disk/memory/IO/file?
Solution 1:
There are a lot of tools, both in the graphical interface and at the command line, for viewing and configuring these various parts of macOS' operations. I'll give you a summary of the most relevant ones.
For viewing processes in the GUI, Activity Monitor is the primary tool. It can also view other per-process things like memory usage, and disk and network activity (and it also gives some overall stats at the bottom of the window). You can also view open files and network ports for processes you own by selecting them, and clicking the Inspect (circle-with-an-"i"-in-it) button in the toolbar, then selecting the Open Files and Ports tab. And it can kill (force-exit) running programs.
At the command line, top
is my favorite tool. I use top -u -s5
to show top CPU-using processes (updated every 5 seconds, because the default of 1 second is too fast). top -orsize
will show top "real memory" usage instead. And it shows overall stats at the top of the screen. ps
is the other main tool; by default, it only shows your command-line processes, so use ps -A
(or -ax
or -e
) to show all processes. Check the man page for lots more options. You can use kill
to kill processes by PID, or killall
to kill them by name (/program). (Warning: on some other OSes, killall
does different, and much more lethal, things, so think before you type.)
A lot of the process management in macOS (especially running background processes) is handled by launchd
, and you can query and manage it from the command line with launchctl
(warning: this can be a bit confusing). Apple doesn't provide a GUI for interacting with this, but there is a third-party option: LaunchControl from soma-zone.
For memory: since that's pretty much used by processes, use the process monitoring tools to see what's going on. You can get some whole-system virtual memory stats from vm_stat
(warning: these stats are in pages, not KB or MB or anything like that) or sysctl vm.swapusage
(or if you want to drink from the firehose, sysctl -a vm
). Memory management is thoroughly automated, so there aren't really any tools to configure it.
For disks: Disk Utility is the GUI tool of choice, both to see how things are formatted and to make changes (erase/format/partition/etc). At the command line, diskutil
is its counterpart.
For files: if you just want to look around, it's Finder in the GUI. Apple makes a fair bit of the filesystem invisible in the Finder (which is sort of a "don't mess with this unless you know what you're doing" indication); if you want to see the normally-hidden parts, you can toggle show-all mode with Command-Shift-Period (this also works in standard open and save file dialogs). At the command line, it's ls
(I use ls -AleO@
to show hidden files and various obscure attributes).
If you want to see what files (/folders) are taking up all your space, you can get a basic summary with Apple menu > About This Mac > Storage tab, and a little more info by clicking the Manage button there. There are a bunch of third-party utilities that give more detail. At the command line, it's df
to show which volumes are getting full (df -h
for human-readable sizes), and du
to see how much space is used by each subfolder (and subsubfolder and...) (I mostly use sudo du -xhd1 /path/to/folder
to give a human-readable listing that only goes one folder level deep). Note that you'll need to grant the Terminal Full Disk Access to let its commands see into "private" areas of the filesystem.
For file activity, in addition to Activity Monitor, you can use lsof
to get a (huge) snapshot of which files are open (it las lots of flexible -- and confusing -- options), and fs_usage
to get an (extremely detailed) running log of file accesses.
For I/O, it really depends on the type of I/O you're interested in. If you want to see what's connected, System Information (click the Apple menu, hold the Option key and choose System Information) will give you a huge amount of information about the system's configuration (and not just about I/O devices/attachments). system_profiler
is its command-line counterpart.
You can use iostat
to look at I/O throughput per device (mostly disk access).
For network I/O, use the per-process tools above (and sudo lsof -i
to see open network ports). To view and change the network connection settings, use the System Preferences -> Network pane and its command-line counterpart networksetup
. For detailed network status, use the Network Utility, netstat
, and ifconfig
.
Other I/O... is rather scattered around. Several types, like Bluetooth, Displays, Sound, etc have panes in System Preferences. If you have a specific type you're interested in, you'd have to specify it.