Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

deutsch

#!/bin/bash
# Script to add a user to Linux system
if [ $(id -u) -eq 0 ]; then
	read -p "Einen Benutzer eingeben : " username
	read -s -p "Ein Passwort eingeben : " password
	egrep "^$username" /etc/passwd >/dev/null
	if [ $? -eq 0 ]; then
		echo "Benutzer Existiert schon!"
		read -p"Benutzer entfernen (j/n)? " response
			if ( "$response" == "j" ); then
			    echo "Entferne User : " $username
			    userdel $username
			    bash ./adduser.sh
			    exit 1
			else
			    echo "Bitte anderen Benutzer eingeben : "
			    read -p "Einen Benutzer eingeben : " username
	                    read -s -p "Ein Passwort eingeben : " password
	                    egrep "^$username" /etc/passwd >/dev/null
		              if [ $? -eq 0 ]; then
		                   exit 1
		               	 else
				   pass=$(perl -e 'print crypt($ARGV[0], "password")' $password)
				   useradd -m -p $pass $username
				 [ $? -eq 0 ] && echo "User wurde hinzugefuegt!" || echo "User konnte nicht erstellt werden!!"
		              fi
			fi
	else
		pass=$(perl -e 'print crypt($ARGV[0], "password")' $password)
		useradd -m -p $pass $username
		[ $? -eq 0 ] && echo "User wurde hinzugefügt!" || echo "User konnte nicht erstellt werden!!"
	fi
else
	echo "Nur root darf einen Benutzer zum System hinzufügen"
	exit 2
fi

read -p"Noch einen Benutzer erstellen (j/n)? " response
if ( "$response" == "j" ); then
	bash ./adduser.sh
	exit 3
else
    echo "thx .. "
    exit 4
fi
echo "ENDE"

Advertisements
Loading...

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.