Last active
November 14, 2015 20:43
-
-
Save awd-git/d79330fad4b648a849fd to your computer and use it in GitHub Desktop.
Manage processes in Linux (Ubuntu)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Easiest way to find out what processes are running | |
$ top | |
// Improved version of top. Install on ubuntu as: | |
$ sudo apt-get install htop | |
// run htop same as top | |
$ htop | |
// Listing running process with ps | |
// ps itself won't show much | |
$ ps | |
// this will show pretty much every process | |
$ ps aux | |
// filter output with grep | |
$ ps aux | grep init | |
// show processes in a hierarchical relationship | |
$ ps axjf | |
// Simple way to find the PID of a process is pgrep | |
$ pgrep init | |
// Kill a process by id (where PID is the process ID number) | |
$ kill PID | |
// If it won't go add some oomph | |
$ kill -KILL PID | |
// Kill an established TCP connection | |
// first identify the remote port you like to kill | |
$ netstat -n | grep 5002 | |
tcp 0 45021 192.168.0.64:5002 192.168.0.129:50826 ESTABLISHED | |
// second identify the inteface | |
$ netstat -in | |
Kernel Interface table | |
Iface MTU Met RX-OK RX-ERR RX-DRP RX-OVR TX-OK TX-ERR TX-DRP TX-OVR Flg | |
**eth1** 1500 0 32397808 0 91 0 109544268 0 0 0 BMRU | |
lo 65536 0 86298 0 0 0 86298 0 0 0 LRU | |
wlan0 1500 0 253441 0 0 0 151715 108899 0 0 BMU | |
// call tcpkill with interface and port | |
$ sudo tcpkill -i eth1 port 5002 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment