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,410 points
20 views

1 answer to this question.

0 votes
$ nc -z <host> <port>; echo $?

Use this with 127.0.0.1 as "remote" address.
answered Jun 12 by Shubham
• 13,110 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,810 points
29 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,410 points
15 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,410 points
16 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,120 points
49 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,240 points
25 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,410 points
12 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
• 13,110 points
42 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
• 13,110 points
22 views