SS vs Netstat: Which is Better for Monitoring Network Connections?

Short answer: use ss. netstat is basically legacy now.

Here’s the practical difference without fluff:


ss (Socket Statistics) — Modern tool

  • Part of iproute2 (actively maintained)
  • Much faster (especially on busy servers)
  • Reads kernel data directly (no heavy parsing)
  • Better filtering options

👉 Example:

ss -ant | grep ':443 '

🧓 netstat — Old tool

  • From net-tools (deprecated on many systems)
  • Slower (parses /proc manually)
  • May not be installed by default on newer Linux

👉 Example:

netstat -anp | grep ':443 '

🔍 Real Difference (Important for you)

If your server has high traffic:

  • netstat → slow, can lag, high CPU usage
  • ss → fast, efficient, scalable

📊 Feature Comparison

Featuress ✅netstat ❌
SpeedFastSlow
MaintainedYesNo
Default in LinuxYesOften No
Large trafficHandles wellStruggles

💡 Your Use Case (connection counting)

Best command:

ss -ant state established '( sport = :443 )' | wc -l

More accurate than plain grep.


⚠️ Important Reality

Both ss and netstat:

❌ Do NOT count requests
✅ They count connections

So if you’re trying to measure:

  • Visitors ❌
  • Page views ❌
  • API hits ❌

This approach is misleading.


👍 Recommendation

  • Use ss for server load monitoring
  • Use logs (Nginx/Apache) for real traffic

how to check the configuration of pc in ubuntu

In Ubuntu, you can check your PC configuration (CPU, RAM, GPU, storage, etc.) using both GUI and terminal commands.


🖥️ 1. Simple GUI Method (Easiest)

  • Go to Settings
  • Scroll down → click About

You’ll see:

  • OS version
  • RAM
  • Processor
  • Graphics

💻 2. Terminal Commands (Detailed)

🔹 1. Basic system info

uname -a

🔹 2. CPU details

lscpu

🔹 3. RAM (Memory)

free -h

🔹 4. Full hardware overview

sudo lshw

👉 For short summary:

sudo lshw -short

🔹 5. Disk / Storage info

lsblk

or

df -h

🔹 6. GPU (Graphics)

lspci | grep -i vga

🔹 7. System summary (best all-in-one)

Install:

sudo apt install neofetch

Run:

neofetch

👉 This gives a clean summary (CPU, RAM, GPU, OS, etc.)


🔹 8. Detailed system report (advanced)

sudo apt install inxi
inxi -Fxz

⚡ Pro Tip

If you want a clean screenshot-style output, use:

neofetch

It looks good and is easy to share.

Unix Timestamp Converter & Calculator

What is a Unix Timestamp?

A Unix timestamp (also known as Unix time or POSIX time) represents the number of seconds that have elapsed since January 1, 1970 (UTC). This standardized time representation is widely used in programming and computer systems for tracking time intervals and managing datetime operations.

How to Use This Calculator

  • 1. Choose the conversion direction (Unix timestamp ↔ datetime)
  • 2. Enter your timestamp or datetime value
  • 3. Select your preferred timezone
  • 4. Click ‘Convert’ to see the result
  • 5. Use the copy button to copy the converted value

Common Use Cases

  • Converting log file timestamps
  • Database time management
  • API integration testing
  • Cross-timezone event scheduling
  • System time synchronization

Key Features

  • Instant conversion between Unix timestamps and human-readable dates
  • Support for multiple international timezones
  • Various datetime format options
  • Easy one-click copy functionality
  • Accurate calculations including timezone adjustments

Unix Timestamp Converter & Calculator

  • What is Unix Time?Unix Time is the number of seconds that have elapsed since 00:00:00 UTC on 1 January 1970, also known as the Unix Epoch. It’s widely used in computer systems and programming.
  • How is Unix Time used?Unix Time is used in many programming languages and systems to represent time. It’s particularly useful for storing timestamps, calculating time differences, and synchronizing events across different time zones.
  • What is the difference between Unix Time and UTC?Unix Time is the number of seconds since the Unix Epoch (1970-01-01 00:00:00 UTC), while UTC (Coordinated Universal Time) is the primary time standard by which the world regulates clocks and time.
  • Why do we use Unix Time?Unix Time is used because it’s simple, unambiguous, and independent of time zones. It makes it easy to perform time calculations and comparisons, and it takes up less storage space than formatted dates.
  • What is the Year 2038 problem?The Year 2038 problem refers to when 32-bit Unix Time will overflow on January 19, 2038. After this point, systems using 32-bit Unix Time will need to use 64-bit timestamps or alternative solutions.
  • What is the Unix Epoch?The Unix Epoch is the reference point from which Unix Time is measured: January 1, 1970, at 00:00:00 UTC. This date was chosen for historical reasons related to the development of Unix.
  • Can Unix Time be negative?Yes, Unix Time can be negative for dates before the Unix Epoch (January 1, 1970). For example, December 31, 1969, at 23:59:59 UTC would be -1 in Unix Time.
  • How do leap seconds affect Unix Time?Unix Time ignores leap seconds. It assumes every day has exactly 86,400 seconds, which means it gradually drifts from UTC, which includes leap seconds to stay synchronized with Earth’s rotation.
  • How do time zones affect Unix Time?Unix Time is always in UTC and independent of time zones. When displaying Unix Time in a specific time zone, the conversion happens at the moment of display, not in the stored value.
  • What’s the difference between Unix Time and ISO 8601?Unix Time is a simple count of seconds, while ISO 8601 is a standardized way to represent dates and times as text (e.g., ‘2024-01-01T00:00:00Z’). Both serve different purposes in different contexts.

clean and correct Apache config template for a cPanel server using EasyApache + NGINX Manager where NGINX handles ports

Apache Config Snippet (for /etc/apache2/conf/httpd.conf)

Ensure these ports:

Listen 8080
Listen 8443

Example VirtualHost for HTTP (8080)

<VirtualHost *:8080>
ServerName yourdomain.com
ServerAlias www.yourdomain.com

DocumentRoot /home/username/public_html

<Directory "/home/username/public_html">
AllowOverride All
Options -Indexes +FollowSymLinks
Require all granted
</Directory>

ErrorLog /var/log/apache2/yourdomain.com-error.log
CustomLog /var/log/apache2/yourdomain.com-access.log combined
</VirtualHost>

Example VirtualHost for HTTPS (8443)

<VirtualHost *:8443>
ServerName yourdomain.com
ServerAlias www.yourdomain.com

DocumentRoot /home/username/public_html

SSLEngine on
SSLCertificateFile /var/cpanel/ssl/apache_tls/yourdomain.com/combined
SSLCertificateKeyFile /var/cpanel/ssl/apache_tls/yourdomain.com/privkey

<Directory "/home/username/public_html">
AllowOverride All
Options -Indexes +FollowSymLinks
Require all granted
</Directory>

ErrorLog /var/log/apache2/yourdomain.com-ssl-error.log
CustomLog /var/log/apache2/yourdomain.com-ssl-access.log combined
</VirtualHost>

Replace:

  • yourdomain.com with your actual domain
  • username with the cPanel username
  • SSL paths with correct ones (can get via WHM > Manage SSL Hosts)

Check Ports

After saving and verifying configs:

bashCopyEditnetstat -tulpn | grep -E '8080|8443'

Should show Apache (httpd) listening on these.


Restart Services

bashCopyEdit/scripts/restartsrv_httpd
/scripts/restartsrv_nginx

Test

bashCopyEditcurl -I http://yourdomain.com
curl -I https://yourdomain.com

If NGINX is proxying correctly to Apache, both should return a 200 OK.

EasyApache + Nginx Manager Not Working

Since you’re using EasyApache + NGINX Manager (on cPanel/WHM), Apache and Nginx are working together, where:

  • NGINX acts as a reverse proxy — listening on ports 80 and 443
  • Apache runs behind it — typically on ports like 8080 (HTTP) and 8443 (HTTPS)

Problem:

Your Apache is trying to bind to port 443, but NGINX is already using it, as it should in a reverse proxy setup. Apache should not try to bind to 443 directly.


How to Fix:

Step 1: Check Apache Listening Ports

Run this in SSH:

grep -i listen /etc/apache2/conf/httpd.conf

You should not see Listen 443. If you do, change it to:

Listen 8443

Then restart Apache:

/scripts/restartsrv_httpd

Step 2: Ensure Apache is Set to Run on Alternate Ports (8080/8443)

In WHM:

  1. Go to WHM > Home > Software > NGINX Manager
  2. Click “Settings”
  3. Make sure it says:
    • Apache HTTPS Port: 8443
    • Apache HTTP Port: 8080

If not, update it and save, then restart NGINX and Apache:

/scripts/restartsrv_nginx
/scripts/restartsrv_httpd

Step 3: Check Apache Include Files

Sometimes SSL-related VirtualHosts are misconfigured. Run:

grep -Ri '<VirtualHost' /etc/apache2/conf.d/

Look for entries like:

<VirtualHost *:443>

If found, change to:

<VirtualHost *:8443>

Also ensure SSLEngine on is only in 8443 blocks, not on 443.

Then:

/scripts/restartsrv_httpd

Optional Cleanup Script

If you’d like a quick fix script, here’s a Bash one:

#!/bin/bash
echo "Stopping any stuck Apache processes..."
pkill -f httpd

echo "Checking for anything using port 443..."
lsof -i :443

echo "Restarting NGINX and Apache in proxy mode..."
/scripts/restartsrv_nginx
/scripts/restartsrv_httpd

echo "Done. Check Apache status with: systemctl status httpd"

Save as fix_apache.sh, then run:

chmod +x fix_apache.sh
./fix_apache.sh

Final Step: Confirm it’s Fixed

netstat -tulpn | grep :443

Should show nginx, not apache.

And:

curl -I https://yourdomain.com

Should return 200 OK.

Installing Nginx as a reverse proxy in front of Apache on CentOS 7 involves several steps:

1. Install and Configure Apache:

Install Apache.

Code

    sudo yum install httpd -y
  • Configure Apache to listen on a different port (e.g., 8080) to avoid conflict with Nginx:

Code

    sudo sed -i 's/^Listen 80/Listen 8080/' /etc/httpd/conf/httpd.conf

Start and enable Apache.

Code

    sudo systemctl start httpd
sudo systemctl enable httpd
  • Adjust firewall rules for Apache (if needed):

Code

    sudo firewall-cmd --permanent --add-port=8080/tcp
sudo firewall-cmd --reload

2. Install and Configure Nginx:

Install EPEL repository (required for Nginx).

Code

    sudo yum install epel-release -y

install nginx.

Code

    sudo yum install nginx -y

Configure Nginx as a reverse proxy.

Edit the Nginx configuration file (e.g., /etc/nginx/nginx.conf or a new virtual host file in /etc/nginx/conf.d/):

Code

    server {
listen 80;
server_name your_domain.com; # Replace with your domain or IP

location / {
proxy_pass http://127.0.0.1:8080; # Apache's address and port
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}

Start and enable Nginx.

Code

    sudo systemctl start nginx
sudo systemctl enable nginx

Adjust firewall rules for Nginx.

Code

    sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --permanent --add-service=https # If using SSL/TLS
sudo firewall-cmd --reload

install gnome in ubuntu

To install the GNOME desktop environment on Ubuntu, you can use the ubuntu-gnome-desktop package. First, update your package lists using sudo apt update, then install GNOME with sudo apt install ubuntu-gnome-desktop. After installation, you may need to configure the display manager (e.g., GDM3) to use GNOME as the default session. 

Here’s a more detailed breakdown:

  1. Update your package lists:

Code

   sudo apt update

This ensures you’re working with the latest package information. 

  1. Install GNOME:

Code

   sudo apt install ubuntu-gnome-desktop

This command installs the ubuntu-gnome-desktop package, which provides a complete GNOME desktop experience, including applications like Firefox, LibreOffice, and more, according to wikiHow

  1. (Optional) Install GNOME Tweaks: 

Code

   sudo apt install gnome-tweaks

GNOME Tweaks allows you to further customize your GNOME desktop environment. 

  1. (Optional) Configure the display manager: 

If you want GNOME to be the default login environment, you may need to configure the display manager. For example, if you’re using GDM3, you can run: 

Code

   sudo dpkg-reconfigure gdm3

Select “GNOME” as the default session in the configuration menu. 

  1. Log out and log back in:

Log out of your current session and, at the login screen, select “Ubuntu” or “GNOME” from the session options (usually accessible via a gear icon) to start your new GNOME session. 

how can i know ubuntu version

To find out which version of Ubuntu you are running, you can either use the GUI by navigating to Settings and then About, or the command line by opening a terminal and using the lsb_release -a command. 

Here’s a more detailed explanation:

Using the GUI:

  1. Open the Settings application.
  2. Go to “Details” on the left menu bar.
  3. The Ubuntu version will be displayed in large text below the Ubuntu logo. 

Using the Command Line:

  1. Open a terminal (Ctrl+Alt+T).
  2. Type lsb_release -a and press Enter.
  3. The output will include the Ubuntu version on the “Description:” line. 

Other Methods:

  • cat /etc/issue: This command will print the version information in a single line. 
  • cat /etc/lsb-release: This command will print the contents of the lsb-release file, which also contains version information. 
  • hostnamectl: This command provides various system information, including the Ubuntu version. 

how to customize ubuntu iso image

To customize an Ubuntu ISO image, you can use tools like Cubic or follow a more manual process involving mounting the ISO, modifying files within a chroot environment, and then rebuilding the ISO. Cubic provides a GUI wizard for easier customization, while the manual approach offers more control. 

Using Cubic (GUI Wizard):

  1. Install Cubic: You can install Cubic using a PPA (Personal Package Archive) on your Ubuntu system: 

Code

    sudo apt-add-repository ppa:cubic-wizard/release
sudo apt update
sudo apt install cubic
  1. Open Cubic: Launch Cubic from the application menu.
  2. Create a Custom ISO: Cubic will guide you through the process, allowing you to select the base ISO, customize packages, add/remove software, and more. 
  3. Build the ISO: Cubic will automatically generate a custom ISO file based on your selections. 

Manual Customization (Chroot Environment):

  1. Mount the ISO: Mount the Ubuntu ISO image to a directory, for example:

Code

    sudo mkdir /mnt/iso
sudo mount -o loop /path/to/ubuntu.iso /mnt/iso
  1. Chroot: Create a chroot environment within the mounted ISO: 

Code

    sudo mount -o bind /dev /mnt/iso/dev
sudo mount -o bind /dev/shm /mnt/iso/dev/shm
sudo chroot /mnt/iso
  1. Make Changes: Inside the chroot, you can make various modifications:
    • Install Packages: Use apt-get install to install additional software.
    • Configure Services: Modify configuration files in /etc to adjust services.
    • Add/Remove Users: Use adduser or userdel to manage user accounts.
    • Customize GRUB: Edit /etc/grub.d/ scripts to customize the boot menu.
  2. Rebuild the ISO: After making your changes, you’ll need to rebuild the ISO using tools like Genisoimage or mkisofs
  3. Unmount: Once you’ve rebuilt the ISO, unmount the ISO and chroot environment:

Code

    sudo umount /mnt/iso/dev
sudo umount /mnt/iso/dev/shm
exit # Exit the chroot environment
sudo umount /mnt/iso

Additional Tips:

  • Preseeding:For automated installations, you can create a preseed file (e.g., ubuntu-custom.seed) to answer installation prompts automatically, according to an Ask Ubuntu post
  • Custom Folders:You can add custom folders to the ISO and copy them to the Ubuntu OS during installation. 
  • Testing:It’s always a good idea to test your customized ISO before using it on real hardware or devices. 

SQLSTATE[08004] [1040] Too many connections

How to change max_connections

You can change max_connections while MySQL is running via SET:

mysql> SHOW VARIABLES LIKE "max_connections";
+-----------------+-------+
| Variable_name   | Value |
+-----------------+-------+
| max_connections | 151|
+-----------------+-------+
1 row in set (0.00 sec)

mysql> SET GLOBAL max_connections = 201;
Query OK, 0 rows affected (0.00 sec)

mysql> SHOW VARIABLES LIKE "max_connections";
+-----------------+-------+
| Variable_name   | Value |
+-----------------+-------+
| max_connections | 201|
+-----------------+-------+
1 row in set (0.00 sec)