Google 到幾篇都大同小異
這篇How to create a new user on Mac – The Geek Way的指令比較容易複製來用
提供參考
Step 1. Open Terminal. You can do that by clicking on the Terminal icon from the Utilities menu. Just drag down the Finder toolbar to reveal all the utilities.
Step 2. Type in the following line:
sudo dcsl . -create\Users\Username Usershell /bin/bash
Hit Enter to continue.
Step 3. Type in the following line:
sudo dscl . -create/Users/username RealName “Nicky Summer”
Of course, you will need to change the “Nicky Summer” string with the user’s real name. When ready, smash that Enter button to continue.
Step 4. Type in or paste the following line:
“sudo dscl . -create/Users/username UniqueID 1001
Please note that the UniqueID’s attribute must be different for each user (i.e. Marc Smith and John LeGrand, two fictional users, cannot both have 1001 as the UniqueID).
Step 5. Type in or paste the following line:
sudo dscl . -create/Users/username PrimaryGroup ID 1000
Hit Enter to continue.
Step 6. Type or paste this line:
sudo dscl . – create/Users/username NFSHomeDirectory/Local/Users/username
This command will allow you to whip up a home folder for the newly created user.
Step 7. Type in or paste the following line:
sudo dscl . -passwd\Users\username password
Of course, you will need to replace the “password” string with anything your heart desires. When ready, press Enter to continue.
(Optional) To grant the newly created user admin privileges, you will need to type in or paste the following line:
sudo dscl . -append/Groups/admin GroupMembership username
Press Enter to continue.
Congrats! You now know how to create a new Mac user using the Terminal. Get your lines straight, write the lines in order, and everything will be hunky-dory.
我也是找到類似的
但是輸入
sudo dcsl . -create\Users\Username Usershell /bin/bash
卻顯示
sudo: dcsl: command not found
我能確定我的權限是最大的帳號
所以有點疑惑到底錯在哪裡
我有找到這個指令可以用
sudo dscl . -create /Users/username
但卻不知道要怎麼去做MAC 的批次檔了@@
構想是
for i in {1..100}
do
sudo dscl . -create /Users/user$i
echo 0000 | password --stdin
user$i
done
我只敢這樣測試
加減看看
for i in {1..3};
do
echo 'sudo dcsl . -create/Users/user'$i' Usershell /bin/bash'
echo 'sudo dscl . -create/Users/user'$i' RealName 'User #'$i
echo 'sudo dscl . -create/Users/user'$i' UniqueID 3210'$i
echo 'sudo dscl . -create/Users/user'$i' PrimaryGroup ID 1000'
echo 'sudo dscl . –create/Users/user'$i' NFSHomeDirectory/Local/Users/user'$i
echo 'sudo dscl . -passwd/Users/user'$i' WdPs00'$i
done