Sometimes you want to use a specific port number but some other process(es) is using it. To get the control of the port you need to terminate all other processes and free it.
To find out which process(es) you need to kill, use lsof -i :port. It will return a list of each command and PID that is using the specific port. After that kill those PID using kill -s 9.
The following script will accept a range of ports to free, and for each it will try to kill all processes that are holding them blocked.
low=12345;
high=12350;
for i in `seq $low $high`; do
lsof -i :$i | tail -n +2 | awk '{system("kill -s 9 " $2)}';
done
Using tail -n +2 we skip the first line of the input which would be the header information.
The system method will invoke a new sh shell and execute the command in it.
Using kill -s 9 we signal the processes that they have to terminate immediately.
netstat -nputw; The "netstat" command is a network utility tool used to display information about active network connections, including the protocol used (TCP or UDP), the local and remote addresses and port numbers, and the current state of the connection. The options used in this command are as follows: "n"…
Following is a command a root can use to stop all active threads of a user with an exception list (you can replace someApplication) with specific commands you wish to keep alive. ps -U useraccount | egrep -v "someApplication|someCommand" | awk '{print $2}' | xargs -t kill; In this command,…
To empty the cache of gnome tracker3, you can follow the steps below: Open a terminal window by pressing Ctrl + Alt + T. Type the following command to stop the tracker daemon: tracker3 daemon -t; Type the following command to clear the tracker database: tracker reset --filesystem; This command…