Linux - NetworkingThis forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
How can I log out the User4 from my console using the root login?
I just checked out the man page of shutdown but didn't find any hint there.
The logout command is also not doing the work. We cannot specify a username wit it to log him/her out.
While you are logged in as superuser/root you can use 'kill' command.
1. Know the UID in tty4:
root@host-# w (this will return list of all logged users in the machine)
2. Kill the process ID (PID) belonging to him:
root@host -#ps axu | grep USER
root@host-# kill N (where N =the PID number of the user you want to kick out)
3. If he has taken hold of X while you are at the shell you can kill the X process ID
root@host-# top (this will show X pid) press "K" then write the X PID, press Enter.
If you want to close all files opened by the user you can find them all using "lsof | grep 'username'" then proceed to kill all of it. Just be careful of this.
Distribution: On my PC I use RHEL, at office AIX, Solaris, HP-UX, RHEL.
Posts: 254
Original Poster
Rep:
Quote:
Originally Posted by malekmustaq
While you are logged in as superuser/root you can use 'kill' command.
1. Know the UID in tty4:
root@host-# w (this will return list of all logged users in the machine)
2. Kill the process ID (PID) belonging to him:
root@host -#ps axu | grep USER
root@host-# kill N (where N =the PID number of the user you want to kick out)
3. If he has taken hold of X while you are at the shell you can kill the X process ID
root@host-# top (this will show X pid) press "K" then write the X PID, press Enter.
If you want to close all files opened by the user you can find them all using "lsof | grep 'username'" then proceed to kill all of it. Just be careful of this.
Hope it helps.
Well, I thought there would be a command to accomplish it straightforwardly.
Anyways, thanks for the suggestion. Can you suggest a method of killing a process which has multiple Process IDs?
For example, user_zero logs in using the shell bash. The user_zero execute the command: "vi fileName".
We see in the output of
ps aux | grep user_zero
that there are two PIDs- one for -bash and the other for "vi filename".
So, "killall -u user_zero" would only terminate the editor and log off the user. We need to kill the PID of "-bash" also.
Is there any single command to kill all the PIDs of a single User or Command or Service?
Okay, I just tried:
killall -9 pid_of_"-bash"
and the user is logged out.
Last edited by Hi_This_is_Dev; 09-24-2010 at 07:20 PM.
- No need to use 'killall', 'kill' is enough.
- Because of bash is parent process (check with ps -ef | grep pts\/x). Killing the parent will kill its children as well.
Is there any single command to kill all the PIDs of a single User or Command or Service?
As 'quanta' stated above so it is: "Kill the mother, and the children die." Or have you not read, it is written: "I shall strike the shepherd and the flock is scattered."
So how would you know which is the mother and which are the children?
GNU has made it simple for you to know. Issue either of these commands in the terminal and you shall see the picture of the process tree:
Hi_There@host--# ps -ejH (or this one..)
Hi_There@host--# ps -axjf
Hope this helps. Good luck.
Last edited by malekmustaq; 09-25-2010 at 02:45 AM.
that there are two PIDs- one for -bash and the other for "vi filename".
So, "killall -u user_zero" would only terminate the editor and log off the user. We need to kill the PID of "-bash" also.
Where effective user was able to deploy multiple threads there shall be many processes bearing children and possible grandchildren. This means you are not engaged against a family alone but killing you have to kill the entire clan.
To control the system is the work of the admin. Looking ONLY for a single magical command is like a lazy man waiting for a miracle to happen. And I can only give you one miracle to eradicate all processes in one command: 'Ctl+Alt+Del' !
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.