-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadmin.sh
executable file
·43 lines (43 loc) · 1.02 KB
/
admin.sh
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
#!/bin/bash
PS3="Your choice: "
select ITEM in "Add User" "List All Processes" "Kill Process" "Install Program" "Quit"
do
if [[ $REPLY -eq 1 ]]
then
read -p "Enter username: " username
output="$(grep -w $username /etc/passwd)"
if [[ -n $output ]]
then
echo "The username $username already exists."
else
sudo useradd -m -s /bin/bash "$username"
if [[ $? -eq 0 ]]
then
echo "The user $username was added successfully."
tail -n 1 /etc/passwd
else
echo "There was an error adding the user $username."
fi
fi
elif [[ $REPLY -eq 2 ]]
then
echo "Listing all processes..."
sleep 1
ps -ef
elif [[ $REPLY -eq 3 ]]
then
read -p "Enter the process to kill: " process
pkill $process
elif [[ $REPLY -eq 4 ]]
then
read -p "Enter the program to install: " app
sudo pacman -Syu && sudo pacman -S $app
elif [[ $REPLY -eq 5 ]]
then
echo "Quitting..."
sleep 1
exit
else
echo "Invalid menu selection."
fi
done