Because we sometime need to work on the dark side...

Package management

Use Brew and Brew cask.

ps f

The MacOS version of ps does noot have a -f option. This can be emulated by using the pstree program available in the pstree brew package.

# treeps -- show ps(1) as process hierarchy -- v1.0 07/08/14
my %p; # Global array of pid info
sub PrintLineage($$) {    # Print proc lineage
  my ($pid, $indent) = @_;
  printf("%s |_ %-8d %s\n", $indent, $pid, $p{$pid}{cmd}); # print
  foreach my $kpid (sort {$a<=>$b} @{ $p{$pid}{kids} } ) {  # loop thru kids
    PrintLineage($kpid, "   $indent");                       # Recurse into kids
open(FD, "ps axo ppid,pid,command|");
while ( <FD> ) { # Read lines of output
  my ($ppid,$pid,$cmd) = ( $_ =~ m/(\S+)\s+(\S+)\s(.*)/ );  # parse ps(1) lines
  $p{$pid}{cmd} = $cmd;
  # $p{$pid}{kids} = (); <- this line is not needed and can cause incorrect output
  push(@{ $p{$ppid}{kids} }, $pid); # Add our pid to parent's kid
PrintLineage(($ARGV[0]) ? $ARGV[0] : 1, "");     # recurse to print lineage starting with specified PID or PID 1.



If there are sound problems, (low volume...) killing Core audio might be a solution:

sudo killall coreaudiod
sudo launchctl unload /System/Library/LaunchDaemons/ && sudo launchctl load /System/Library/LaunchDaemons/

Strace equivalent

The equivalent of strace under MacOS is dtruss. To be run by superuser.


sudo dtruss python

To filter specific syscalls the following can be used:

sudo dtruss -f -t open python

open port

lsof -nP -iTCP:$PORT | grep LISTEN


No space left on device

MacOS is quite annoying when there are no space left, since removing a file even with rm allocates some space on APFS. In that case the best way to save some space is to flush the swap (which automatically grows on MacOS). Then make up some space.

In some cases the storage management tool is able to flush the Trash or remove some files, not only rarely.

The only way I found to flush the swap is to restart.

If you get in a situation where the disk is so full that the OS is not able to restart, you'll need to remove the swap partition from recovery mode.

Enter recovery mode: start computer and press CMD+R until the loading bar appear.

Once in recovery mode, with diskutil list locate your main drive.

Make sure that you are selecting the correct partition, you can safely remove the swap volume (it will be recreated at startup). The swap partition is the one called APFS Volume VM.

diskutil apfs deletevolume disk2s4

restart in normal mode ~