How to Check Opened Port on Linux VPS Server

By default, the linux operating system manages 65536 ports. If you run Virtual private Server (VPS) on linux platform, it is better to turn off any services or ports that you don’t actually need. This is to ensure your VPS server will not become avenues of attack for any security threats. Simply run these commands to easily see open ports on your Linux VPS server that are currently listening.

1. List opened ports with protocol name :

[root@vps-server ~]# netstat --listen --tcp

Examples :

[root@vps-server ~]# netstat --listen --tcp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address               Foreign Address             State
tcp        0      0 *:mysql                     *:*                         LISTEN
tcp        0      0 *:http                      *:*                         LISTEN
tcp        0      0 *:ftp                       *:*                         LISTEN
tcp        0      0 *:ssh                       *:*                         LISTEN

2. List opened ports with protocol number :

[root@vps-server ~]# netstat --listen --tcp -n

Examples :

[root@vps-server ~]# netstat --listen --tcp -n
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address               Foreign Address             State
tcp        0      0 0.0.0.0:3306                0.0.0.0:*                   LISTEN
tcp        0      0 0.0.0.0:80                  0.0.0.0:*                   LISTEN
tcp        0      0 0.0.0.0:21                  0.0.0.0:*                   LISTEN
tcp        0      0 0.0.0.0:22                  0.0.0.0:*                   LISTEN

How to Check VPS Network Speed

Several important factors to consider before buying a Virtual Private Server (VPS) are Internet connection speed, I/O speed, CPU performance and the server or network uptime. Actually, you can get a complete comparison about the VPS performance at serverbear.com websites, but if you want a second opinion on how fast is your connection speed VPS, you can perform the speedtest by yourself. In this post I will share with you how to check the speed of network for Linux VPS. These steps have been tested on a CentOS 5 and CentOS 6 VPS hosted at different locations in the United States.

1. Test 100MB File on the CentOS 5 VPS located at North Carolina, USA :

# wget -O /dev/null - http://cachefly.cachefly.net/100mb.test

Example :

# wget -O /dev/null - http://cachefly.cachefly.net/100mb.test
--2012-04-19 17:40:00--  http://cachefly.cachefly.net/100mb.test
Resolving cachefly.cachefly.net... 205.234.175.175
Connecting to cachefly.cachefly.net|205.234.175.175|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 104857600 (100M) [application/octet-stream]
Saving to: `/dev/null'

100%[=======================================================>] 104,857,600 11.1M/s   in 9.1s

2012-04-19 17:40:09 (11.0 MB/s) - `/dev/null' saved [104857600/104857600]

FINISHED --2012-04-19 17:40:09--
Downloaded: 1 files, 100M in 9.1s (11.0 MB/s)

100Mbps port = 12.5M/s Maximum speed

2. Test 1GB File on the CentOS 6 VPS located at New York City, USA :

# wget -O /dev/null - http://speedtest.nyc.solvps.com/1GB.zip
--2015-03-08 03:43:25--  http://speedtest.nyc.solvps.com/1GB.zip
Resolving speedtest.nyc.solvps.com... 104.128.230.11
Connecting to speedtest.nyc.solvps.com|104.128.230.11|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1073741824 (1.0G) [application/zip]
Saving to: â/dev/nullâ

100%[====================================>] 1,073,741,824 33.1M/s   in 37s

2015-03-08 03:44:02 (27.8 MB/s) - â/dev/nullâ

FINISHED --2015-03-08 03:44:02--
Downloaded: 1 files, 1.0G in 37s (27.8 MB/s)

1Gigabit port = 125 MB/s Maximum speed

VPS network speed

How to Check Memory Usage on Linux VPS Server

There are several ways on how to check the memory usage on linux virtual Private Server (VPS). This steps has been tested on linux CentOS 6.2 server and may workings on other linux server as well.

1. Check memory usage using “/proc/meminfo” command:

[root@centos62 ~]# cat /proc/meminfo

Output :

MemTotal:        1030888 kB
MemFree:          710372 kB
Buffers:           36444 kB
Cached:           191484 kB
SwapCached:            0 kB
Active:           180552 kB
Inactive:         104976 kB
Active(anon):      58048 kB
Inactive(anon):     2124 kB
Active(file):     122504 kB
Inactive(file):   102852 kB
Unevictable:           0 kB
Mlocked:               0 kB
HighTotal:        141256 kB
HighFree:            280 kB
LowTotal:         889632 kB
LowFree:          710092 kB
SwapTotal:       2064376 kB
SwapFree:        2064376 kB
Dirty:              1388 kB
Writeback:             0 kB
AnonPages:         57628 kB
Mapped:            16512 kB
Shmem:              2564 kB
Slab:              21372 kB
SReclaimable:      15292 kB
SUnreclaim:         6080 kB
KernelStack:        1192 kB
PageTables:         1712 kB
NFS_Unstable:          0 kB
Bounce:                0 kB
WritebackTmp:          0 kB
CommitLimit:     2579820 kB
Committed_AS:     158252 kB
VmallocTotal:     122880 kB
VmallocUsed:        4264 kB
VmallocChunk:     111800 kB
HugePages_Total:       0
HugePages_Free:        0
HugePages_Rsvd:        0
HugePages_Surp:        0
Hugepagesize:       2048 kB
DirectMap4k:       10232 kB
DirectMap2M:      897024 kB

2. Check memory usage using “free -m” command :

[root@centos62 ~]# free -m

Output :

             total       used       free     shared    buffers     cached
Mem:          1006        317        689          0         36        190
-/+ buffers/cache:         90        916
Swap:         2015          0       2015
[root@centos62 ~]#

3. Check memory usage using “top” command :

[root@centos62 ~]# top

Output :

Tasks:  84 total,   1 running,  83 sleeping,   0 stopped,   0 zombie
Cpu(s):  0.5%us,  2.4%sy,  0.0%ni, 96.0%id,  0.8%wa,  0.0%hi,  0.2%si,  0.0%st
Mem:   1030888k total,   324996k used,   705892k free,    37324k buffers
Swap:  2064376k total,        0k used,  2064376k free,   194916k cached

4. Check memory usage using “vmstat” command :

[root@centos62 ~]# vmstat

Output :

procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu-----
 r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa st
 0  0      0 701072  38236 198804    0    0    18    23   88   97  1  3 96  1  0

How to Display the Number of Processors (vCPU) on Linux VPS

Question :

How to display the number of Virtual processor(vCPU) on linux Virtual Private Server (VPS) or Virtual Dedicated Server (VDS) ?

Answer :

To display the number of virtual processor(cpu) on linux vps, you have to run any of this command :

1. This command will display exact number of virtual cpu (vCPU) :

[root@centos62 ~]# cat /proc/cpuinfo | grep processor | wc -l
2

2. This command will grep any available vCPU. First cpu will start with 0.

Example of linux CentOS server with 1 vCPU :

[root@centos62 ~]# cat /proc/cpuinfo | grep processor
processor       : 0

Example of linux CentOS server with 2 vCPU :

[root@centos62 ~]# cat /proc/cpuinfo | grep processor
processor       : 0
processor       : 1

or this command will return the same result as steps (2).

[root@centos62 ~]# grep processor /proc/cpuinfo
processor       : 0

For additional information, you can display the number of cores on each CPU. Either Duo/Quad?

[root@centos62 ~]# cat /proc/cpuinfo |grep cpu\ cores |uniq
cpu cores       : 4