A fast and elegant command-line utility for inspecting and managing TCP ports on macOS and Linux
Project description
lsport
A fast and elegant command-line utility for inspecting and managing TCP ports on macOS and Linux.
What is lsport?
lsport helps you quickly identify which processes are occupying TCP ports and terminate them when needed. It provides three modes of operation:
- List mode: View all open TCP ports with process details
- Kill mode: Terminate a process occupying a specific port
- Interactive mode: Browse and manage ports through a TUI menu
Features
- ๐ Fast port scanning using
psutil - ๐จ Beautiful terminal output with
rich - ๐ Filter by port state (LISTEN, ESTABLISHED, CLOSE_WAIT)
- ๐ก๏ธ Safe: asks for confirmation before killing processes
- ๐ช Force kill option for stubborn processes
- ๐ Interactive TUI for easy port management
Requirements
- macOS or Linux
- Python 3.9 or higher
pipx(one-time install)
Installation
lsport is distributed as a standard Python package and installed in an
isolated environment via pipx. This avoids
polluting your system Python, never touches sudo, and gives you a clean
pipx uninstall lsport when you're done.
1. Install pipx (one-time)
macOS:
brew install pipx
pipx ensurepath
Linux (Debian/Ubuntu):
sudo apt install pipx
pipx ensurepath
For other distributions or platforms see the pipx installation guide.
2. Install lsport
git clone https://github.com/0xBroom/lsport.git
cd lsport
pipx install .
That's it. lsport is now available on your PATH, with its dependencies
isolated in a dedicated virtual environment under ~/.local/share/pipx/.
Updating
cd lsport
git pull
pipx install . --force
Uninstalling
pipx uninstall lsport
Usage
List all open ports
lsport list
Output example:
โโโโโโโโฌโโโโโโโโโโโโโโฌโโโโโโโโโโโฌโโโโโโโฌโโโโโโโโโโโโโโโโโ
โ Port โ Protocol โ State โ PID โ Process โ
โโโโโโโโผโโโโโโโโโโโโโโผโโโโโโโโโโโผโโโโโโโผโโโโโโโโโโโโโโโโโค
โ 3000 โ 0.0.0.0:3000โ LISTEN โ 1234 โ node โ
โ 5432 โ 127.0.0.1:* โ LISTEN โ 5678 โ postgres โ
โโโโโโโโดโโโโโโโโโโโโโโดโโโโโโโโโโโดโโโโโโโดโโโโโโโโโโโโโโโโโ
Filter by state
# Show only listening ports
lsport list --state listen
# Show active connections
lsport list --state established
# Show ports in close_wait state
lsport list --state close_wait
Kill a process on a specific port
# Interactive kill (asks for confirmation)
lsport kill 3000
# Skip confirmation
lsport kill 3000 --yes
# Force kill (SIGKILL instead of SIGTERM)
lsport kill 3000 --force
Interactive mode
lsport interactive
Navigate the interactive TUI to:
- Browse all LISTEN ports
- Select ports by row number or port number
- Kill processes with confirmation
Command Reference
lsport list
Lists all open TCP ports.
Options:
-s, --state [listen|established|close_wait]- Filter by connection state
lsport kill <port>
Terminates the process occupying the specified port.
Options:
-f, --force- Use SIGKILL instead of SIGTERM-y, --yes- Skip confirmation prompt
lsport interactive
Launch an interactive TUI to browse and manage ports.
Development
Project structure
lsport/
โโโ lsport.py # Main CLI application
โโโ pyproject.toml # Package metadata and entry point
โโโ LICENSE # MIT License
โโโ README.md # This file
Dependencies
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Author
Created by Esteban Encina
Acknowledgments
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file lsport-0.3.0.tar.gz.
File metadata
- Download URL: lsport-0.3.0.tar.gz
- Upload date:
- Size: 10.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9e2026acaef5bb26a7ecdcd682a9c1d8f74c5089031fdd4f28b375a438d2ba22
|
|
| MD5 |
f620ea0da1b32e894d95ae4a914b0023
|
|
| BLAKE2b-256 |
90d8c4f3b4bb70441ec235afe5e067503fab49de0debae8a0687070cb2087381
|
Provenance
The following attestation bundles were made for lsport-0.3.0.tar.gz:
Publisher:
release.yml on 0xBroom/lsport
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
lsport-0.3.0.tar.gz -
Subject digest:
9e2026acaef5bb26a7ecdcd682a9c1d8f74c5089031fdd4f28b375a438d2ba22 - Sigstore transparency entry: 1484799012
- Sigstore integration time:
-
Permalink:
0xBroom/lsport@47f91dfafa3977addad86288d702b2cf72b0cc8b -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/0xBroom
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@47f91dfafa3977addad86288d702b2cf72b0cc8b -
Trigger Event:
push
-
Statement type:
File details
Details for the file lsport-0.3.0-py3-none-any.whl.
File metadata
- Download URL: lsport-0.3.0-py3-none-any.whl
- Upload date:
- Size: 7.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
80205eff4bdfe64c9c14a15f39b9b6e7ab5f6be4952e4b74a6e92a88870509ee
|
|
| MD5 |
8010ab8fe6f390d83ba74da88f84017d
|
|
| BLAKE2b-256 |
5e5604a01f389714c51834bba1867383405d13f84a3b90bcac118ee3b8e5530d
|
Provenance
The following attestation bundles were made for lsport-0.3.0-py3-none-any.whl:
Publisher:
release.yml on 0xBroom/lsport
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
lsport-0.3.0-py3-none-any.whl -
Subject digest:
80205eff4bdfe64c9c14a15f39b9b6e7ab5f6be4952e4b74a6e92a88870509ee - Sigstore transparency entry: 1484799062
- Sigstore integration time:
-
Permalink:
0xBroom/lsport@47f91dfafa3977addad86288d702b2cf72b0cc8b -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/0xBroom
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@47f91dfafa3977addad86288d702b2cf72b0cc8b -
Trigger Event:
push
-
Statement type: