#!/bin/bash # #********************************************** #Author: lanfeng #QQ: 447320311 #Date: 2020-07-12 #FileName: createuser.sh #Version: 1.1 #Description: The test script #Copyright (C) 2020All rights reserved #********************************************* if grep "dabao" /etc/passwd ;then echo "此用户已存在" else useradd dabao grep "dabao" /etc/passwd fi
此处以dabao未用户名进行判断,如果打包存在则提示"此用户已存在",否则创建此用户,并将创建用户的相关id,所属组等信息打印出来.