[Fw]linux How to view and kick off other users who are logged in

Source: Internet
Author: User
Tags ftp client

How to view and kick other users who are logged in under LinuxPosted on2011/09/01

How do I view the currently logged in user under Linux and kick off the users you think should be kicked off?
Please use the WHO command to see who is currently logged in

[email protected] http]# who
Root Tty1 Apr 9 13:17
HTTP pts/0 Apr 16 15:13 (192.168.8.235)
HTTP PTS/1 Apr 16 15:13 (192.168.8.235)

Note: May have a friend to call out immediately: "What?!" There are 3 users logged in! I've been hacked! ", hehe, joking ~ ~ The above message tells us:

TTY refers to the creation of a TTY when you log in to any virtual console, such as when you plug in a monitor login host, and you add a TTY.

pts is the result of every remote connection, such as I am now using the FTP client to connect to the host, the host will produce a PTS, in fact, the above 192.168.8.235 is me, the two HTTP on my connection.
TTY and pts see: http://blog.haohtml.com/archives/11102

To kick out a user and the program that the user runs (very savage), use the following method:
For example: Want to kick off HTTP this user and all of his open programs execute the following command

Pkill-u http

Note: This command is actually very dangerous, so be very careful to execute!!
The reason for his danger is that all the relevant programs of the user will be turned off, what does that mean? That means: If you use HTTP as the user-enabled Apache service, the Apache service has stopped and you have to manually open Apache services! Be more critical: if you accidentally execute the command to kick out the root, it means that the SSH service using root also stops, and you have to (yes!). is necessary! Connect the monitor to the server, or you must press the reset button ~ ~
So what's the safe way?
It is safe to look at the terminal number and then see all the processes performed by that terminal, and stop the service according to the process number!
Example:

[email protected] http]# who
Root Tty1 Apr 9 13:17
HTTP pts/0 Apr 16 15:13 (192.168.8.235)
[Email protected] http]# ps-ef|grep pts/0
HTTP 16627 16595 0 15:13? 00:00:00 sshd: [Email protected]/0
HTTP 16628 16627 0 15:13 pts/0 00:00:00-bash
Root 16680 16628 0 15:13 pts/0 00:00:00 su
Root 16681 16680 0 15:13 pts/0 00:00:00 bash
Root 18089 16681 0 15:41 pts/0 00:00:00 ps-ef
Root 18090 16681 0 15:41 pts/0 00:00:00 grep pts/0

Did you see it? If you want to terminate a process, look at the process number and execute it. For example, to knock out the HTTP bash, see that the process number is 16628.

Kill-9 16628

You can do it.
But be careful not to expel yourself.
Additional Information:
First W look at them in TTY? And then PS aux |grep tty? , and then kill the PID
The distal end should be pts, kill it.

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.