Ubuntu process view and end commands in Linux

Source: Internet
Author: User
Tags port number

Description of the situation

Due to improper operation, the Django program in the terminal started Python manage.py runserver is not closed (port 8000), again when the terminal starts, an error occurred:

Error:that port is already in use.

Now find the original process and kill the process.

Solutions

1.sudo Netstat-antup

To activate an Internet connection (server and established connections)

The code is as follows Copy Code
Proto recv-q Send-q Local address Foreign address State Pid/program Name
TCP 0 0 127.0.0.1:631 0.0.0.0:* LISTEN 2206/cupsd
TCP 0 0 127.0.0.1:5432 0.0.0.0:* LISTEN 1138/postgres
TCP 0 0 127.0.0.1:953 0.0.0.0:* LISTEN 1053/named
TCP 0 0 127.0.0.1:8000 0.0.0.0:* LISTEN 3203/python
TCP 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN 1041/mysqld
TCP 0 0 127.0.0.1:20080 0.0.0.0:* LISTEN 3415/ssh
TCP 0 0 192.168.1.75:53 0.0.0.0:* LISTEN 1053/named
TCP 0 0 127.0.1.1:53 0.0.0.0:* LISTEN 1223/dnsmasq


The PID number for the process with port number 8000 is found to be 3203

Kill this process with the following command

The code is as follows Copy Code
sudo kill 3203

2.sudo lsof-i:8000

The code is as follows Copy Code

COMMAND PID USER FD TYPE DEVICE size/off NODE NAME
Python 3632 Ying 3u IPv4 46257 0t0 TCP localhost:8000 (LISTEN)

Kill the process the same way 1

The code is as follows Copy Code

3.ps aux | grep manage.py

Ying 3497 0.0 0.5 67112 23456 pts/26 s+ 10:57 0:00 python manage.py runserver
Ying 3498 0.9 0.6 143784 25176 pts/26 sl+ 10:57 0:05/usr/bin/python manage.py runserver
Ying 3615 0.0 0.0 15956 932 pts/28 s+ 11:07 0:00 grep--color=auto manage.py

Kill Process Method Same Method 1

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.