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, 2019 in Linux Administration by Upasana
• 8,620 points
542 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, 2019 by Shubham
• 13,490 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, 2019 in Linux Administration by DareDev
• 6,890 points
1,201 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, 2019 in Linux Administration by Upasana
• 8,620 points
401 views
0 votes
1 answer

Which is a good hex editor for Linux?

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

answered Jun 5, 2019 in Linux Administration by Upasana
• 8,620 points
589 views
0 votes
0 answers

Is there a way to determine the amount of free video RAM in Linux?

We believe that we are running out ...READ MORE

Apr 26, 2022 in Linux Administration by Edureka
• 13,670 points
220 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 13, 2019 in Linux Administration by ajs3033
• 7,300 points
3,960 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, 2019 in Linux Administration by Upasana
• 8,620 points
782 views
0 votes
1 answer
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, 2019 in Linux Administration by Shubham
• 13,490 points
1,261 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP