Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top
watch netstat -n -A inet             + notify-send "Attention new  connection"


watch  cat /proc/net/ip_conntrack    + notify-send "Attention new  connection"


watch ss -n                          + notify-send "Attention new  connection"

Do you have any idea how to connect this halves and thank you.

share|improve this question
Wait a minute... you want a notification each time a socket is opened? – Braiam Dec 12 '13 at 23:41
Which desktop manager are you using? as with some you can set a notification anyway. – Wilf Dec 12 '13 at 23:43

What you need is a short bash script, like:

while [ 1 ]
  if [ "PARAMETER" = "SOMETHING" ]; then
     notify-send "Attention" "There is a new connection."
     echo "Nothing Found"
  sleep 5

Basically, this would listen for a PARAMETER (How, I don't know...), and when it equals SOMETHING, then it will send a notification. If the PARAMETER is not equal to SOMETHING, it will print Nothing Found (This is not necessary, it just shows that it is working), wait for 5 seconds, and start again.

The problem is getting it find when it has connected... None of these...

  • netstat -n -A inet
  • cat /proc/net/ip_conntrack - apparently deprecated anyway, see here
  • ss -n

...seem to produce the parameters required...

Any corrections welcome, especially with the bash script

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.