Top community members
All Wiki Articles Create Wiki Article

Welcome to Dirask IT community! ❤ 💻
We are community of people that helps each other.

If you are beginner in IT field, you are more then welcome to ask questions, it will help you to learn faster. We are here to help you.

We are always beginner in something, we just need to remember it along the way.

there are no wrong questions - Ask Question

Bash - how to scan open ports with netcat / nc in Debian Linux?

0 contributions
2 points

Using Bash it is possible to scan ports with netcat (nc command) in Debian family Linux in following way.

1. Netcat bash script example script file:



function break_script

trap break_script SIGINT;

for (( i = 1; i < 65535; ++i ))
	nc -z -w 1 "$1" "$i" < /dev/null;

	[ $? -eq 0 ] && echo "Open port $i";
	[ $broken -eq 1 ] && break;


$ ./
Open port 22
Open port 80
Open port 111
Open port 3306
Open port 8005
Open port 8080

Note: if nc command does not exist use following commands:

$ sudo apt-get update
$ sudo apt-get install netcat
0 contributions

Checkout latest Findings & News:

Checkout latest questions:

Checkout latest wiki articles:

Hey 👋
Would you like to know what we do?
  • Dirask is IT community, where we share coding knowledge and help each other to solve coding problems.
  • We welcome everyone,
    no matter what the experience,
    no matter how basic the question is,
    this community will help you.
Read more