Linux logout user or logoff user commands

by on May 15, 2007 · 15 comments· last updated at May 15, 2007

Q. How do I logout Linux user?

A. root or admin user can logout any user forcefully. If you are logged in as vivek and just wanted to logout or logoff, type logout command or hit CTRL+D:
$ logout

You will be logout of a login shell session or secure shell session.

Task: Linux logout user

If you would like to logout other users, you must login as root user. Next you need to use pkill command.

pkill command syntax

pkill -KILL -u {username}

To see list of logged in user type who or w command:
# who
OR
# w
To logout user called raj, enter:
# pkill -KILL -u raj
OR
$ sudo pkill -KILL -u raj

For more information read our article - Howto: Linux kill and logout users



You should follow me on twitter here or grab rss feed to keep track of new changes.

Featured Articles:

{ 15 comments… read them below or add one }

1 rajdoe December 12, 2007 at 1:13 am

Thankssssss man !

Reply

2 songshu July 24, 2008 at 1:15 pm

Its one of things i hardly ever remember, never mind that i take the effort to write it down, but if you do need it a post like this is worth a million…
thanks

Reply

3 The Doctor June 12, 2009 at 1:44 am

Works in OpenBSD 4.5 also. Great tip.

Reply

4 Wildcard September 2, 2009 at 12:13 am

Whow, thanks for this posting! Just what I needed, highly appreciated!

Reply

5 Husen June 7, 2010 at 10:55 am

Thanks, I was looking for such a command

Reply

6 harris March 5, 2011 at 2:49 am

i want to show the login time and logout time of all users then i will sort it according to their name help me pls…

Reply

7 Mehdi May 6, 2011 at 5:09 pm

Thanks a lot!
pkill worked fine in the GUI session!
Regards;

Reply

8 Mohamad Aqashenas September 14, 2011 at 1:48 pm

Thanks a lot.
I found here very usefull information about my quistions.
Best regards.

Reply

9 yaw October 6, 2011 at 3:02 pm

what’s the KILL flag do?

Reply

10 arturo April 16, 2012 at 3:58 am

thanks, it works me to kill my locked sessions in a server

Reply

11 Raj May 14, 2012 at 12:08 pm

Hey, Thanks… This is exactly i requried.

Reply

12 New_Linux_kid June 15, 2012 at 5:18 am

Thanks you buddy….I have seen some of your posts regarding Linux commands. They are very useful for beginners like me.

Reply

13 shivendra August 24, 2012 at 5:32 am

if i logged twice from putty as same user root then if i want to logout one root user then how i would do it.As same user logged twice then in that case if i kill process of root -user then both will get kill…so is their is any ip based parameter to logout one root ?

Reply

14 sunnogo August 27, 2012 at 3:18 pm

Mark! do the work!

Reply

15 Scott April 8, 2013 at 4:16 pm

Wow. What bad information. Lets say you have root logged in under two sessions.

pkill -KILL -u root

That kills all processes owned by root. Meaning most system processes.

Let’s say you have one user in multiple sessions and that user is not root. Well, you just killed both sessions, even if that’s not what you wanted.

This is terrible advice, and the article should be called “Linux Kill All Processes by User”, and have nothing to do with “logging off”.

Reply

Leave a Comment

You can use these HTML tags and attributes for your code and commands: <strong> <em> <ol> <li> <u> <ul> <kbd> <blockquote> <pre> <a href="" title="">

Tagged as:

Previous Faq:

Next Faq: