What is the most effective way to check Samba server availability from a Linux client?
1 Answer
As the comment suggests, test to see if the port is open. But instead of "telnet", using "nc" to just test if the port is open is much easier to check the result:
nc -z remotehost 139 && echo up || echo down
-
Thanks @PBI your advice is much more convenient than, what I used: nmap -p $port $ip | grep --quiet -e "^[0-9]*[/tcpudp ]*closed" :)– atevmCommented Feb 1, 2016 at 13:31
-
I thought the port was 445 and not 139 techcommunity.microsoft.com/t5/storage-at-microsoft/… Commented Nov 10, 2023 at 15:18
telnet <remotehostname> 139
ornmap -p 139 <remotehostname>
should do it. For telnet if you get the message 'telnet: Unable to connect to remote host: Connection refused' then the host does not expose samba to you. see more info on how to test port TCP\139 here: superuser.com/questions/769541/…