Skip to main content

Who is connecting to linux server

netstat -tn

-n: Display numeric only

-t: Display TCP connections only



Who is connected to my linux host - netstat -tn
Who is connecting to linux host: netstat -tn

netstat is not installed on CentOS/RHEL minimal installation by default.

[tuyendq@001 ~]$ which netstat
/usr/bin/which: no netstat in (/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/home/tuyendq/.local/bin:/home/tuyendq/bin)

Which package does netstat belong to?

[tuyendq@001 ~]$ yum search netstat
Loaded plugins: fastestmirror
Determining fastest mirrors
 * base: mirror.hostduplex.com
 * epel: mirrors.develooper.com
 * extras: repos.lax.quadranet.com
 * updates: mirror.hostduplex.com
zabbix-non-supported                                                                                                4/4
=================================================== Matched: netstat ===================================================
bwm-ng.x86_64 : Bandwidth Monitor NG
dstat.noarch : Versatile resource statistics tool
net-snmp.x86_64 : A collection of SNMP protocol tools and libraries
net-tools.x86_64 : Basic networking tools
python2-psutil.x86_64 : A process and system utilities module for Python
python34-psutil.x86_64 : A process and system utilities module for Python
python36-psutil.x86_64 : A process and system utilities module for Python
unhide.x86_64 : Tool to find hidden processes and TCP/UDP ports from rootkits

Install net-tools package in order to use netstat

[tuyendq@001 ~]$ sudo yum install -y net-tools
[sudo] password for tuyendq:
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirror.scalabledns.com
 * epel: mirrors.develooper.com
 * extras: mirror.scalabledns.com
 * updates: mirrors.usc.edu
Resolving Dependencies
--> Running transaction check
---> Package net-tools.x86_64 0:2.0-0.24.20131004git.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

========================================================================================================================
 Package                   Arch                   Version                                    Repository            Size
========================================================================================================================
Installing:
 net-tools                 x86_64                 2.0-0.24.20131004git.el7                   base                 306 k

Transaction Summary
========================================================================================================================
Install  1 Package

Total download size: 306 k
Installed size: 918 k
Downloading packages:
net-tools-2.0-0.24.20131004git.el7.x86_64.rpm                                                    | 306 kB  00:00:01
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : net-tools-2.0-0.24.20131004git.el7.x86_64                                                            1/1
  Verifying  : net-tools-2.0-0.24.20131004git.el7.x86_64                                                            1/1

Installed:
  net-tools.x86_64 0:2.0-0.24.20131004git.el7

Complete!

Check netstat version

[tuyendq@001 ~]$ netstat --version
net-tools 2.10-alpha
Fred Baumgarten, Alan Cox, Bernd Eckenfels, Phil Blundell, Tuan Hoang, Brian Micek and others
+NEW_ADDRT +RTF_IRTT +RTF_REJECT +FW_MASQUERADE +I18N +SELINUX
AF: (inet) +UNIX +INET +INET6 +IPX +AX25 +NETROM +X25 +ATALK +ECONET +ROSE -BLUETOOTH
HW:  +ETHER +ARC +SLIP +PPP +TUNNEL -TR +AX25 +NETROM +X25 +FR +ROSE +ASH +SIT +FDDI +HIPPI +HDLC/LAPB +EUI64
[tuyendq@001 ~]$

Check open ports with netstat, ss, lsof

netstat -tupln | grep LISTEN
sudo ss -tupln | grep LISTEN
sudo lsof -i -P -n | grep LISTEN

Popular posts from this blog

Linux command: Check Current Shell

What is your current shell ?

Java: Free Online Courses

The Java™ Tutorials by Oracle The Java Tutorials are practical guides for programmers who want to use the Java programming language to create applications. They include hundreds of complete, working examples, and dozens of lessons. Groups of related lessons are organized into "trails". https://docs.oracle.com/javase/tutorial/ Learn to Program in Java at edX.ogr Get started on the path to becoming a software engineer by learning core coding skills in Java—one of the most popular programming languages. https://www.edx.org/course/learn-to-program-in-java-0 Java Tutorial by javapoint.com https://www.javatpoint.com/java-tutorial Java Tutorial by SoloLearn.com I love SoloLearn because I can learn Java - and other popular programming languages - anywhere, any time on your mobile devices. https://www.sololearn.com/Course/Java/ Java on Azure https://docs.microsoft.com/en-us/learn/paths/java-on-azure/

Powershell: Get-ChildItem

List, search/find files and directories with Get-ChildItem cmdlet.