Linux CentOS low on memory – how to tell which user is sucking RAM

To see what users are sucking RAM:

smem -u and smem -u -p tell you exactly which user is using RAM.

Get smem here: https://www.selenic.com/smem/

To see available cached RAM:

If all your memory is getting used, take a closer look to see which memory is being sucked up by disk cache and is actually available instantly to any app that needs it:

free -m or watch free -m to constantly monitor your RAM usage.

Example:

root@niagra [~]# free -m
total       used       free     shared    buffers     cached
Mem:         32101      30831       1270          0        640      27716
-/+ buffers/cache:       2473      29627
Swap:         8191          0       8191

That bolded number is actually what’s available at any time instantaneously.
It’s in the row “+/- buffers/cache” under the column “free”

Memory that is You’d call it Linux calls it
taken by applications Used Used
available for applications, and used for something Free Used
not used for anything Free Free

To release cached memory and get your RAM back:

echo 3 | sudo tee /proc/sys/vm/drop_caches

Then wait 3 seconds and run free -m again, you’ll see the memory was released from cache but this should not be necessary since the column “free” showing on “+/- buffers/cache” didn’t change much.


I also use a variation of “top” called “mem”, it’s an RPM that must be installed.

To turn swap on or off: sudo swapoff -a and sudo swapon -a

To see everything about your RAM: sudo dmidecode -t 17

Posted in Server tips. No Comments »

DNS and MX record checker IP to Domain or Domain Name to IP

http://mxtoolbox.com/SuperToolX.aspx?action=a%3ailagd.org&run=toolpage

Posted in Server tips. No Comments »

WHM remove dedicated IP from websites so you can share the IP

If the IP is already dedicated to a domain/account you will have to first SSH to the server.

Then you want to edit the file /etc/domainips
Remove/delete the line that contains the IP and its current dedicated domain and save.

Next edit the file /var/cpanel/mainips/root
Add the IP you would like to share to a new line and save

At this point you should be able to go into WHM and assign the IP to multiple accounts.

Suggested file permissions for wordpress on an apache server

Please reference this URL for your WordPress sites: https://codex.wordpress.org/Changing_File_Permissions

See section “Shared Hosting with suexec”

In such an suexec configuration, the correct permissions scheme is simple to understand.

• All files should be owned by the actual user’s account, not the user account used for the httpd process.
• Group ownership is irrelevant, unless there’s specific group requirements for the web-server process permissions checking. This is not usually the case.
All directories should be 755 or 750.
• All files should be 644 or 640. Exception: wp-config.php should be 440 or 400 to prevent other users on the server from reading it.
• No directories should ever be given 777, even upload directories. Since the php process is running as the owner of the files, it gets the owners permissions and can write to even a 755 directory.

chmod directories recursively – change permissions on folders and files for tight security on wordpress

find /home/username/public_html -type d -exec chmod 750 {} \;

To chmod files recursively using find:
find /home/username/public_html -type f -exec chmod 640 {} \;
(for higher security on wordpress)
 

Whois – How to tell what hosting company a website is using

https://who.is/whois/typeyourdomainnamehere.com

Posted in Server tips. No Comments »

Apache fasstcgi mods

I run suExec so each account will run as the owner of the account.

Fastcgi mods added to the Apache post_virtualhost_global.conf (WHM>Service Configuration>Apache Configuration>Post VirtualHost Include>All Versions)

<IfModule fcgid_module>
FcgidMaxRequestLen 52428800
</IfModule>

<IfModule mod_fcgid.c>
FcgidMaxProcesses 150
FcgidMaxProcessesPerClass 100
FcgidIOTimeout 300
FcgidMinProcessesPerClass 1
FcgidIdleTimeout 300
FcgidIdleScanInterval 120
FcgidBusyTimeout 300
FcgidBusyScanInterval 120
FcgidErrorScanInterval 10
FcgidZombieScanInterval 3
FcgidProcessLifeTime 3600
</IfModule>

Fix Heartbleed bug by quick update for openSSL on apache

yum update openssl* -y
This will update openSSL to the newest version for apache on CentOS

To check your server to see if it’s vulnerable to the Heartbleed bug: https://www.ssllabs.com/ssltest/

chown all files on a website to change owner

chown -v -R registration:registration public_html

The first part registration: is the group the second part :registration is the owner

-v is verbose

-R is recursive

So this will change the group and owner of every file and folder nested inside public_html

Locked out of my own firewall

CSF is the first culprit if you are locked out of your own server firewall after too many failed login attempts from a certain IP.

The block was in your firewall, not cpHulk.
The IP was listed in /etc/csf/csf.deny and /var/lib/csf/csf.tempip and /var/lib/csf/csf.tempban
You can whitelist the IP in your firewall by placing the IP in /etc/csf/csf.allow, then running csf -r

Next you can place your external IP in the whitelist of cPHulk:

WHM > Security Center > cPHulk brute force protection > White/Black list > Quick Add your current external IP to: White List (Trusted IP List)

To find your external IP:

http://cmyip.com