I learn from Amazon AWS Console that, you can open port by using specific attached security group of an instance and by editing it you can directly alter the port available for communication as mentioned in https://stackoverflow.com/a/10454688/789745.
I'm wondering, if the above can be performed using command line?? I have tried using netstat, nmap, iptables. but not successful so far.