Skip to content

Instantly share code, notes, and snippets.

View fentensoft's full-sized avatar

Debug Liu fentensoft

  • East China Normal University
  • ShangHai, China
View GitHub Profile
@fentensoft
fentensoft / linux_shadow.py
Last active March 5, 2024 22:26
A simple python script to manage linux users (add, del, lock, unlock, list)
from passlib.hash import sha512_crypt
import subprocess
import pwd
def add_user(username, password):
pwd = sha512_crypt.encrypt(password)
return subprocess.call(["useradd", username, "-m", "-p", pwd])
def del_user(username):
return subprocess.call(["userdel", "-r", username])