Unix-Linux

Netstat

listening ports

netstat syntax

Run netstat command along with grep command to filter out port in LISTEN state

t – Display TCP sockets.
u – Display UDP sockets.
l – Display listening sockets
n – Do now try to resolve names
p – Show process using socket

[root@cen8 ~]# netstat -tulpn | grep LISTEN

[root@cen8 ~]# netstat -tulpn

[root@cen8 ~]# netstat

List all listening ports

Netstat -a

[root@cen8 ~]# netstat -a

List only TCP port connections

[root@cen8 ~]# netstat -at

List only UDP port connections

[root@cen8 ~]# netstat -au

List all actively listening ports

[root@cen8 ~]# netstat -l

Listening TCP

[root@cen8 ~]# netstat -lt

Listening UDP

[root@cen8 ~]# netstat -lu

Netstat + grep

The combination of netstat and grep are very commonly used for finding the number of listening programs on a port. We run the standard netstat -ap and then pipe to grep for a search key. For this example, we will use http:

[root@cen8 ~]# netstat -ap | grep http

Pull statistics by protocol

To pull and view network statistics sorted by protocol

[root@cen8 ~]# netstat -s

TCP Sorting Network Stat

[root@cen8 ~]# netstat -st

UDP Network Stat

[root@cen8 ~]# netstat -su

Display services by Process ID

[root@cen8 ~]# netstat -tp

Show I/O by interface

The -i option is another useful flag for troubleshooting. To view send/receive

Centos/RedHat

Firewall

Firewall Status

After disabled firewall

 [root@cen8 ~]# systemctl status firewalld

After enable firewall

[root@cen8 ~]# systemctl status firewalld

Stop firewall process

[root@cen8 ~]# systemctl stop firewalld

Stop and start firewall

[root@cen8 ~]# systemctl stop firewalld

[root@cen8 ~]# systemctl start firewalld

Apache process and status

Apache HTTPD is an HTTP server daemon produced by the Apache Foundation. It is a piece of software that listens for network requests (which are expressed using the Hypertext Transfer Protocol) and responds to them.

It is open source and many entities use it to host their websites.

Apache Httpd is basically a web server used for handling requests and delivering static content. While CGI is a protocol which adds a scripts with the request and based on the script the content is delivered instead of simply returning a static content. So it is not necessary to use CGI with apache httpd but for delivering a dynnmic content httpd and cgi are used together.

Firewall status

[root@cen8 ~]# firewall-cmd –list-all

[root@cen8 ~]# systemctl status httpd.service

[root@cen8 ~]# systemctl status httpd

[root@cen8 ~]# systemctl start httpd.service

[root@cen8 ~]# systemctl start httpd

[root@cen8 ~]# systemctl stop httpd

Maria DB Database server

Status

[root@rserver8 ~]# systemctl status mariadb

Stop

[root@rserver8 ~]# systemctl stop mariadb

[root@rserver8 ~]# systemctl start mariadb

[root@rserver8 ~]# systemctl restart mariadb.service

MYSQL Server

[root@ rserver8 ~]# systemctl status mysqld

[root@ rserver8 ~]# systemctl stop mysqld

[root@ rserver8 ~]# systemctl start mysqld

[root@ hq ~]# systemctl restart mysqld

Netstat

listening ports

netstat syntax

Run netstat command along with grep command to filter out port in LISTEN state

t – Display TCP sockets.
u – Display UDP sockets.
l – Display listening sockets
n – Do now try to resolve names
p – Show process using socket

[root@cen8 ~]# netstat -tulpn | grep LISTEN

[root@cen8 ~]# netstat -tulpn

[root@cen8 ~]# netstat

List all listening ports

Netstat -a

[root@cen8 ~]# netstat -a

List only TCP port connections

[root@cen8 ~]# netstat -at

List only UDP port connections

[root@cen8 ~]# netstat -au

List all actively listening ports

[root@cen8 ~]# netstat -l

Listening TCP

[root@cen8 ~]# netstat -lt

Listening UDP

[root@cen8 ~]# netstat -lu

Netstat + grep

The combination of netstat and grep are very commonly used for finding the number of listening programs on a port. We run the standard netstat -ap and then pipe to grep for a search key. For this example, we will use http:

[root@cen8 ~]# netstat -ap | grep http

Pull statistics by protocol

To pull and view network statistics sorted by protocol

[root@cen8 ~]# netstat -s

TCP Sorting Network Stat

[root@cen8 ~]# netstat -st

UDP Network Stat

[root@cen8 ~]# netstat -su

Display services by Process ID

[root@cen8 ~]# netstat -tp

Show I/O by interface

The -i option is another useful flag for troubleshooting. To view send/receive

Centos/RedHat

Firewall

Firewall Status

After disabled firewall

 [root@cen8 ~]# systemctl status firewalld

After enable firewall

[root@cen8 ~]# systemctl status firewalld

Stop firewall process

[root@cen8 ~]# systemctl stop firewalld

Stop and start firewall

[root@cen8 ~]# systemctl stop firewalld

[root@cen8 ~]# systemctl start firewalld

Apache process and status

Apache HTTPD is an HTTP server daemon produced by the Apache Foundation. It is a piece of software that listens for network requests (which are expressed using the Hypertext Transfer Protocol) and responds to them.

It is open source and many entities use it to host their websites.

Apache Httpd is basically a web server used for handling requests and delivering static content. While CGI is a protocol which adds a scripts with the request and based on the script the content is delivered instead of simply returning a static content. So it is not necessary to use CGI with apache httpd but for delivering a dynnmic content httpd and cgi are used together.

Firewall status

[root@cen8 ~]# firewall-cmd –list-all

[root@cen8 ~]# systemctl status httpd.service

[root@cen8 ~]# systemctl status httpd

[root@cen8 ~]# systemctl start httpd.service

[root@cen8 ~]# systemctl start httpd

[root@cen8 ~]# systemctl stop httpd

Maria DB Database server

Status

[root@rserver8 ~]# systemctl status mariadb

Stop

[root@rserver8 ~]# systemctl stop mariadb

[root@rserver8 ~]# systemctl start mariadb

[root@rserver8 ~]# systemctl restart mariadb.service

MYSQL Server

[root@ rserver8 ~]# systemctl status mysqld

[root@ rserver8 ~]# systemctl stop mysqld

[root@ rserver8 ~]# systemctl start mysqld

[root@ hq ~]# systemctl restart mysqld

ip command examples

[root@rserver8 ~]# ip addr

[root@rserver8 ~]# ifconfig

[root@rserver8 ~]# ip a

 IPv4 and IPv6

[root@rserver8 ~]# ip -4 a

[root@rserver8 ~]# ip -6 a

Show routing table

To display the contents of the routing tables

[root@rserver8 ~]# ip r

[root@rserver8 ~]# ip r list

[root@rserver8 ~]# ip route list

Output in JSON Format

-j option to display output in a JSON format

-p option which makes the output more readable

[root@rserver8 ~]# ip -p addr

[root@rserver8 ~]# ip -j -p addr

[root@rserver8 ~]# ip -j -p addr show ens33

Enable/Disable the Network Interface

ENABLE Network Interface

User Login History

RedHAT Linux User Login History

[syed@rserver8 ~]$ sudo last -i4

[syed@rserver8 ~]$ sudo last -i20

[syed@rserver8 ~]$ sudo last -i20

Leave a Reply

Your email address will not be published. Required fields are marked *