Add user script in bulk - taken from LinuxSir

xiaoxiao2021-03-06  77

New features: Specify the shell for new users, such as I let them only send and receive emails, using ftp, no logged in permissions, can specify a shell: / bin / null that does not exist, then add this shell in the middle of the shells file. If you want this user to log in, only the function of modifying the password, you can change the password command / usr / bin / passwd as a shell, so that the new password is displayed when the user is logged in.

I found that _smbgroup must be a group already existing!

#! / bin / sh #Name: SMBADD #DES: To Add Some Samba User #author: Popzslam

_PASSWD = ****** #You can defined it youself. _SMBNAME = user _SMBGROUP = users #Sorry, I forget the samba group's name.You can edit this script and input the currect name. _SMBSHELL = / bin / null #Defined user's shell myAdd () {adduser $ _SMBNAME -g $ _SMBGROUP -s $ _SMBSHELL echo "The smbuser" $ _SMBNAME "is added to" $ _SMBGROUP echo "Set password for smbuser" echo $ _PASSWD |! passwd $ _SMBNAME --stdin}

UserList () {if [-f ~ / smbuserlist]; then

i = 1 while _num = `Head -n $ 1 == i {Printf"% s ", $ 1; next;} 'i =" $ i "` do if [-z $ _NUM] The echo "there is no user to add !!" exit 0 else _smbname = `awk '$ 1 == i {Printf"% s ", $ 2; Next;}' i =" $ i "~ / smbuserlist` MyAdd i = `EXPR $ i 1` Fi Done else echo" You Must Create a file named / "smbuserlist /" first! "fi}

#main part userlist #end

转载请注明原文地址:https://www.9cbs.com/read-92054.html

New Post(0)