How to view the logged in user and kick out under the Linux system

Source: Internet
Author: User
Tags pkill

Linux is a multi-user system that, once connected to a network, can serve multiple logged-in users at the same time.

View the actions of a user

View Current User:

[[email protected] ROOT] # W
2:31pm up one day, 21:18 4 USERS, Lode average:0.12, 0.09, 0.08
USER TTY from [email protected] IDLE jcpu PCPU
ROOT tty1-09:21am 3:23 0.13S 0.08s-bash
GEORGE tty2-09:40am 18:00s 0.12S 0.00S TELNET
HELLO tty6-11:12am 34.00S 0.06S 0.o6s BASH
MARRY pts/1 192.0.3.1102:40pm 5.20S 0.09S 0.03S FTP

command message meaning

The information shown above is indicated as follows:

The first line shows the summary information of the system, and the fields indicate the current time of the system, the system running time, the total number of users logged in and the system average load information. For several of the above display data the meanings are:

2:13PM indicates that the time to execute W is 2:31 P.M..

11DAYS,21:18 indicates that the system is running for 11 days and 21 hours and 18 minutes.

4 users indicate that the total number of systems logged in today is 4.

The load AVERAGE, along with the numbers that follow, indicates how much the system has been loading in the last 1, 5, 10 minutes, the smaller the value, the lighter the system load.

From the second line to form a table, a total of 8 columns, showing what each user is doing and the system resources occupied by the user.

User: Displays the login username. The user repeatedly logs in, the account will also appear repeatedly.

TTY: The terminal used by the user to log in.

From: Shows where the user landed the system.

[Email protected]: is the login at, indicating the time of landing into the system.

Idle: User idle time, from the end of the last task of the user, to the current duration.

JCPU: A terminal designator that indicates the CPU time spent on all process tasks associated with the terminal during this time period.

PCPU: Refers to the CPU time that is spent after the task of the what domain is executed.

What: Represents the currently executing task.

View a user

When the login system user is a lot of time, you can add a user name after W, you will see the user to perform the task of the situation.

[Email protected]:/# W Joe


14:20:53 up 13:52, 4 users, Load average:0.23, 0.17, 0.14
USER TTY from [email protected] IDLE jcpu PCPU
Joe pts/0 Www.lan 14:20 10.00s 0.12s 0.12s-bash

By default, all of the above information is displayed, and if you only care about one aspect, you can use only the relevant options.

View Login User

Similarly, if a system administrator wants to know which users are logged on at a given moment, they can use the system-provided web commands, which can view the users and other information currently logged on to the system:

[[email protected] root] #who                        root tty1-09:21am                        reorge tty2-09:40am                        Hello tty6-11:12am                        marry pts/1:0 02:40pm

You can see that the above information is very similar to the W command. If you want to make the list more detailed, you can add the option-hit, and so on, you can get the user is willing to accept other user information (-T) can also display the idle time (-i) and the title bar (-h). If a user is willing to accept the message, a "+" is displayed in the MESG column, which is also used to send the message to the user using the command MESG.

Use Who am I to see that is your own login terminal

[email protected] ~]# who am I


Root PTS/1 2009-08-02 03:06 (192.168.0.31)

View Login User History

If the system administrator wants to know the historical behavior of user login in the system, it can also see that the user has logged in to the system. Use the last command to query the information of the user who logged in:

[Email protected]:~$ last
Joe pts/0 Www.lan Thu Sep 14:20 still logged in
Root PTS/4 www.lan Thu Sep 11:04 still logged in
Root PTS/3 www.lan Thu Sep 10 10:26-13:14 (02:48)
Root pts/0 www.lan Thu Sep 10 10:15-12:36 (02:20)
Root PTS/6 Www.lan Thu 20 10:09-14:21 (04:11)
Root PTS/5 Www.lan Thu 20 09:59-14:11 (04:12)
Root PTS/4 www.lan Wed 19 17:18-12:01 (18:43)
Root PTS/3 www.lan Wed 19 17:18-12:08 (18:50)
Root PTS/2 192.168.35.111 Wed 19 14:57-11:41 (20:44)
Root PTS/1:0 Wed 14:54 still logged in
Root pts/0:0 Wed 19 14:02-17:18 (1+03:16)

If you want to see the user's login, you can also add a user name after the last command, the system will only show the user login system situation.

[Email protected]:~$ last Joe


Joe pts/0 Www.lan Thu Sep 14:20 still logged in

Wtmp begins Tue 18 15:32:04 2015

Executing the last command is actually displaying the contents of the Wtmp file in the/var/log/directory.

How Linux kicks out logged-in users :

[Email protected]:~# pkill-kill-t pts/0

If the last view is still not killed, it is recommended to add-9 forced kill.

[Email protected] ~]# pkill-9-t PTS/1

Above transfer from: http://tech.ccidnet.com/art/302/20061121/956303_1.html

How to view the logged in user and kick out under the Linux system

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.