ss – socket statistics – translated for netstat users

ss –  translated for netstat users

Since netstat version 1.4, man page says that netstat is obsolete, so We should use ‘ss’, but how?
I put here some tips here:

Show listening connections with process name and PID

sudo ss -ltp

Show all connections with process name and PID of each open connection

sudo ss -tp

Filter out tcp, udp

ss -A tcp
ss -A udp

Do not resolve hostname

ss -nt

Show only listening sockets

ss -ltn # For TCP
ss -lun # For UDP

Filtering connections by tcp state

ss -t4 state established
ss -t4 state time-wait

The state can be either of the following

  1. established
  2. syn-sent
  3. syn-recv
  4. fin-wait-1
  5. fin-wait-2
  6. time-wait
  7. closed
  8. close-wait
  9. last-ack
  10. closing
  11. all : All of the above states
  12. connected : All the states except for listen and closed
  13. synchronized : All the connected states except for syn-sent
  14. bucket : Show states, which are maintained as minisockets, i.e. time-wait and syn-recv.
  15. big : Opposite to bucket state.


How do I generate crypted passwords for the user module?
mkpasswd --method=SHA-512

Ad-Hoc Commands
ansible -i env/XXX/hosts group_you_want -a "sudo sed -i 's/DNS1.*//;s/DNS2.*//' /etc/sysconfig/network-scripts/ifcfg-ens192" -u xx --become

Show Environment Variables values:
ansible -i env/XXX/hosts -m debug -a "var=hostvars" group_you_want

Show hosts values:
ansible -i env/XXX/hosts -m setup group_you_want

Use another private-key:
ansible -i env/XXX/host --private-key=~/.ssh/anotheruser ....

Jinja all hosts ips:
{% for host in groups['group_you_want'] %}
blablacommand {{ hostvars[host]['ansible_default_ipv4']['address'] }}
{% endfor %}

Ansible and Google Compute Engine

Install dependencies

pip install apache-libcloud

Then install the gcloud. Visit:

Create and Download your service account p12

Convert the p12 format to pem

openssl pkcs12 -in ~/.ssh/foo.p12 -passin pass:notasecret -nodes -nocerts | openssl rsa -out ~/.ssh/foo.pem

To list google images

gcloud compute images list

To list google machine-type

gcloud compute machine-types list

To check your service account mail

Create a playbook

cat > gce_def.yml
- name: Compute Engine demo
  hosts: localhost
  gather_facts: False
    pid: my-first111134
    pem: /etc/ansible/pkey.pem
    - name: Create instance
        instance_names: demo1,demo2
        zone: us-central1-b
        machine_type: n1-standard-1
        image: debian-7-wheezy
        project_id: "{{ pid }}"
        pem_file: "{{ pem }}"
        service_account_email: "{{ email }}"

List running instances

gcloud compute instances list

Install Hue on Hortonworks – Centos 6.7