How to create a user in linux using python

后端 未结 6 725
南旧
南旧 2020-12-08 16:48

How do I create a user in Linux using Python? I mean, I know about the subprocess module and thought about calling \'adduser\' and passing all the parameters at once, but th

6条回答
  •  孤街浪徒
    2020-12-08 17:18

    def createUser(name,username,password):
        encPass = crypt.crypt(password,"22")   
        return  os.system("useradd -p "+encPass+ " -s "+ "/bin/bash "+ "-d "+ "/home/" + username+ " -m "+ " -c \""+ name+"\" " + username)
    

提交回复
热议问题