Tag Archives: bash

Execute a command on every file inside current directory

for file in `find -maxdepth 1 -type f`; do echo -n > $file; done

using “netcat” as a port scanner on linux

There are certain time when you need to do a port scan on a remote host in a Linux shell. There are many scripts flying all over the internet giving you this ability; but wait! There’s a native way to do this.

The “netcat” command [perhaps you’ll need to install it using yum or whatever installation method you prefer] can do the job really nice!
nc <host-name-or-ip-address> -z -w 1 <start-port>-<end-port>

nc -z -w 1 1-65535
this will scan for ports from 1 to 65536 on and will wait 1 second before throwing a timeout for every port being checked.

Nice trick, wasn’t it?