Main Page

From Cheatsheet
Revision as of 06:43, 13 December 2010 by Admin (talk | contribs)
Jump to navigation Jump to search

This is my wiki, containing all of my SECRETS.

Also I would like to note that... YOU LOSE THE GAME! TG
Fukung Pointless Sites


Specified Guides

We are going to change this up a little. Links to the Specified Guides will be first now.

Coremanaged phpmyadmin
Coremanaged Pure-ftp
Coremanaged SSL
Custom Compiling
Drupal Guide
Email walkthrough
FTP walkthrough
Godaddy, nameserver setup
HTTPD AND APACHE
Perl
[http://shooltz.net/w/index.php?title=PHP PHP
Plesk
Ramdisk
Suphpfix

Core system understanding Guides

These are to help you better understand the operating system itself. (Coming shortly)

Understanding Linus startup


General Shit

.htaccess

to enable the reading of the custom php.ini in the public_html for suphp you need to add the following and replaces username with the cpanel user's username

suPHP_ConfigPath /home/username/public_html

then

cd /home/username/public_html
cp /usr/local/lib/php.ini /home/username/public_html/php.ini
touch phpinfo.php && echo "<?php phpinfo(); ?>" >> phpinfo.php
chown username. php.ini phpinfo.php

Now add you custom changes for that account into that php.ini, and then proceed to test by going to that users website/phpinfo.php and see it your changes are there.


Adding domains to Dedicated ips

To place more that one domain on a dedicated IP go to:

cd /var/cpanel/userdata/

Choose the domains user that we are adding to the ip example: username/domain.com

 vim username/domain.com

Change the ip to the new ip, save the file.

/scripts/rebuildhttpdconf
/etc/init.d/httpd stop
/etc/init.d/httpd stop
/etc/init.d/httpd startssl

Wait for it to propagate, and viola!

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)

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

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 ARE LOCATED AT

vim /usr/local/cpanel/logs/error_log

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

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.ini

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

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:

AddHandler php-cgi .php .htm 
Action php-cgi /home/(username)/public_html/cgi-bin/php5.cgi

if by chance the php5.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

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.

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 

Email

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

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

Do a traceroute on the email path to the mx hosts

exim -bt Email address here


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

Flash plugin for centos

yum install flash-plugin.1386

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

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

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 blocking

Add this to the .htaccess, Blocks the index of / from being seen. Comment out to make visible again.

Options -Indexes
OR
Options +Indexes +a-

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

Load checking

Listening on port

lsof -i :25

Load per process checking

/usr/local/cpanel/bin/dcpumonview

Total connections on port 80

netstat -nap |grep -c :80

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

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

Locating log files

Finding a log file that has been modified in the last 24hrs

find /home -name error_log -mtime -1

Memory and load issues

Load per process checking

/usr/local/cpanel/bin/dcpumonview

Memory per user foo'ed up by mwineland

lwtmpvar=;for each in `ps aux | grep -v COMMAND | awk '{print $1}' | sort | uniq`; do lwtmpvar="$lwtmpvar\n`ps aux | egrep ^$each | awk 'BEGIN{total=0};{total += $4};END{print total, $1}'`"; done; echo -e $lwtmpvar | grep -v ^$ | sort -rn | head

Checking swaps memory usage

vmstat 1

If digging into swaps memory run this and see if there are any tables that are "[!!] Total fragmented tables" If it does show that there are fragmented tables, run an optimize on the tables.

wget mysqltuner.pl/mysqltuner.pl && perl mysqltuner.pl

Optimization script here

for i in $(mysql -e "show databases;" | sed 's/Database//') ; do for each in $(mysql -e "use $i; show tables;" \
| sed 's/Tables.*//' ;) ; do mysql -e "use $i ; optimize table $each" ; done ; done

Using Sar

this can be helpful in figuring out what the swaps are are or the iowait.

sar

This will display Collected, report, or save system activity information.

sar -r

This will show you the memory and swap space utilization statistics.
You can futher clean that up to show just mem used and swpused with the following.

sar -r | awk '{print $1,"\t"$2,"\t"$5,"\t\t"$10}'

You can also use sar to view previous days log files. Do the following.

cd /var/log/sa
ll

This should provide you with a list that looks like the following.

 
-rw-r--r--  1 root root 484640 Aug  1 15:51 sa01
-rw-r--r--  1 root root 484176 Aug  2 23:50 sa02
-rw-r--r--  1 root root 228576 Aug  3 11:00 sa03
-rw-r--r--  1 root root 490992 Jul 26 23:50 sa26
-rw-r--r--  1 root root 490992 Jul 27 23:50 sa27
-rw-r--r--  1 root root 490992 Jul 28 23:50 sa28
-rw-r--r--  1 root root 481232 Jul 29 23:50 sa29
-rw-r--r--  1 root root 490992 Jul 30 23:50 sa30
-rw-r--r--  1 root root 485104 Jul 31 15:37 sa31
-rw-r--r--  1 root root 491873 Aug  1 23:53 sar01
-rw-r--r--  1 root root 491907 Aug  2 23:53 sar02
-rw-r--r--  1 root root 498737 Jul 25 23:53 sar25
-rw-r--r--  1 root root 498737 Jul 26 23:53 sar26
-rw-r--r--  1 root root 498737 Jul 27 23:53 sar27
-rw-r--r--  1 root root 498737 Jul 28 23:53 sar28
-rw-r--r--  1 root root 489709 Jul 29 23:53 sar29
-rw-r--r--  1 root root 498737 Jul 30 23:53 sar30
-rw-r--r--  1 root root 493163 Jul 31 23:53 sar31

Each of those files is a log for that day of the month. Pick and choose then view them with the following command.

sar -f sa01

If you want to view different modes of the sar add the flags at the end of the command like so.

 sar -f sa01 -r

check the parent for oomage figure out the instance id

vzlist -a

place id here.

cat /var/log/messages | grep OOM.*ve\=(id goes here)

run this to see how many times this has happened in one day.

grep Aug\ 21.*OOM.*ve\=(id goes here) /var/log/messages | wc -l

To find script memory usage run the following lines

for each in `ls -A /var/cpanel/users | fgrep -v "."`; do grep -R memory_limit /home/$each/public_html/ >> /root/temp.txt; done
cat /root/temp.txt | grep ini_set

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

Go into the php.ini and un-comment these lines.

vim /usr/local/lib/php.ini

and un-comment these lines.

extension=php_mbstring.dll
extension=php_mcrypt.dll

Then

/etc/init.d/httpd stop
/etc/init.d/httpd startssl

MODSEC

my whitelisting script

wget http://shooltz.net/modsec_whitelister.sh
chmod +x modsec_whitelister.sh
./modsec_whitelister.sh

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
/wp-admin/admin-ajax.php
/wp-admin/page.php

Script to email Modsec logs

per day to the customer.

First make the script

touch /root/modseclog.sh
touch /root/tmplog.txt
touch /root/tmplog2.txt
chmod +x /root/modseclog.sh
vim /root/modseclog.sh

Paste the following into it.

#!/bin/bash

date=`date | awk '{print$2, $3}'`
echo "" > /root/tmplog.txt && echo "" > /root/tmplog2.txt
cat /usr/local/apache/logs/error_log | grep modsec > /root/tmplog.txt
cat /root/tmp.txt | grep "$date" > /root/tmplog2.txt
cat /root/tmplog2.txt | mail -s "Modsec Log for $date" (email goes here)

Save it and then add the following line into your crontab.

57 23 * * * /root/modseclog.sh

Now wait for 11:57 and then check your email. :P


ModRewrite

www 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]

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

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

my guide to 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 '{}' \;


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.

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

Register_globals

turn off in dso for one account
just add the following to the cpanel account .htaccess that you want to disable globals for.

php_flag register_globals off 

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.

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}

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/

SCP

scp {file} root@(servers ip here):/home/ 


SED

replace this with THIS

sed -i 's/(this)/(THIS)/g' path/filename

S.M.A.R.T stuffs

hard drive statistics

smartctl -A /dev/sdbX

replace X with hard drive number.

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

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

Tar

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

us the exact line that the previous command gave you.

Time sync

sync time to lws 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

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.

WordPress Solutions

Moving a WP site To move a wordpress site forward a directory You will do the following:
1) cd to the users public_html then move the contents forward

mv (current installation)/* /home/user/public_html/

now edit the wp-config.php and add the following lines..

define('WP_HOME','http://domain.com');
define('WP_SITEURL','http://domain.com');

Then login to their whm and go into WHM and then find the database, and modify the site url to the correct domain. (located under the wp-options table as the siteurl description)

Then if the urls need stuffs removed do the following.

mysqldump dbname > dbname.sql
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 's/old url/newurl/g' dbname.sql 

Then you have to re-import the .sql

mysql dbname < dbname.sql

should be done now.

YUM problems

First off always check this location

ls -lah /etc/yum.repos.d

And if it lists anything MORE than the following please mv everything else out of this folder.

root@host [/usr/local/cpanel/logs/easy/apache]# ls -lah /etc/yum.repos.d
total 20K
drwxr-xr-x   2 root     root     4.0K Nov 14 19:08 ./
drwxr-xr-x  63 root     root      12K Nov 14 20:02 ../
-rw-r--r--   1 systuser systuser  660 Mar  2  2005 yum.system.repo

if you see anything more than this please move all other repos out of this folder and try again. If you problem still occurs please proceed on. Next check you yum.conf to make sure it is correct should look like the following.

[root@Shooltz.net [~]$ cat /etc/yum.conf
[main]
cachedir=/var/cache/yum
debuglevel=2
logfile=/var/log/yum.log
pkgpolicy=newest
distroverpkg=centos-release
tolerant=1
exactarch=1
retries=20
obsoletes=1
gpgcheck=1
exclude=apache* bind-chroot centos-yumconf courier* dovecot* exim* httpd* mod_ssl* mysql* nsd* perl* php* proftpd* pure-ftpd* ruby* spamassassin* squirrelmail*

If you yum.conf does not look lik ethat please back it up and replace it with what follows.

mv /etc/yum.conf /etc/yum.conf.bak
echo -e "[main]\ncachedir=/var/cache/yum\ndebuglevel=2\nlogfile=/var/log/yum.log\npkgpolicy=newest\ndistroverpkg=centos-release\ntolerant=1\nexactarch=1\nretries=20\nobsoletes=1\ngpgcheck=1\nexclude=apache* bind-chroot centos-yumconf courier* dovecot* exim* httpd* mod_ssl* mysql* nsd* perl* php* proftpd* pure-ftpd* ruby* spamassassin* squirrelmail*" > /etc/yum.conf

After this has been completed, and if it is still broken we will reset the rpm databases.

rm -f /var/lib/rpm/__db*
rpm -vv --rebuilddb