iT邦幫忙

0

MacOS 使用指令增加使用者

  • 分享至 

  • xImage

目前有遇到一個狀況是

要幫macOS新增使用者

但由於要新增的使用者較多

而且蘋果系統算剛入手

不知道有人能幫忙告知要怎麼使用蘋果指令去新增

同時可以新增 user001~user100

不需要特殊權限

最基礎的使用者就好

感謝大家

圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

1 個回答

0
海綿寶寶
iT邦大神 1 級 ‧ 2020-06-24 22:25:43

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.
zeo0621 iT邦新手 5 級 ‧ 2020-06-24 22:48:41 檢舉

我也是找到類似的

但是輸入
sudo dcsl . -create\Users\Username Usershell /bin/bash

卻顯示
sudo: dcsl: command not found

我能確定我的權限是最大的帳號

所以有點疑惑到底錯在哪裡

zeo0621 iT邦新手 5 級 ‧ 2020-06-24 23:42:40 檢舉

我有找到這個指令可以用

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

我要發表回答

立即登入回答