-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathautouser.sh
More file actions
executable file
·87 lines (61 loc) · 1.44 KB
/
autouser.sh
File metadata and controls
executable file
·87 lines (61 loc) · 1.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/bin/bash
# Script for
# creating multiple users
# removing multiple users
# Showing users
# Author: github.com/LifeErice
# Version : 1.0.0
echo
echo ' ____ __ __ ______ ___ __ __ _____ ___ ____ '
echo ' / || | || | / \ | | |/ ___/ / _]| \ '
echo ' | o || | || || || | ( \_ / [_ | D ) '
echo ' | || | ||_| |_|| O || | |\__ || _]| / '
echo ' | _ || : | | | | || : |/ \ || [_ | \ '
echo ' | | || | | | | || |\ || || . \ '
echo ' |__|__| \__,_| |__| \___/ \__,_| \___||_____||__|\_| '
echo ' Author: EricLife '
echo
# if the there is no argument
if [ $# -eq 0 ]
then
echo "Syntax: autouser -c bob"
echo "autouser --help | -h"
exit 0
fi
# Creating user
# if the arguments match with -c
if [[ "$1" = "-c" ]]
then
# if there is more user passed in arguments
shift
for u in $* ;
do
sudo useradd $u
echo "$u:Password1" | sudo chpasswd
echo
sudo passwd -e $u
echo "$u your temporary password is Password1"
echo "You're good to go!"
done
exit 0
fi
# Removing Users
# if detected the -r argument
if [[ "$1" = "-r" ]]
then
# goto next value
shift
for u in $* ;
do
sudo userdel -r $u
echo "$u has been delected!"
done
exit 0
fi
# Show all users
# if the -s detected
if [[ "$1" = "-s" ]]
then
cat /etc/passwd | grep "/home/" | cut -d ":" -f1
fi
exit 0