Main Page: Difference between revisions

From Cheatsheet
Jump to navigation Jump to search
No edit summary
No edit summary
Line 121: Line 121:
[[User:Admin|Admin]]flush exim queue
[[User:Admin|Admin]]flush exim queue
exim -bpr | awk {'print $3'} | xargs exim -Mrm
exim -bpr | awk {'print $3'} | xargs exim -Mrm
                                                      <h1> APF</h1>
[[User:Admin|Admin]]Apf un block
vi /etc/apf/deny_hosts.rules
/etc/init.d/apf restart
[[User:Admin|Admin]]# of attemps
vi /usr/local/bfd/conf.bfd
[[User:Admin|Admin]]Starting APF:Unable to load iptables module (ipt_state), aborting.
vi /etc/apf/conf.apf
SET_MONOKERN change to 1
/etc/init.d/apf restart
<h1>IPTABLES</h1>
[[User:Admin|Admin]]block temp with IPtables
iptables -I INPUT 1 -s ipaddress -j DROP
[[User:Admin|Admin]]block permanently with APF
/etc/apf/deny_hosts.rules
                                                      <h1>Load checking</h1>
[[User:Admin|Admin]]listening on port
lsof -i :25
[[User:Admin|Admin]]Total connections on port 80
netstat -nap |grep -c :80
[[User:Admin|Admin]]rough per sec hits
/usr/bin/lynx -dump -width 500 http://127.0.0.1/whm-server-status | grep GET | awk '{print $12}' | sort | uniq -c | sort -rn | head
[[User:Admin|Admin]]Tells how many are using port 80
netstat -tn 2>/dev/null | grep :80 | awk '{print $5}' | cut -f1 -d: | sort | uniq -c | sort -rn | head
                                                      <h1>HTTPD and APACHE</h1>
to distill changes to the httpd.conf
/usr/local/cpanel/bin/apache_conf_distiller --update
apache uptime
/usr/bin/lynx -dump -width 500  http://127.0.0.1/whm-server-status
                                                      <h1>PHP</h1>
PHP info
<?php phpinfo(); ?>
PHP version
/usr/local/cpanel/bin/rebuild_phpconf --current
PHP 4 module check
/usr/local/php4/bin/php
Suphp permission fix
wget -O /scripts/suphpfix.pl http://layer3.liquidweb.com/scripts/suphpfix.pl
chmod +x /scripts/suphpfix.pl
/scripts/suphpfix.pl
enable/disable monitoring script ---
wget http://scripts.ssullivan.org/apiCalls/confMonitoring
perl confMonitoring
PhP mem limit on a shared with dso goes into the public_html in the .htaccess
php_value memory_limit 64M
veiw availiable php upgrades
/scripts/phpextensionmgr list
install php upgrade
/scripts/phpextensionmgr install (name here)
                                                    <h1>MYSQL</h1>
to backup all databases to remote location
mkdir /home/sqlbackup
for db in `mysql -s -B -e "show databases"`;do mysqldump $db > /home/sqlbackup/$db.sql.(version number here);done
repair a crashed MYISAM table
stop chkservd and mysql
/usr/local/cpanel/bin/tailwatchd --disable=Cpanel::TailWatch::ChkServd
/etc/init.d/mysql stop
then do
myisamchk -r /var/lib/mysql/(databasename)/(tablename)
/etc/init.d/mysql start
/usr/local/cpanel/bin/tailwatchd --enable=Cpanel::TailWatch::ChkServd
"MySQL server has gone away" fix
increase wait_timeout and max_allowed_packet in
vim /etc/my.cnf
/etc/init.d/mysql stop
/etc/init.d/mysql start
Correct way to upgrade mysql in cpanel box
vim /var/cpanel/cpanel.config
mysql=version you want
/usr/local/cpanel/whostmgr/bin/whostmgr2 --updatetweaksettings
mkdir /home/sqlbackup
for db in `mysql -s -B -e "show databases"`;do mysqldump $db > /home/sqlbackup/$db.sql.(old mysql version number here);done
/scripts/mysqlup
mysqladmin version
/scripts/easyapache
Myqsl packages are installed
rpm -qa | grep SQL | grep -vi perl
Force perl update
/scripts/perlinstaller --force Bundle::DBD::mysql
what mysql version
mysqladmin version
Mysql database location
cd /var/lib/mysql
imports a dumped file
mysql database < db-dump-file.sql
Mysqldump
mysqldump dbname > dbname.sql
<h1>Stats</h1>
update all stats
for user in `ls -A /var/cpanel/users`; do /scripts/runweblogs $user ;done

Revision as of 19:05, 29 March 2010

This is my wiki, containing all of my shortcuts.

System specs

tells the system bit

uname -a

What linux version and release

cat /etc/redhat-release

VPS parent sudo rights

sudo su

OwnerShip

Tell what group number owner is

cat /etc/passwd | grep nobody

Group

add user to group

useradd -G {group-name} username

Permissions

find 777 folders

find /home -perm 0777 -type d -print

Disable root login

useradd lwstaff passwd (assign a password) useradd -G wheel lwstaff vim /etc/ssh/sshd_config change PermitRootLogin to no and uncomment it. restart sshd and test your work.


LIST

Adminlist by last mmodified ls -lt

Adminlist by Proc id lsof -p PID

VI commands

Adminadd line numbers

set number

Adminremove line numbers

set nonumber

ModRewrite

Adminredirect Make sure mod_rewrite is on in the httpd.conf Options +FollowSymlinks RewriteEngine on rewritecond %{http_host} ^domain.com [nc] rewriterule ^(.*)$ http://www.domain.com/$1 [r=301,nc]

MODSEC

AdminRemove specified directory from modsec SecRule REQUEST_URI "URI goes here" phase:1,nolog,allow,ctl:ruleEngine=Off Adminadd to this file and restart vi /usr/local/apache/conf/modsec2/whitelist.conf /etc/init.d/httpd restart /etc/init.d/apf restart

AdminRemove a whole domain SecRule SERVER_NAME "handymanreality.com" phase:1,nolog,allow,ctl:ruleEngine=Off


/wp-admin/post.php


inventorymanagement.com

RPM

AdminRpm src packages go here /usr/local/src/

Adminremove old kernal srcs rpm -qa | grep kernel-source | xargs rpm -e

AdminRpm remove installed packages rpm -e --nodeps {package name here}

Email

Adminhorde mail update (nothing can be in account of will all get erased) /usr/local/cpanel/bin/update-horde --force

AdminTo determine mailserver type /scripts/setupmailserver --current

Admincount mail in folder ls | wc -l

Adminremoving mass spam rm -Rf /home/(user here}/mail/cur*

Adminspam removel script for i in $(find . | xargs grep -m 1 -s -i "Mailer-Daemon" | sed -e 's/\.\/[A-Z0-9a-z]\/\([A-Z0-9a-z\-]\{16\}\)\-[HDJ].*/\1/'); do exim -Mrm $i;done


SPAMD

AdminSPAMD failing /scripts/perlinstaller Digest::SHA1 /scripts/perlinstaller --force Mail::SpamAssassin /etc/rc.d/init.d/exim restart /scripts/restartsrv spamd

EXIM

Adminnumber of msg in q exim -bpc

Adminprint msg q summary exim -bp | exiqsumm

Adminstart a full q run exim -q -v

Adminstart a local delivery q run exim -ql -v

Adminflush exim queue exim -bpr | awk {'print $3'} | xargs exim -Mrm

APF

AdminApf un block vi /etc/apf/deny_hosts.rules /etc/init.d/apf restart

Admin# of attemps vi /usr/local/bfd/conf.bfd

AdminStarting APF:Unable to load iptables module (ipt_state), aborting. vi /etc/apf/conf.apf SET_MONOKERN change to 1 /etc/init.d/apf restart

IPTABLES

Adminblock temp with IPtables iptables -I INPUT 1 -s ipaddress -j DROP

Adminblock permanently with APF /etc/apf/deny_hosts.rules

Load checking

Adminlistening on port lsof -i :25

AdminTotal connections on port 80 netstat -nap |grep -c :80

Adminrough per sec hits /usr/bin/lynx -dump -width 500 http://127.0.0.1/whm-server-status | grep GET | awk '{print $12}' | sort | uniq -c | sort -rn | head

AdminTells how many are using port 80 netstat -tn 2>/dev/null | grep :80 | awk '{print $5}' | cut -f1 -d: | sort | uniq -c | sort -rn | head

HTTPD and APACHE

to distill changes to the httpd.conf /usr/local/cpanel/bin/apache_conf_distiller --update

apache uptime /usr/bin/lynx -dump -width 500 http://127.0.0.1/whm-server-status

PHP

PHP info <?php phpinfo(); ?>

PHP version /usr/local/cpanel/bin/rebuild_phpconf --current

PHP 4 module check /usr/local/php4/bin/php

Suphp permission fix wget -O /scripts/suphpfix.pl http://layer3.liquidweb.com/scripts/suphpfix.pl chmod +x /scripts/suphpfix.pl /scripts/suphpfix.pl


enable/disable monitoring script --- wget http://scripts.ssullivan.org/apiCalls/confMonitoring perl confMonitoring

PhP mem limit on a shared with dso goes into the public_html in the .htaccess php_value memory_limit 64M

veiw availiable php upgrades /scripts/phpextensionmgr list

install php upgrade /scripts/phpextensionmgr install (name here)

MYSQL

to backup all databases to remote location mkdir /home/sqlbackup for db in `mysql -s -B -e "show databases"`;do mysqldump $db > /home/sqlbackup/$db.sql.(version number here);done

repair a crashed MYISAM table stop chkservd and mysql /usr/local/cpanel/bin/tailwatchd --disable=Cpanel::TailWatch::ChkServd /etc/init.d/mysql stop then do myisamchk -r /var/lib/mysql/(databasename)/(tablename) /etc/init.d/mysql start /usr/local/cpanel/bin/tailwatchd --enable=Cpanel::TailWatch::ChkServd

"MySQL server has gone away" fix

increase wait_timeout and max_allowed_packet in vim /etc/my.cnf /etc/init.d/mysql stop /etc/init.d/mysql start

Correct way to upgrade mysql in cpanel box vim /var/cpanel/cpanel.config mysql=version you want /usr/local/cpanel/whostmgr/bin/whostmgr2 --updatetweaksettings mkdir /home/sqlbackup for db in `mysql -s -B -e "show databases"`;do mysqldump $db > /home/sqlbackup/$db.sql.(old mysql version number here);done /scripts/mysqlup mysqladmin version /scripts/easyapache

Myqsl packages are installed rpm -qa | grep SQL | grep -vi perl Force perl update /scripts/perlinstaller --force Bundle::DBD::mysql

what mysql version mysqladmin version

Mysql database location cd /var/lib/mysql

imports a dumped file mysql database < db-dump-file.sql

Mysqldump mysqldump dbname > dbname.sql

Stats

update all stats for user in `ls -A /var/cpanel/users`; do /scripts/runweblogs $user ;done