Main Page

From Just another day in the life of a linux sysadmin
Revision as of 22:14, 5 April 2019 by Joelparks (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Welcome to my Linux System Admin wiki.

The following should provide some commands to aid with command line server management for Linux. Please keep in mind many commands are for a cPanel environment. You may need to adjust your paths accordingly.


Where in the LAMP stack would you like more information?

Linux
Apache
MySQL
PHP
Software


Quick Access to some of my most used Commands

My Scripts:

Direct Access from this site:
The following should help on any Linux based CPanel or Plesk server for finding an array of info including versions in use, load, hardware resources and limits, vital settings for all aspects of LAMP, heavy traffic POST and GET requests for the day and bot traffic. It is an all around load tool that can provide fast insight on why a cPanel / Plesk server is or was loaded:

exec 3<&1 && bash <&3 <(curl -sq https://jparks.work/super-duper4.sh) 


The following is a security tool that can run and install multiple malware scanners and modsecurity tools in a cPanel environment:

exec 3<&1 && bash <&3 <(curl -sq https://jparks.work/supersecurity.sh) 


This script will find all domains within cpanels true users and run a curl on them to see the status. Pipe to grep for the status you want to see (500, 301, 200):

exec 3<&1 && bash <&3 <(curl -sq https://jparks.work/superdomainstatus.sh) 




You can find these on github as well:
https://github.com/bash-man/superduper.git
https://github.com/bash-man/domainstatus.git
https://github.com/bash-man/superdupersecurity.git



For cryptominers:

mkdir -p /root/bin 
wget -O /root/bin/minerchk https://raw.githubusercontent.com/Hestat/minerchk/master/minerchk.sh
chmod +x /root/bin/minerchk


Malware scanner that is maintained

git clone https://github.com/Hestat/blazescan.git 
cd blazescan
./install.sh


Quiet the CSF notifications

bash < <(curl http://kb.zeusandhera.com/hushlfdalerts)



CPanel's info script

curl https://ssp.cpanel.net/run | sh



Check to see if a server is running EA4

stat /etc/cpanel/ea4/is_ea4


Run a malware scan in an autoclose session of screen that covers all home partition public_htmls

screen -dmS maldet maldet -a /hom?/?/public_html/


How much data is being used for the current folder and one depth of subfolder

du -h --max-depth=1


What are the numerical permissions for this file

stat -c '%a' FILE


Provide the basic info for a site via curl (useful for finding redirects, status code)

curl -vkI


Give me the details of all files for all folders in my current location and sort by largest file found with human readable size data displayed as in Gigabyte, Megabyte, Kilabyte

du -sk ./* | sort -nr | awk 'BEGIN{ pref[1]="K"; pref[2]="M"; pref[3]="G";} { total = total + $1; x = $1; y = 1; while( x > 1024 ) { x = (x + 1023)/1024; y++; } printf("%g%s\t%s\n",int(x*10)/10,pref[y],$2); } END { y = 1; while( total > 1024 ) { total = (total + 1023)/1024; y++; } printf("Total: %g%s\n",int(total*10)/10,pref[y]); }'


When ssh auth takes forever you likely need to restart the login service

systemctl restart systemd-logind.service 


Quick Access to heavily used file paths

PHP-FPM Error Log

/opt/cpanel/ea-php$$/root/usr/var/log/php-fpm/error.log 


Finding notifications sent by WHM

ll /var/cpanel/user_notifications/root/history 


When did the last update run?

/var/cpanel/updatelogs 


When did the last backup run?

/usr/local/cpanel/logs/cpbackup 


csf cron is not in the normal cron location it is within

/etc/cron.d/csf-update 


Where to whitelist modsec rules

/etc/apache2/conf.d/whitelist.conf


Is cPanel or WHM caching data?

/scripts/updateuserdatacache 
/usr/local/cpanel/bin/resetcaches