Main Page: Difference between revisions
No edit summary |
No edit summary |
||
Line 7: | Line 7: | ||
What linux version and release | What linux version and release | ||
<pre>cat /etc/redhat-release</pre> | <pre>cat /etc/redhat-release</pre> | ||
<h1>VPS parent sudo rights</h1> | <h1><center>VPS parent sudo rights</center></h1> | ||
Get root fight when logged in using LDAP | Get root fight when logged in using LDAP | ||
<pre>sudo su</pre> | <pre>sudo su</pre> | ||
<h1>OwnerShip</h1> | <h1><center>OwnerShip</center></h1> | ||
Tell what group number owner is | Tell what group number owner is | ||
<pre>cat /etc/passwd | grep nobody</pre> | <pre>cat /etc/passwd | grep nobody</pre> | ||
<h1>Group</h1> | <h1><center>Group</center></h1> | ||
Add user to group | Add user to group | ||
<pre>useradd -G {group-name} username</pre> | <pre>useradd -G {group-name} username</pre> | ||
<h1>Permissions</h1> | <h1><center>Permissions</center></h1> | ||
Find 777 folders | Find 777 folders | ||
<pre>find /home -perm 0777 -type d -print</pre> | <pre>find /home -perm 0777 -type d -print</pre> | ||
<h1>Disable root login</h1> | <h1><center>Disable root login</center></h1> | ||
<pre> | <pre> | ||
useradd lwstaff | useradd lwstaff | ||
Line 34: | Line 34: | ||
<h1> LIST</h1> | <h1><center> LIST</center></h1> | ||
list by last modified | list by last modified | ||
<pre>ls -lt</pre> | <pre>ls -lt</pre> | ||
Line 41: | Line 41: | ||
<pre>lsof -p PID</pre> | <pre>lsof -p PID</pre> | ||
<h1>VI commands</h1> | <h1><center>VI commands</center></h1> | ||
Add line numbers | Add line numbers | ||
<pre>:set number</pre> | <pre>:set number</pre> | ||
Line 48: | Line 48: | ||
<pre>:set nonumber</pre> | <pre>:set nonumber</pre> | ||
<h1>ModRewrite</h1> | <h1><center>ModRewrite</center></h1> | ||
redirect | redirect | ||
Make sure mod_rewrite is on in the httpd.conf | Make sure mod_rewrite is on in the httpd.conf | ||
Line 56: | Line 56: | ||
rewriterule ^(.*)$ http://www.domain.com/$1 [r=301,nc]</pre> | rewriterule ^(.*)$ http://www.domain.com/$1 [r=301,nc]</pre> | ||
<h1>MODSEC</h1> | <h1><center>MODSEC</center></h1> | ||
Remove specified directory from modsec | Remove specified directory from modsec | ||
<pre>SecRule REQUEST_URI "URI goes here" phase:1,nolog,allow,ctl:ruleEngine=Off</pre> | <pre>SecRule REQUEST_URI "URI goes here" phase:1,nolog,allow,ctl:ruleEngine=Off</pre> | ||
Line 72: | Line 72: | ||
</pre> | </pre> | ||
<h1> RPM</h1> | <h1> <center>RPM</center></h1> | ||
Rpm src packages go here | Rpm src packages go here | ||
<pre>/usr/local/src/</pre> | <pre>/usr/local/src/</pre> | ||
Line 81: | Line 81: | ||
Rpm remove installed packages | Rpm remove installed packages | ||
<pre>rpm -e --nodeps {package name here}</pre> | <pre>rpm -e --nodeps {package name here}</pre> | ||
<h1>Email</h1> | <h1><center>Email</center></h1> | ||
horde mail update (nothing can be in account of will all get erased) | horde mail update (nothing can be in account of will all get erased) | ||
Line 99: | Line 99: | ||
</pre> | </pre> | ||
<h1>SPAMD</h1> | <h1><center>SPAMD</center></h1> | ||
SPAMD failing | SPAMD failing | ||
Line 107: | Line 107: | ||
/scripts/restartsrv spamd</pre> | /scripts/restartsrv spamd</pre> | ||
<h1>EXIM</h1> | <h1><center>EXIM</center></h1> | ||
number of msg in q | number of msg in q | ||
Line 123: | Line 123: | ||
Flush exim queue | Flush exim queue | ||
<pre>exim -bpr | awk {'print $3'} | xargs exim -Mrm</pre> | <pre>exim -bpr | awk {'print $3'} | xargs exim -Mrm</pre> | ||
<h1> APF</h1> | <h1><center> APF</center></h1> | ||
Apf un block | Apf un block | ||
<pre>vi /etc/apf/deny_hosts.rules | <pre>vi /etc/apf/deny_hosts.rules | ||
Line 136: | Line 136: | ||
/etc/init.d/apf restart</pre> | /etc/init.d/apf restart</pre> | ||
<h1>IPTABLES</h1> | <h1><center>IPTABLES</center></h1> | ||
Block temp with IPtables | Block temp with IPtables | ||
<pre>iptables -I INPUT 1 -s ipaddress -j DROP</pre> | <pre>iptables -I INPUT 1 -s ipaddress -j DROP</pre> | ||
Line 143: | Line 143: | ||
<pre>/etc/apf/deny_hosts.rules</pre> | <pre>/etc/apf/deny_hosts.rules</pre> | ||
<h1>Load checking</h1> | <h1><center>Load checking</center></h1> | ||
Listening on port | Listening on port | ||
<pre>lsof -i :25 | <pre>lsof -i :25 | ||
Line 156: | Line 156: | ||
<pre>netstat -tn 2>/dev/null | grep :80 | awk '{print $5}' | cut -f1 -d: | sort | uniq -c | sort -rn | head | <pre>netstat -tn 2>/dev/null | grep :80 | awk '{print $5}' | cut -f1 -d: | sort | uniq -c | sort -rn | head | ||
<h1>HTTPD and APACHE</h1> | <h1><center>HTTPD and APACHE</center></h1> | ||
to distill changes to the httpd.conf | to distill changes to the httpd.conf | ||
<pre>/usr/local/cpanel/bin/apache_conf_distiller --update | <pre>/usr/local/cpanel/bin/apache_conf_distiller --update | ||
Line 163: | Line 163: | ||
<pre>/usr/bin/lynx -dump -width 500 http://127.0.0.1/whm-server-status</pre> | <pre>/usr/bin/lynx -dump -width 500 http://127.0.0.1/whm-server-status</pre> | ||
<h1>PHP</h1> | <h1><center>PHP</center></h1> | ||
PHP info | PHP info | ||
<pre><?php phpinfo(); ?> </pre> | <pre><?php phpinfo(); ?> </pre> | ||
Line 192: | Line 192: | ||
<pre>/scripts/phpextensionmgr install (name here)</pre> | <pre>/scripts/phpextensionmgr install (name here)</pre> | ||
<h1>MYSQL</h1> | <h1><center>MYSQL</center></h1> | ||
To backup all databases to remote location | To backup all databases to remote location | ||
<pre>mkdir /home/sqlbackup | <pre>mkdir /home/sqlbackup | ||
Line 235: | Line 235: | ||
Mysqldump | Mysqldump | ||
<pre>mysqldump dbname > dbname.sql</pre> | <pre>mysqldump dbname > dbname.sql</pre> | ||
<h1>Stats</h1> | <h1><center>Stats</center></h1> | ||
update all stats | update all stats | ||
<pre>for user in `ls -A /var/cpanel/users`; do /scripts/runweblogs $user ;done</pre> | <pre>for user in `ls -A /var/cpanel/users`; do /scripts/runweblogs $user ;done</pre> | ||
<h1>Ports</h1> | <h1><center>Ports</center></h1> | ||
Bindings | Bindings | ||
<pre>netstat -lnc</pre> | <pre>netstat -lnc</pre> | ||
<h1>Top</h1> | <h1><center>Top</center></h1> | ||
sort by memory | sort by memory | ||
<pre>shift - m </pre> | <pre>shift - m </pre> | ||
sort by processor usage | sort by processor usage | ||
<pre>shift - p</pre> | <pre>shift - p</pre> | ||
<h1>MR Radar</h1> | <h1><center>MR Radar</center></h1> | ||
Install mr radar | Install mr radar | ||
<pre>lpyum install mm3k-client-pull</pre> | <pre>lpyum install mm3k-client-pull</pre> | ||
<h1>Rdesktop</h1> | <h1><center>Rdesktop</center></h1> | ||
<pre>rdesktop (servername here) -u mshooltz -p (passhere) &</pre> | <pre>rdesktop (servername here) -u mshooltz -p (passhere) &</pre> | ||
<h1>SSl locations</h1> | <h1><center>SSl locations</center></h1> | ||
<pre> | <pre> | ||
/usr/share/ssl | /usr/share/ssl | ||
/etc/ssl/certs | /etc/ssl/certs | ||
</pre> | </pre> | ||
<h1>Empty files</h1> | <h1><center>Empty files</center></h1> | ||
To create a empty file that takes so much spce for testing uploads. | To create a empty file that takes so much spce for testing uploads. | ||
<pre>dd if=/dev/zero of=file1G.tmp bs=1G count=1</pre> | <pre>dd if=/dev/zero of=file1G.tmp bs=1G count=1</pre> | ||
<h1>Index blocking</h1> | <h1><center>Index blocking</center></h1> | ||
Blocks the index of / from being seen. Remove the +a- to make visable again. | Blocks the index of / from being seen. Remove the +a- to make visable again. | ||
<pre>Options +Indexes +a-</pre> | <pre>Options +Indexes +a-</pre> | ||
<h1>CPANEL</h1> | <h1><center>CPANEL</center></h1> | ||
Cpanel gives this error | Cpanel gives this error | ||
[a fatal error or timeout occurred while processing this directive] | [a fatal error or timeout occurred while processing this directive] | ||
Line 283: | Line 279: | ||
<h1>ChkServd</h1> | <h1><center>ChkServd</center></h1> | ||
enable chkservd | enable chkservd | ||
<pre>/usr/local/cpanel/bin/tailwatchd --enable=Cpanel::TailWatch::ChkServd</pre> | <pre>/usr/local/cpanel/bin/tailwatchd --enable=Cpanel::TailWatch::ChkServd</pre> | ||
Disable chkservd | Disable chkservd | ||
<pre>/usr/local/cpanel/bin/tailwatchd --disable=Cpanel::TailWatch::ChkServd</pre> | <pre>/usr/local/cpanel/bin/tailwatchd --disable=Cpanel::TailWatch::ChkServd</pre> | ||
<h1>Fantastico</h1> | <h1><center>Fantastico</h1> | ||
add the Fantastico installer plugin | add the Fantastico installer plugin | ||
Line 296: | Line 292: | ||
rm -rf fantastico_whm_admin.tgz</pre> | rm -rf fantastico_whm_admin.tgz</pre> | ||
<h1>Python</h1> | <h1><center>Python</center></h1> | ||
find python version | find python version | ||
<pre>python -V</pre> | <pre>python -V</pre> | ||
<h1>SED</h1> | <h1><center>SED</center></h1> | ||
replace this with THIS | replace this with THIS | ||
<pre>sed -i 's/(this)/(THIS)/g' path/filename</pre> | <pre>sed -i 's/(this)/(THIS)/g' path/filename</pre> | ||
<h1>Premigrations</h1> | <h1><center>Premigrations</center></h1> | ||
Lower ttls and serial changes | Lower ttls and serial changes | ||
<pre>wget http://layer3.liquidweb.com/migrations/premigrate.sh | <pre>wget http://layer3.liquidweb.com/migrations/premigrate.sh | ||
Line 310: | Line 306: | ||
<h1>SCP</h1> | <h1><center>SCP</center></h1> | ||
<pre>scp {file} root@(servers ip here):/home/ </pre> | <pre>scp {file} root@(servers ip here):/home/ </pre> | ||
<h1>Rsync</h1> | <h1>Rsync</h1> | ||
Line 320: | Line 316: | ||
rsync -avHl /backup/_bacckup-/home/(username)/public_html/ /home/(username)/public_html/</pre> | rsync -avHl /backup/_bacckup-/home/(username)/public_html/ /home/(username)/public_html/</pre> | ||
<h1>For loops and other loops</h1> | <h1><center>For loops and other loops</center></h1> | ||
ALWAYS RUN THIS FIRST!!!!! | ALWAYS RUN THIS FIRST!!!!! | ||
<pre>unalias ls</pre> | <pre>unalias ls</pre> | ||
Line 330: | Line 326: | ||
<pre>while x=0; do killall -9 php5; sleep .1; done</pre> | <pre>while x=0; do killall -9 php5; sleep .1; done</pre> | ||
<h1>History Removal commands</h1> | <h1><center>History Removal commands</center></h1> | ||
run this for a I was never in the box situation. | run this for a I was never in the box situation. | ||
<pre>echo "" > /var/log/messages && echo "" /var/log/secure | <pre>echo "" > /var/log/messages && echo "" /var/log/secure | ||
history -c && echo "" > /var/log/wtmp && echo "" > /var/log/lastlog</pre> | history -c && echo "" > /var/log/wtmp && echo "" > /var/log/lastlog</pre> |
Revision as of 02:33, 30 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
Get root fight when logged in using LDAP
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
list by last modified
ls -lt
list by Proc id
lsof -p PID
VI commands
Add line numbers
:set number
remove line numbers
:set nonumber
ModRewrite
redirect 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
Remove specified directory from modsec
SecRule REQUEST_URI "URI goes here" phase:1,nolog,allow,ctl:ruleEngine=Off
Add to this file and restart
vi /usr/local/apache/conf/modsec2/whitelist.conf /etc/init.d/httpd restart /etc/init.d/apf restart
Remove a whole domain
SecRule SERVER_NAME "handymanreality.com" phase:1,nolog,allow,ctl:ruleEngine=Off
Common modsec uri's
/wp-admin/post.php
RPM
Rpm src packages go here
/usr/local/src/
remove old kernal srcs
rpm -qa | grep kernel-source | xargs rpm -e
Rpm remove installed packages
rpm -e --nodeps {package name here}
Email
horde mail update (nothing can be in account of will all get erased)
/usr/local/cpanel/bin/update-horde --force
To determine mailserver type
/scripts/setupmailserver --current
Count mail in folder
ls | wc -l
removing mass spam
rm -Rf /home/(user here}/mail/cur*
spam 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
SPAMD failing
/scripts/perlinstaller Digest::SHA1 /scripts/perlinstaller --force Mail::SpamAssassin /etc/rc.d/init.d/exim restart /scripts/restartsrv spamd
EXIM
number of msg in q
exim -bpc
print msg q summary
exim -bp | exiqsumm
Start a full q run
exim -q -v
Start a local delivery q run
exim -ql -v
Flush exim queue
exim -bpr | awk {'print $3'} | xargs exim -Mrm
APF
Apf un block
vi /etc/apf/deny_hosts.rules /etc/init.d/apf restart
- of attemps
vi /usr/local/bfd/conf.bfd
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
IPTABLES
Block temp with IPtables
iptables -I INPUT 1 -s ipaddress -j DROP
Block permanently with APF
/etc/apf/deny_hosts.rules
Load checking
Listening on port
lsof -i :25 Total connections on port 80 <pre>netstat -nap |grep -c :80 rough per sec hits <pre>/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 Tells how many are using port 80 <pre>netstat -tn 2>/dev/null | grep :80 | awk '{print $5}' | cut -f1 -d: | sort | uniq -c | sort -rn | head <h1><center>HTTPD and APACHE</center></h1> to distill changes to the httpd.conf <pre>/usr/local/cpanel/bin/apache_conf_distiller --update apache uptime <pre>/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
Ports
Bindings
netstat -lnc
Top
sort by memory
shift - m
sort by processor usage
shift - p
MR Radar
Install mr radar
lpyum install mm3k-client-pull
Rdesktop
rdesktop (servername here) -u mshooltz -p (passhere) &
SSl locations
/usr/share/ssl /etc/ssl/certs
Empty files
To create a empty file that takes so much spce for testing uploads.
dd if=/dev/zero of=file1G.tmp bs=1G count=1
Index blocking
Blocks the index of / from being seen. Remove the +a- to make visable again.
Options +Indexes +a-
CPANEL
Cpanel gives this error [a fatal error or timeout occurred while processing this directive] mv /home/(username)/.cpanel/*cache different location and or check permissions on the /home/(username)/.cpanel folder should be user:user
error when accessing http://ipaddress/~username/ Warning: Unknown: open_basedir restriction in effect. File(/home/hilariou/public_html/index.php) is not within the allowed path(s): (/usr/local/lp:/proc:/usr/lib/php:/usr/local/lib/php:/tmp) in Unknown on line 0
Move this line to the post section of the httpd.conf
vim /usr/local/apache/conf/httpd.conf
Include "/usr/local/lp/configs/httpd/vhost.conf"
ChkServd
enable chkservd
/usr/local/cpanel/bin/tailwatchd --enable=Cpanel::TailWatch::ChkServd
Disable chkservd
/usr/local/cpanel/bin/tailwatchd --disable=Cpanel::TailWatch::ChkServd
Fantastico
add the Fantastico installer plugin
cd /usr/local/cpanel/whostmgr/docroot/cgi wget -N http://files.betaservant.com/files/free/fantastico_whm_admin.tgz tar -xzpf fantastico_whm_admin.tgz rm -rf fantastico_whm_admin.tgz
Python
find python version
python -V
SED
replace this with THIS
sed -i 's/(this)/(THIS)/g' path/filename
Premigrations
Lower ttls and serial changes
wget http://layer3.liquidweb.com/migrations/premigrate.sh bash premigrate.sh
SCP
scp {file} root@(servers ip here):/home/
Rsync
For restoring a shared account
/scripts/pkgacct (username)
Now empty out their public_html
rm -rf /home/(username)/public_html/* rsync -avHl /backup/_bacckup-/home/(username)/public_html/ /home/(username)/public_html/
For loops and other loops
ALWAYS RUN THIS FIRST!!!!!
unalias ls
package all cpanel accounts
for user in `ls -A /var/cpanel/users`; do /scripts/pkgacct $user;done
looping a command
while x=0; do killall -9 php5; sleep .1; done
History Removal commands
run this for a I was never in the box situation.
echo "" > /var/log/messages && echo "" /var/log/secure history -c && echo "" > /var/log/wtmp && echo "" > /var/log/lastlog