deepseek-v3-0324· DeepSeek LMArena Human Preference 140K
how to kill process in Linux which uses given port e.g. 5000
- User
how to kill process in Linux which uses given port e.g. 5000
- Assistant
To kill a process in Linux that is using a specific port (e.g., port
5000), follow these steps:1. Find the Process ID (PID) Using the Port
Use the
lsof(List Open Files) command to identify the process:sudo lsof -i :5000Example output:
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME python3 12345 user 3u IPv4 123456 0t0 TCP *:5000 (LISTEN)- The
PID(e.g.,12345) is the process ID you need to kill.
2. Kill the Process
Once you have the PID, terminate it using:
sudo kill -9 12345(Replace
12345with the actual PID from the previous step.)Alternative: Using
fuserYou can also use
fuserto find and kill the process:sudo fuser -k 5000/tcpThis directly kills the process using port
5000.If
lsoforfuseris Not InstalledInstall them using:
- Debian/Ubuntu:
sudo apt install lsof - RHEL/CentOS:
sudo yum install lsof
Verify the Port is Freed
Check if the port is no longer in use:
sudo lsof -i :5000(No output means the port is free.)
This should successfully kill the process using port
5000. Let me know if you need further help! 🚀 - The
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.