cancel
Showing results for 
Search instead for 
Did you mean: 

kicking out a user

khilari
Regular Advisor

kicking out a user

hi guys, i want to delete a user but he is currently logged on with some processes. What is the cleanest way to get this done.
Thanks

root@sp10 # ps -ef | grep saps
saps 26159 26140 0 Jun 3 pts/ta 0:00 -sh
root 694 29500 0 23:31:04 pts/0 0:00 grep saps
saps 4711 26159 0 Jun 3 pts/ta 0:00 more runserver.sh
8 REPLIES
johnsonpk
Honored Contributor

Re: kicking out a user

Hi khilari,

Kill those user process by Kill -15

#kill -15 4711
#kill -15 26159

Then delete the user by userdel command


Rgds
Johnson
Safarali
Valued Contributor

Re: kicking out a user

Hi

You can use who -a | grep user name and kill the id


Sajjad Sahir
Honored Contributor

Re: kicking out a user

Dear Khilari

please determine the exact process id first, by using the command ps -eaf | grep username then only issue the kill -15 to terminate the process.

once u killed the process u can delete the user
by using userdel command

thanks and regards

Sajjad Sahir
Akif_1
Super Advisor

Re: kicking out a user

Hello,

Always remember KILL/RM/CHOWN are dangerous commands in UNIX. So be careful before you react.

Determine the severity of the user process
Kill those user process by Kill -15 or #kill -9

#kill -15 4711
#kill -15 26159

To restrict future login of this particular user delete the user by userdel command


Rgds
Akif
T(ogether) E(very one) A(chive) M(ore)
Dennis Handly
Acclaimed Contributor

Re: kicking out a user

If you are going to deleted a user, why is it still logged on?

To find the processes:
UNIX95=EXTENDED_PS ps -H -fu saps

After checking above, to just kill them all:
kill $(UNIX95=EXTENDED_PS ps -fu saps -opid=)

Arunabha Banerjee
Valued Contributor

Re: kicking out a user

Hi you can do this following way also

ps -fu saps | awk '{print $1,$2}' (See the list of running process by saps)


kill -9 `ps -ef |grep saps |awk '{print $2}'` (and then kill the all process for saps user)

now you can delete the saps user and saps user home directory also

# userdel -r saps
AB
Suraj K Sankari
Honored Contributor

Re: kicking out a user

HI,

Ffirst kill the process which is own by saps
as per your output there are 2 process I can see :
saps 26159 26140 0 Jun 3 pts/ta 0:00 -sh
saps 4711 26159 0 Jun 3 pts/ta 0:00 more runserver.sh
use the below command
#kill -9 26159 4711

then cross check with
#ps -aef | grep saps
once you check then used
#userdel saps or
#userdel -r saps

-r removes user saps's home directory.

Suraj
Durvesh Mendhekar
Regular Advisor

Re: kicking out a user

Hi,

Use who -THu to detemine the terminal and then
kill it by using fuser -k /dev/"terminal".

Regards,
Durvesh