How to add a user from the command line in macOS? In Terminal, I used, useradd liao2, as I would also do in Linux, but it failed:

useradd liao2
-bash useradd: command not found


I also tried using sudo:

sudo useradd liao2
Password:
sudo: useradd: command not found


How can a user be added from Terminal?
A similar tool to useradd is /usr/sbin/sysadminctl on macOS . There isn't a manual but /usr/sbin/sysadminctl -h is explanatory. You should be aware that the command and options will be stored in your shell's history. Note the last line of the help output so that the user password is not stored in your shell's history.