CLI Commands
Network
Kill Process
This command terminates all processes listening on TCP port 3000. The fuser utility identifies which processes are using a specified file or network port, and the -k flag kills those processes. Useful for freeing up port 3000 when a process won't exit gracefully.
fuser -k 3000/tcp
List Sockets
This command lists all listening TCP network sockets along with their associated process information, then filters the results to show only those using port 3000. Useful for identifying which process is using port 3000 in a WSL environment.
ss -ltnp | grep ':3000'
Example Output:
LISTEN 0 511 *:3000 *:* users:(("MainThread",pid=10015,fd=27))
Retrieve IP Addresses
Retrieve the first IP address assigned to the WSL2 instance.
It uses hostname -I to list all IP addresses associated with the system,
and awk '{print $1}' to extract and display only the first one,
which is typically the primary network interface's IP address.
hostname -I | awk '{print $1}'
Example Output:
172.24.176.1
The actual IP address will vary depending on your WSL2 instance and network configuration.
Git
Delete Branches
git branch | grep -vE '^\*?\s*main$' | xargs -r git branch -D
This command safely deletes all local Git branches except the main branch. It works by:
git branch- lists all local branchesgrep -vE '^\*?\s*main$'- filters out the main branch (and current branch indicator *)xargs -r git branch -D- deletes each remaining branch forcefully (-D flag)
The -r flag in xargs prevents errors if no branches match the filter.
Use with caution as deleted branches cannot be easily recovered.