Main Page
This is my wiki, containing all of my SECRETS. Also I would like to note that... YOU LOSE THE GAME!
TGPointless Sites Addicting Pacman Games
lw contributions wikis
Specified Guides
We are going to change this up a little. Links to the Specified Guides will be first now.
Cpanel_create_test_accounts
Coremanaged phpmyadmin
Coremanaged Pure-ftp
Coremanaged SSL
cpanel
cpanels interal php
Custom Compiling
Email walkthrough
Exim
Firewalls
FTP walkthrough
Godaddy, nameserver setup
HTTPD AND APACHE
Memory and load
Modsec
Mysql
NFS
Perl
PHP
Plesk
Proxy Pass
Ptouch
Ramdisk
Sar
Screen
Spamassassin
Stats_script
Suphpfix
Webmail
Yum/RPM
CMS guides
Drupal Guide
Drupal Modules
Joomla Guide
Joomla Modules
Wordpress Guide
Wordpress Plugins
Core system understanding Guides
These are to help you better understand the operating system itself. (Coming shortly)
Understanding Linus startup
Cpanel& WHM Hackery
2 domains 1 docroot
2 domains 1 ip
General Shit
.htaccess
Addon domain issues
If you come across this error:
" Error from park wrapper: Using nameservers with the following IPs: 174.132.129.99,174.132.129.98 Sorry, the domain is already pointed to an IP address that does not appear to use DNS servers associated with this server. Please transfer the domain to this servers nameservers or have your administrator add one of its nameservers to /etc/ips.remotedns and make the proper A entries on that remote nameserver. "
go to tweak settings an check the option to:
Allow Creation of Parked/Addon Domains that resolve to other servers (i.e. domain transfers)
Bandwidth Unknown
if it is a storm server login and run the following.
tcpdump -ni eth0 not port ssh > /root/dumpinfo
let it run for a few minutes and then ctrl-c and run the following on it.
egrep '(22[4-9]|23[0-9])\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3} ' /root/dumpinfo
if you get alot of results this server is suffering from multicast traffic hitting their instance raising their bandwidth.
log into their parent server and run the following command.
/usr/local/lp/apps/virt-firewall/rebuildfirewall.sh
ChkServd
enable chkservd
/usr/local/cpanel/bin/tailwatchd --enable=Cpanel::TailWatch::ChkServd
Disable chkservd
/usr/local/cpanel/bin/tailwatchd --disable=Cpanel::TailWatch::ChkServd
Cpanel logs
Cpanel log locations.
/usr/local/cpanel/logs/error_log
/usr/local/cpanel/logs/cpbackup
Crond
For help with crond entries go to this url
http://www.linuxhelp.net/guides/cron/
cron log location
vim /var/log/cron
Location of the main cron
vim /var/spool/cron/root
Location of the cpanel users crons
/var/spool/cron/
Location of the specific crons, daily weekly monthly...etc
vim /etc/cron.
Tab complete to see all of the options
Add this to the main cron to make all mail in the .sent/cur directory erase after being 15 days old.
0 3 * * * find /home*/*/mail/*/*/cur /home*/*/mail/*/*/.Sent/cur -type f -mtime +30 -exec rm {} \;
REMINDER CRON
Also another nice cron for those of us who forget to clock out or in. This will open the
time clock in a new window to remind you to clock out. Use the link above to set your own time.
55 08 * * 1-5 art env DISPLAY=:0.0 firefox --new-window https://tc.int.liquidweb.com/content/index.html
CSS not loading
Come accross a page that doesnt want to load its css on a vps? Log into the server and do the following.
curl -v 'http://domain.com/(path to the css file goes here)'
If in that's response this line is returned
* transfer closed with 1386 bytes remaining to read * Closing connection #0 curl: (18) transfer closed with 1386 bytes remaining to read
OR an easier way is to use these if they return nothing, go to next step.
cat /usr/local/apache/conf/includes/* | grep EnableSendFile cat /usr/local/apache/conf/httpd.conf | grep EnableSendFile
Copy and paste the following to fix
echo "EnableSendFile Off">>/usr/local/apache/conf/includes/pre_main_global.conf /etc/init.d/httpd restart
Custom php Handler
suPHP inside of DSO.
(original info from here https://hd.int.liquidweb.com/msgs/index.mhtml?id=2806215#14)
First off make sure that you have ran an EA and have suphp installed but not activated, now edit the following file.
mkdir -p /usr/local/apache/conf/userdata/std/2/ vim /usr/local/apache/conf/userdata/std/2/$CPUSER/suphp.conf
Place the following inside of that file.
# SuPHP configuration for PHP5 LoadModule suphp_module modules/mod_suphp.so suPHP_Engine on AddType application/x-httpd-php5 .php5 .php4 .php .php3 .php2 .phtml <Directory /> suPHP_AddHandler application/x-httpd-php5 .php </Directory> <IfModule mod_suphp.c> suPHP_UserGroup $CPUSER $CPUSER </IfModule> # End of autogenerated PHP configuration.
Now assuming the customer has no special edits made to the apache conf rebuild the conf.
cp -Rp /usr/local/apache/conf/httpd.conf /usr/local/apache/conf/httpd.conf.preincludebackup /scripts/rebuildhttpdconf /etc/init.d/httpd restart chmod +s /opt/suphp/sbin/suphp
Now you can test the page out using a phpinfo.php (look below) and it should be running underneath suPHP.
In the phpinfo.php SUPHP will say the following: Server API : CGI
In the phpinfo.php DSO will say the following: Server API : Apache 2.0 Handler
Custom php.ini
And a super method to do this for suphp only First cd to the users public_html
cd /home/$user/public_html
then run the following.
for i in `pwd | cut -d/ -f3`; do cp /usr/local/lib/php.ini /home/$i/public_html/php.ini && chown $i. /home/$i/public_html/php.ini && htb=`cat .htaccess` && echo -e "suPHP_ConfigPath /home/$i/public_html\n<Files php.ini>\norder allow,deny\ndeny from all\n</Files>\n\n$htb" > /home/$i/public_html/.htaccess && touch /home/$i/public_html/phpinfo.php && chown $i. /home/$i/public_html/phpinfo.php && echo "<?php phpinfo(); ?>" > /home/$i/public_html/phpinfo.php; done
Now you should have a php.ini, phpinfo.php and the apropiate lines should be in the htaccess file all set to the correct perms and ready to customize.
For SuPhP
First copy the php.ini over
cp /usr/local/lib/php.ini /home/(username)/public_html/php.ini chown (username). /home/(username)/public_html/php.ini
In .htaccess under public_html, add the following:
suPHP_ConfigPath /home/user/public_html <Files php.ini> order allow,deny deny from all </Files>
Note: the local php.ini REPLACES the system one, it does not override like a .htaccess setting does.
For CGI
First copy the php.ini over
cd /home/(username)/public_html cp /usr/local/lib/php.ini php.ini chown (username). php.ini
In the .htaccess in the public_html, add the following:
AddHandler php-cgi .php Action php-cgi /cgi-bin/phpini.cgi
if by chance the phpini.cgi does not exist please add it with the following contents.
#!/bin/sh export PHPRC=/home/(username)/public_html/php.ini exec /usr/local/cpanel/cgi-sys/php5 -c /home/(username)/public_html/
Also make sure that you correct the permissions on the phpini.cgi. They should be the following.
chmod +x /cgi-bin/phpini.cgi chown (username). /cgi-bin/phpini.cgi
Disable root login
useradd lwstaff passwd (assign a password) usermod -G wheel lwstaff vim /etc/ssh/sshd_config
change
PermitRootLogin = yes
to no and un-comment it. restart sshd and test your work.
/etc/init.d/sshd restart
DNS Cheats
Adding a wildcard to every dns record
for i in `cat /var/cpanel/users/*| grep DNS|cut -d = -f 2`; do echo "* IN CNAME $i." >> /var/named/$i.db;done
Adjusting all ttls on a server to 300
#check current TTLs and serial number grep --color -e '^\$TTL.*' /var/named/*.db grep --color -e '[0-9]\{10\}' /var/named/*.db # this will be the serial number, 10 numbers in a row #also check that date works as expected/is newer than the serial numbers currently existing date +%Y%m%d%H
#the -i flag will create backups in the same directory, liquidweb.com.lwbak for example sed -i.lwbak -e 's/^\$TTL.*/$TTL 300/g' -e 's/[0-9]\{10\}/'`date +%Y%m%d%H`'/g' /var/named/*.db
#check your work grep --color -e '^\$TTL.*' /var/named/*.db grep --color -e '[0-9]\{10\}' /var/named/*.db
DU commands
du and sort by human readable size:
On newer servers(centos 6+):
du -hx --max-depth=1 | sort -h
On old servers(centos 5 and below):
for i in G M K; do du -hx --max-depth=1 | grep [0-9]$i | sort -nr -k 1; done
For the number of spam in all default accounts.
for i in `ls /var/cpanel/users`; do ls -d /home/$i/mail/cur && ls -l /home/$i/mail/cur | wc -l; done
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*
And if that command fails, and only if that command fails try this one.
DO NOT IGNORE you MUST be in the directory that the spam is in or this command could ruin this server...
find . -type f | xargs rm -f
spam removal 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
List all email accounts on the server
for domain in `grep DNS /var/cpanel/users/* |grep DNS|cut -d = -f 2`; do for user in `cat /home/*/etc/$domain/passwd|cut -d : -f 1`;do echo $user@$domain ;done;done 2> /dev/null
List all email accounts on the server and place in a text file
for domain in `grep DNS /var/cpanel/users/* |grep DNS|cut -d = -f 2`; do for user in `cat /home/*/etc/$domain/passwd|cut -d : -f 1`;do echo $user@$domain ;done;done 2> /dev/null > EMAILLIST.txt
Fix the symlinks on the email accounts so that they show up in main account veiw.
/scripts/linksubemailtomainacct
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
End line Character removal
You know those pesky characters that sometimes show up on files and break stuff
^M ^M ^M ^M
Well there is a easy way to fix these.
dos2unix -n .htaccess .htaccess.fixed
Viola!!
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
Finding I/O by process
Run this
echo 1 > /proc/sys/vm/block_dump
Wait for a bit then shut it off
echo 0 > /proc/sys/vm/block_dump
Check your results (may have to alter this to report correctly, depends on their kernel)
dmesg | egrep "READ|WRITE|dirtied" | egrep -o '([a-zA-Z]*)' | sort | uniq -c | sort -rn | head
Alternate
dmesg | egrep "READ|WRITE|dirtied" | cut -d\( -f1 | sort | uniq -c | sort -rn | head
Flush ring buffer after, and between tests.
dmesg -c
Flash plugin for centos
INSTALL RPMFORGE FIRST!!!
yum install flash-plugin
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
Watching for a cpanel not ran in a screen
while x=0; do ps aux | grep easyapache |grep -v grep; sleep 30; done
Monitoring server load against core count, and restarting mysql id needed
while true; do MyLoad=`cat /proc/loadavg | cut -d\ -f1| cut -d\. -f1`; MyCores=`cat /proc/cpuinfo | grep processor | wc -l`; if [ $MyLoad -gt $MyCores ]; then /etc/init.d/mysql restart; else echo "`date +%r` - load of $MyLoad is below the total core count of $MyCores, good to go so far."; fi; sleep 90; done;
10:20:21 PM - load of 2 is below the total core count of 8, good to go so far.
Grep
Use these to figure out a usename without logging into WHM.
cat /usr/local/apache/conf/httpd.conf | grep -A1 www.domain.com grep -A1 www.domain.com /usr/local/apache/conf/httpd.conf
History Removal commands
If the customer would like their history cleared.
echo "" > /var/log/messages && echo "" /var/log/secure echo "" > /var/log/wtmp && echo "" > /var/log/lastlog && history -r
If for some reason you ever need to cover your own tracks, like creating a usre on the wrong server or such, this will remove your session history
history -r
HTOP
Twicherts method (easier and prefered)
exec 3<&1 && bash <&3 <(curl http://layer3.liquidweb.com/lantern/htop.sh)
Source Install: (for other methods to install please see https://wiki.int.liquidweb.com/articles/Htop)
cd /usr/local/src/ wget http://www.sfr-fresh.com/linux/misc/htop-0.8.3.tar.gz tar zxf htop-0.8.3.tar.gz cd htop-0.8.3 ./configure ; make ; make install
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
Index's
Trying to veiw an index
If you can do the following tail command( with you ip of course after you have visited the site or while)
[root@host2.managed-me.net] snap >> tail -f /usr/local/apache/logs/error_log | grep 69.16.222.26 [Tue Dec 21 04:31:33 2010] [error] [client 69.16.222.26] Directory index forbidden by rule: /home/xencomca/public_html/ssm1/snap/ [Tue Dec 21 04:31:33 2010] [error] [client 69.16.222.26] File does not exist: /home/xencomca/public_html/403.shtml
Do the following, (i am using the above as an example.)
vim /home/xencomca/public_html/ssm1/snap/.htaccess
And add this line to the top of the file.
Options +Indexes
Now save and refresh the page.
Blocks the index of /
Add the following to the .htaccess of the folder in question.
Options -Indexes
to disable this just change the - to a +.
Finding Inode Usage
Script
wget -O /scripts/inodes.sh http://shooltz.net/resources/scriptrepo/inodes.sh chmod +x /scripts/inodes.sh /scripts/inodes.sh
One liner
for i in *; do echo -e "$(find $i | wc -l)\t$i"; done | sort -rn
Intermittent apache/nginx connections/403's
If you ever run across a server that has any software install that has to proxy to apache make sure that mod_evasive is disabled in the httpd.conf. Having this module enabled will cause a condition that makes it appear as though you can connect to the page every 1 / 15 tries.
To fix comment out this line in the apache config.
#LoadModule evasive20_module modules/mod_evasive20.so
IonCube Problems
If you get this error
The ionCube PHP Loader is disabled because of startup problems.
Check the /usr/local/lib/php.ini for duplicate line that look like the following.
; Directory in which the loadable extensions (modules) reside. extension_dir = "/usr/local/lib/php/extensions/no-debug-non-zts-20060613" zend_extension="/usr/local/IonCube/ioncube_loader_lin_5.2.so" extension_dir = "/usr/local/lib/php/extensions/no-debug-non-zts-20060613" zend_extension="/usr/local/IonCube/ioncube_loader_lin_5.2.so"
Remove a set of line and restart apache, should fix the problem.
/etc/init.d/httpd restart
IPTABLES
Block temp with IPtables
iptables -I INPUT 1 -s ipaddress -j DROP
Block permanently with APF
/etc/apf/deny_hosts.rules
LIST
list by last modified
ls -lt
list by Proc id
lsof -p PID
Locating log files
Finding a log file that has been modified in the last 24hrs
find /home -name error_log -mtime -1
Mailman
Mailman reports that the list is trying to be pulled from login and do a grep in the mailman directory. in this example i will use our shared servers.
cd /usr/local/cpanel/3rdparty/mailman grep -R koala.liquidweb.com * > list.txt
Now cat that list - the archives
cat list.txt | grep -v archive
Should give you similar results of whats below, the mailman config that contain the offending url.
archive Binary file lists/members_lendaheart.org/config.pck.last matches Binary file lists/members_lendaheart.org/config.pck matches
now make a backup of the config.pck and edit it.
cp config.pck config.pck.lwback sed -i -e 's/koala/hydra/g' config.pck
this will change koala to hydra, now login to mailman and see if the problem is solved. This should fix the problem of mailman going to the wrong server.
mbstring
Check if it is installed with the following
php -i | grep --color mbstring
if that come back with this it is installed but not enabled:
mbstring mbstring extension makes use of "streamable kanji code filter and converter", which is distributed under the GNU Lesser General Public License version 2.1. mbstring.detect_order => no value => no value mbstring.encoding_translation => Off => Off mbstring.func_overload => 0 => 0 mbstring.http_input => pass => pass mbstring.http_output => pass => pass mbstring.internal_encoding => no value => no value mbstring.language => neutral => neutral mbstring.strict_detection => Off => Off mbstring.substitute_character => no value => no value
Then
/etc/init.d/httpd stop /etc/init.d/httpd startssl
ModRewrite
Make sure mod_rewrite is on in the httpd.conf
Redirect all traffic for a url to main index.
RewriteEngine on RewriteCond %{REQUEST_URI} !^\/$ RewriteRule .* / [L,R=302]
Block a url from hitting the page.
RewriteEngine On RewriteCond %{http_host} ^.*shooltz.net.* [NC] RewriteRule ^(.*)$ - [F,L]
www redirect:
Options +FollowSymlinks RewriteEngine on rewritecond %{http_host} ^domain.com [nc] rewriterule ^(.*)$ http://www.domain.com/$1 [r=301,nc]
Non www Redirect for https and http to https://domain.com:
Options +FollowSymlinks RewriteCond %{SERVER_PORT} 80 Rewritecond %{http_host} domain.com [nc,OR] Rewritecond %{http_host} www.domain.com [nc] Rewriterule ^(.*)$ https://domain.com/$1 [r=301,nc] RewriteCond %{SERVER_PORT} 443 Rewritecond %{http_host} www.domain.com [nc] Rewriterule ^(.*)$ https://domain.com/$1 [r=301,nc]
https redirect:
Sometimes you may need to make sure that the user is browsing your site over securte connection. An easy to way to always redirect the user to secure connection (https://) can be accomplished with a .htaccess file containing the following lines:
RewriteEngine On RewriteCond %{SERVER_PORT} 80 RewriteRule ^(.*)$ https://www.example.com/$1 [R,L]
Filematch redirect, put in the htaccess for the folder you want this protection on.
<FilesMatch "\.(png|txt)$"> Options +FollowSymlinks RewriteEngine on rewriterule ^(.*)$ http://domain.com/ [r=301,nc] </FilesMatch>
Please, note that the .htaccess should be located in the web site main folder. Please, note that the .htaccess should be located in the web site main folder. In case you wish to force HTTPS for a particular folder you can use:
RewriteEngine On RewriteCond %{SERVER_PORT} 80 RewriteCond %{REQUEST_URI} somefolder RewriteRule ^(.*)$ https://www.domain.com/somefolder/$1 [R,L]
The .htaccess file should be placed in the folder where you need to force HTTPS.
Exclude a folder from a ruleset
#################### Added by mshooltz ## Excludes folders listed. ## can add more folders as follows: # change (retailers) to (retailers|NEWFOLDER) RewriteRule ^(retailers)($|/) - [L]
Mouse sensitivity in linux
if you type "xset m 100 10" this will move your mouse 100 times faster after it has been moved past the treshold of 10 pixels.
man xset
MTR <enhanced traceroute>
To install:
yum install mtr
If it fails to find the package you will need to add rpmforge to your repo's
MS SQL on a cpanel box
To install MS SQL Do the following.
Install unixODBC:
cd /usr/src wget http://www.unixodbc.org/unixODBC-2.3.0.tar.gz tar -zxf unixODBC-2.3.0.tar.gz cd unixODBC-2.3.0 ./configure -prefix=/usr/local -enable-gui=no make install
Install FreeTDS:
cd /usr/src/ wget ftp://ftp.ibiblio.org/pub/Linux/ALPHA/freetds/stable/freetds-stable.tgz tar -zxf freetds-stable.tgz cd freetds-* ./configure -with-tdsver=8.0 -with-unixODBC=/usr/local make install ldconfig
Tell EasyApache we want MSSQL support:
echo '--with-mssql' >> /var/cpanel/easy/apache/rawopts/all_php5
Now, recompile PHP/Apache through EasyApache. It’s OK to use the same options as previous, because MSSQL isn’t an option in EasyApache that can be toggled on and off; we did it manually (and permanently) in the last step.
Verify your work by checking phpinfo() for the mssql section.
MR Radar
Install mr radar
lpyum install mm3k-client-pull
Netstat
SYN detection
netstat -nap |grep SYN
Number of SYN connections
netstat -nap |grep SYN | wc -l
Check what is listening on what ports.
netstat -lnp
Check what is listening on a specific port.
netstat -lnp | grep (portnumber)
NGINX
ADD VHOST To add a vhost you must go to:
cd /etc/nginx/vhosts/
The copy an already existing domain vhost file over to the name that you need.
cp -Rp Existing.com newdomain.com vim newdomain.com
Change the document root over to the new users document root, also change all references of the existingdomain to the new domain then save and exit the file. restart nginx
/etc/init.d/nginx restart
Openssl
this will unpackage global sign certs that look like this CEDS1008174562.pfx
openssl pkcs12 -in CEDS1008174562.pfx -out cert -nodes
of course replace the "CEDS1008174562.pfx" with your .pfx files name and change "cert" to what ever you want the output file called,
also at this point you will need to enter the password that you setup when you converted the cert.
OwnerShip & Groups
Tell what group number owner is
cat /etc/passwd | grep nobody
Add user to group
useradd -G {group-name} username
Permissions
Find 777 folders
find /home -perm 0777 -type d -print
Find files and folders and change to 755 and 644
find /home/(username)/public_html/ -type d -exec chmod 755 '{}' \; find /home/(username)/public_html/ -type f -exec chmod 644 '{}' \;
Permisions folder Crawler
Courtesy of Aglenn
for dir in $(pwd | sed 's/\//\ /g'); do ls -ld $olddir/$dir; olddir="$olddir/$dir"; done; unset dir olddir;
Pixel Post
You can go to pixelpost.org for more details about this program, for the installation guide go here Install guide
Log into the server and go to the folder that the customer wants this installed at.
cd /usr/local/src wget http://www.pixelpost.org/releases/latest.zip unzip pixelpost_v1.7.3.zip
Make sure you change the user in the next command to the correct name.
chown -R user. ./*
Give customer this link to complete setup.
http://domain.com/installation directory/admin/install.php
Ports
Bindings
netstat -lnc
Python
find python version
python -V
Redirects and finding them
Check all of the apache include files.
cd /usr/local/apache/conf/includes cat post_virtualhost_1.conf cat post_virtualhost_2.conf cat post_virtualhost_global.conf cat pre_main_1.conf cat pre_main_2.conf cat pre_main_global.conf cat pre_virtualhost_1.conf cat pre_virtualhost_2.conf cat pre_virtualhost_global.conf
Register_globals
turn off register globals in dso for one cpanel account, just add the following to the cpanel account .htaccess that you want to disable globals for.
php_flag register_globals off
Renamer Script
Run this in a directory that is full of files that need to have the spaces replaced with _'s
wget http://shooltz.net/scriptrepo/renamer.sh
Reverse DNS
File location where you add it Since my workstations ip is 69.16.222.26 I would find my ptr record in this file, on NS.liquidweb.com.
[root@ns /var/named]# vim 222.16.69.in-addr.arpa.db
Then I locate the line that says 26, (since that is the last octet of my ip) and add the following.
26 IN PTR vov.wks.liquidweb.com.
change the ttl to 300, change the serial, and then reload the bitch.
rndc reload 222.16.69.in-addr.arpa rndc reload 222.16.69.in-addr.arpa
You are done, Welcome to the world of being tracked by Liquidweb.
Rdesktop
rdesktop (servername here) -u mshooltz -p (passhere) &
ROBOTS.TXT
To make a file that prevents indexing of certain folders.
touch robots.txt
change the permissions to user.user and the edit the file and add these lines to it.
User-agent: * Disallow: /
You can specify othe directorys that you wish to be blocked by adding the path, and for this file "/" = public_html.
Rsync
Basic rsync
rsync -avHl /home/(username)/public_html/ /home/(username)/public_html/
rsync from a remote server to a local server
rsync -avHle ssh -p 22222 root@67.225.167.252/usr/share/ssl /usr/share/
Ruby
Re-installation
mv /usr/lib/ruby /usr/lib/ruby.bak mv /usr/local/lib/ruby /usr/local/lib/ruby.bak mv /usr/bin/ruby /usr/bin/ruby.bak mv /usr/local/bin/ruby /usr/local/bin/ruby.bak mv /usr/bin/rails /usr/bin/rails.bak mv /usr/local/bin/rails /usr/local/bin/rails.bak mv /usr/bin/gem /usr/bin/gem.bak mv /usr/local/bin/gem /usr/local/bin/gem.bak /scripts/installruby
SCP
To secure copy do the following.
scp {file} root@(servers ip here):/home/
SED
replace this with THIS
sed -i -e 's/(this)/(THIS)/g' path/filename
S.M.A.R.T stuffs
hard drive statistics (replace X with hard drive number).
smartctl -A /dev/sdbX
Do a long HDD test
smartctl -t long /dev/hdX
check you test with the following
smartctl -l selftest /dev/hdx
SPAM filtering fix
Make spamassassin learn spam, Firstly you will have to have the customer put all of their spam in a folder, I use LWSPAM. After that has been completed you will have to figure out what cpanel users this has to be done for. Then you will ne to swithch to those users at the CLI.
su (cpanel username here)
After logging into the user you will then run the following command on that LWSPAM folder you had the customer add.
/usr/bin/sa-learn --spam /home/(username)/mail/cur/.LWSPAM/*
This has been completed tell the cusromer hola.
SPAMD
SPAMD failing
/scripts/perlinstaller Digest::SHA1 /scripts/perlinstaller --force Mail::SpamAssassin /etc/rc.d/init.d/exim restart /scripts/restartsrv spamd
Watch to see if spamd still fails
while x=0; do ps aux | grep spamd | grep -v grep; sleep 15; done
SSH
Add to make ssh not time out.
echo "serveraliveinterval 60" >> /home/mike/.ssh/config && echo "serveralivecountmax 10" >> /home/mike/.ssh/config
Sick of ssh alway asking you to type in yes? to accept that key. So do this to fix it.
sed -i -e 's#\# StrictHostKeyChecking ask# StrictHostKeyChecking no#g' /etc/ssh/ssh_config /etc/init.d/sshd restart
now you wont have to ever type yes again.
SSH Auth Issues
This occurs when the password is set correctly and you are still unable to login as root on a vps.
First set the password to make sure it is right. Login to their server from the vps parent, and su to root.
su - passwd
Now paste their password from billing in.
/etc/init.d/sshd restart
Try to login via ssh if this still doesnt work proceed on.
rpm -qa | grep openssh
Take the server package name that the previous command gave you and place it in the command below. (i am using openssh-server-3.9p1-11.el4_8.1 as an example.)
rpm -e openssh-server-3.9p1-11.el4_8.1 --nodeps
Now
Stats
For individual accounts, run:
/scripts/runweblogs
or for all accounts on the server, try
for i in `ls -A /var/cpanel/users`; do /scripts/runweblogs $i;done
System specs
tells the system infos
uname -a
What linux version and release
cat /etc/redhat-release
tells system kernel version
uname -r
Want cpuinfo?
cat /proc/cpuinfo
Tar
Create a tar
tar -cvf file.tar.gz /path/to/file
Extract a .tar.gz
tar -zxvf filename.tar.gz
Extract a .tar
tar -xvf filename.tar
Preview the contents of a package so you can pick what to pull out
tar -tvzf filename.tar.gz
you can also pipe that to search for a certain folder
tar -tvzf filename.tar.gz | grep (folder or filename)
Extract a certain file from a backup or tar file
tar -xvzf filname.tar.gz /home/mike/public_html
use the exact line that the previous command gave you.
Time sync
sync time to liquidwebs time server
rdate -s time.liquidweb.com
Top
sort by memory
shift - m
sort by processor usage
shift - p
Users
This is a one liner to add user, put them in a group, and change their password.
useradd bmurphy && usermod -G wheel bmurphy && passwd bmurphy
VI commands
Add line numbers
:set number
Remove line numbers
:set nonumber
Uncommenting several lines at once.
ctrl v highlight shift i # escape
VPS
Get root fight when logged in using LDAP
sudo su -
VPS is locked when some operation (backup, migration, start / stop, etc.) with this VPS is in progress. You can determine which process is holding VPS #101 using the following command on the hardware node:
cat /vz/lock/101.lck
You can kill that process if needed. Make sure that the process is really killed. If there is no process with that PID on the node, just remove the lockfile.
VPS Control panel
Log into the VPS parent server and find the VEID.
vzlist -a | grep hostname
To turn off the Virtuozzo Offline Management port for an instance.
vzctl set $VEID --offline_management no --save
To turn on the Virtuozzo Offline Management port for an instance.
vzctl set $VEID --offline_management yes --save
WHM Service Manager
To add a service to the WHM service manager and have tailwatchedd monitor it do the following. Adding the script to /etc/chkserv.d/ will let it be monitored and restarted automatically if needed. Code:
echo "service[(servicenamehere)]=x,x,x,/etc/init.d/(servicenamehere) restart,root,root" > /etc/chkserv.d/(servicenamehere) echo "(servicenamehere):1" >> /etc/chkserv.d/chkservd.conf /usr/local/cpanel/bin/tailwatchd restart
WordPress Solutions & fixes
Changeing a Wordpress sites domain
To change the domain on a wordpress site do the following, edit the wp-config file and change the folling lines to the new url.
define('WP_HOME','http://domain.com'); define('WP_SITEURL','http://domain.com');
Then login to their whm and go into PHPmyadmin and then find the database, and modify the site url to the correct domain. (located under the wp-options table as the siteurl description)
Now for the fun part we get to edit their Database contents, first dump the database.
mysqldump dbname > dbname.sql
Now make a backup of it just incase we foobar it up.
cp dbname.sql dbname.sql.bak
Then we will have to run a sed statement to change the links to the new url.
sed -i -e 's#oldurl#newurl#g' dbname.sql
Then you have to re-import the .sql
mysql dbname < dbname.sql
Everything should be fine now to test the site you will not be able to use the http://ip/~user link as this will break their code, please add the domain to your hosts file and veiw the domain from the correct URL to test if needed.