You are on page 1of 6

1

Running head: Unix

UNIX
Student name:
Institution Affiliation:

2
unix

Script for user maintenance


Prompt the system administrator for all valid input parameters
bin/sh
#task commands
read p Input database name : dbasename
read s p Input Password : passwrd1
read p Input user name : username1
echo kindly select a single list option
#continue!

Generate a list to ask which task is needed to be performed

3
unix

#1/bin/sh
alist = 1. Do this activity;
blist= 2. Do that activity;
clist=3. Do another activity;
dlist=4. Create a group;
flist=5. Drop group;
elist=6. Create a User
glist=7. Stop User processes
hlist=8. Extras;
ilist= ;
wrongchoice () { MSG=Kindly select another option ; }
apick () { activity1 ; }
bpick () { activity2 ; }
cpick () { activity3 ; }
dpick () { cgrp ; }
epick () { dgrp ; }
fpick () { duser ; }
gpick () { kuproc ; }
hpick () { ext ; }
ipick () { wrongchoice ; }
thelist () {
clear
echo \t\tKindly select an option
echo
echo \t\t\t $alist
echo \t\t\t $blist
echo \t\t\t $clist
echo \t\t\t $dlist
echo \t\t\t $elist
echo \t\t\t $flist
echo \t\t\t $glist

4
unix

echo \t\t\t $hlist


echo \t\t\t $ilist
echo $MSG
}
MSG=
while true
do
thelist
read answer
MSG=
case $answer in
a|A) apick;;
b|B) bpick;;
c|C) cpick;;
d|D) dpick;;
e|E) epick;;
f|F) fpick;;
g|G) gpick;;
h|H) hpick;;
i|I) ipick;;
x|X) break;;
*) wrongchoice;;
#exit when user press X
#list display above

Create a UNIX group


#1/bin/sh
groupadd -g THISGID $batsgroup

5
unix

Drop a UNIX group

#1/bin/sh
groupdel $batsgroup

Create a user

#1/bin/sh
#generate a User file with users names to input in a list
# the file name userslist.txt
if grep q ^${group}: /etc/group
for I in more userslist.txt
do
echo $i
adduser $i
done
#now run it
./userslist.txt

Drop a user

#1/bin/sh
for ttt in host1
do
echo $tt
ssh $ttt rmuser p batsuser
done

A script that will kill all of the processes associated with a user.
#1/bin/sh
#kill process
read p Input user name : username1

6
unix

top U username1
read p Input the process group name : procgrpname
while [true]
ps aux
do
echo input the process ID to kill
read procnum
echo Are you sure you want to kill $procnum?
echo 1 for yes, 2 for no
read chosen
if [ $chosen eq 1]
then
kill -9 $procnum
fi
done

Differences between Daemons and Processes


Daemons and processes are similar in function and scope but they are typically different in
one major way, daemons are usually started when the computer boots as well as tend not to
be stopped unless it is killed by a process or the computer shuts off, manually. Processes
especially the USER PROCESSES, are specific jobs that the daemon will call to achieve the
wish of the operator. Processes are threads that are ended when the job completes and are not
retained running as daemons are. Killing a daemon or daemons being executed causes errors
such as failure to access the server through SSH, as well as most often will need a reboot of
the system to restart the daemons required to operate the system.

You might also like