CentOS 7 Firewall Common Commands

Disabling the Firewall

systemctl disable firewalld

Enabling the Firewall

systemctl disable firewalld

Status of the Firewall

firewall-cmd --state

Allowing Ports

firewall-cmd --permanent --zone=public --add-port=2223/tcp

firewall-cmd --reload

Check Active Zone & Open Ports

firewall-cmd --list-all-zones

Shows Default Zone

firewall-cmd --get-default-zone

Monitor which sites are putting heavy load on a WHM/cPanel Server

For resource tracking purposes it will help if the system is using both SuExec and SuPHP so that CGI and PHP processes run as the appropriate user account and not using the shared system user like that of user “nobody” for Apache.

The following features in WHM may be used to obtain information about CPU, RAM, Apache and MySQL resource utilization; the first tool shown below, Daily Process Log in Server Status, includes daily averages:

WHM: Main >> Server Status >> Daily Process Log

WHM: Main >> Server Status >> Apache Status

WHM: Main >> SQL Services >> Show MySQL Processes

WHM: Main >> System Health >> Show Current CPU Usage

WHM: Main >> System Health >> Show Current Running Processes

Original Source: https://forums.cpanel.net/threads/how-to-determine-which-websites-are-the-busiest.142413/

Free Up Disk Space on Linux System in a Hurry

Stuck with a Linux system with 0% free disk space? If your Linux system is a CentOS system you could try running the following:

yum clean all && rm -f /var/log/messages-* /var/log/cron-* /var/log/secure-* /var/log/spooler-* /var/log/maillog-* /var/log/lastlog-*

What does that command do?

It first clears any temporary files or cache that the yum package manager has stored (harmless to do) it then clears old system log files, it leaves the most recent log files in place and only clears the older archived log files.

Check how much free space is available on your system

Run:

df -h

And you may see an output similar to this (obviously your values may vary):

Filesystem Size Used Avail Use% Mounted on
/dev/vda1 28G 4.5G 22G 17% /
tmpfs 1.9G 0 1.9G 0% /dev/shm

Narrowing down where space is being used

If you have the ‘ncdu’ tool installed on your Linux system then now may be a good time to use it, you could try changing directory to your root path / or /home/ and then using ncdu which will show you visually where your space is being consumed.

Finding and Removing Large error_log Files on Linux

Many of the commands listed on this page are more suited for a server running the WHM / cPanel environment, WHM / cPanel keeps user’s websites and error_log files underneath their /home/ directory.

If you wanted to apply this command to systems that were not using WHM / cPanel then you might change the page mention in the commands below from: /home*/*/public_html/ to be / instead.

Find and Remove

The command below will find and remove error_log files irrespective of their size.

find /home*/*/public_html/ -type f -name "error_log" -exec rm -f {} \;

Find and Remove error_log files only if they are over 50mb

find /home*/*/public_html/ -name "error_log" -size +5000k -exec ls -lah {} \;