Linux: Efficiently test if a port is Open

0 votes
How can I quickly find out whether a port 445 is open/listening on a server from a bash script.

I have tried a couple of options, but I want something quick:
1. lsof -i :445 (Takes seconds)
2. netstat -an |grep 445 |grep LISTEN (Takes seconds)
3. telnet (it doesn't return)
4. nmap, netcat are not available on the server

Is there another way that doesn't enumerate first and greps after that.
Jun 12 in Linux Administration by Upasana
• 8,210 points
16 views

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
0 votes
$ nc -z <host> <port>; echo $?

Use this with 127.0.0.1 as "remote" address.
answered Jun 12 by Shubham
• 12,890 points

Related Questions In Linux Administration

0 votes
1 answer

Linux: Killing a process occupying a particular port

Use the port command to find the ...READ MORE

answered Apr 3 in Linux Administration by DareDev
• 6,710 points
28 views
0 votes
1 answer

Determining whether a given Linux is 32 bit or 64 bit

try this. getconf LONG_BIT Output: 32, if OS is 32 ...READ MORE

answered May 21 in Linux Administration by Upasana
• 8,210 points
11 views
0 votes
1 answer

Which is a good hex editor for Linux?

You could try Bless. It is written ...READ MORE

answered Jun 4 in Linux Administration by Upasana
• 8,210 points
13 views
0 votes
1 answer

How to create a symlink in Linux?

To create a symbolic link, you can ...READ MORE

answered Jan 31 in Linux Administration by Omkar
• 67,000 points
44 views
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

Adding yes/no/cancel prompts in shell script

You can use the read command. Here's ...READ MORE

answered Mar 12 in Linux Administration by ajs3033
• 7,120 points
22 views
0 votes
1 answer

How to change the default shell in Linux?

1. Change the password file directly for ...READ MORE

answered May 24 in Linux Administration by Upasana
• 8,210 points
11 views
0 votes
1 answer

Comparing two string variables in an 'if' statement in Bash

1. For string comparison, use: if [ "$s1" ...READ MORE

answered May 15 in Linux Administration by Shubham
• 12,890 points
37 views
0 votes
1 answer

Removing a symlink to a directory

rm foo try this. Also, You need write ...READ MORE

answered May 15 in Linux Administration by Shubham
• 12,890 points
19 views

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.