Bash Commands
find files that contain a specific string – only prints file names
find . -type f -exec grep -irl 'string' {} \;
check load on boxes
vmstat 3
iotop
iostat 2
top within top you can check the load average across the top, you can also check swapping where you see the swap memory, a lot of activity with swapping can be a cause of website / server performance issues. The load average should stay below 1 load unit per CPU core, otherwise you may see performance issues.
Count all inodes on the account. You can adjust the path to get the exact count of a folder.
find ~/ | wc -l
See all processes in top for your username:
top -u `whoami`
Kill all processes for a specific username:
pkill -u `whoami` php5
(php5 can be replaced for any process name this user is running)
List files in ssh with the dates modified associated:
ls -l
See if a 301 redirect is actually happening:
curl -Iv google.com
-v = Verbose, tell me what you’re doing
Diagnosing cpu throttling (version 2):
Get into ssh.
Switch the account to just php 5. Not php 5 single php.ini.
type: top
hit enter
After that type: u
hit enter
then the username of the account.
hit enter
Then type: c
This will show the path to the php scripts which are currently running which you can then use to see what script is being slow. Then of course find out what domain/subdomain is assigned to that directory.
This makes it way easier to find out which site on an account is having throttling issues.
Other throttling diagnosing techniques:
Compare timestamps of when they were most recently throttled with their raw apache logs to make some guesses about which scripts were being accessed when it was throttled.
You may also check ~/tmp/mysql_slow_queries for the database generating the most logs, then use phpMyAdmin to check the database for the most tables and try and relate it to a problem plugin.
Importing MySql:
mysql -uusername -p username_databasename < sqlfile.sql
Exporting MySql:
mysqldump -u gatmarke -p gatmarke_newcosep09 >database.sql
Grep the error logs:
grep `whoami` /var/log/domlogs/error_log
Search the contents of all files in a certain directory for a specific string:
grep -irl 'thestring' ~/
Symbolic Links (sym links):
ln -s ~/public_html/datadrive ~/WEBDRIVES/datadrive
This will make it so that if you cd into ~/WEBDRIVES/datadrive you are actually cd’ing into ~/public_html/datadrive
Continue process without shell or without ssh running:
pause current process: ctrl z
Make it go to background: bg
Disown the command: disown -h -r %1
Recursively change file and directory permissions (good for fixing 500 errors):
find . -type d -exec chmod 755 {} \;
This will recursively search your directory tree (starting at dir ) and chmod 755 all directories only.
Similarly, the following will chmod all files only (and ignore the directories):
find . -type f -exec chmod 644 {} \;
Removes write permissions from group and world on all files
find -exec chmod go-w {} \;
Rename all .htaccess files at once. (also good for fixing 500 errors):
find ~/ -name .htaccess -exec mv {} {}.bak \;
Rename all php.ini files at once. (good for fixing php errors):
find ~/ -name php.ini -exec mv {} {}.bak \;
Fix Most Frontpage Issues:
find ~/public_html/ -type d -exec chmod 755 {} \;
find ~/public_html/ -name "_borders" -exec rm -fr {} \;
find ~/public_html/ -name "_derived" -exec rm -fr {} \;
find ~/public_html/ -name "_fpclass" -exec rm -fr {} \;
find ~/public_html/ -name "_overlay" -exec rm -fr {} \;
find ~/public_html/ -name "_private" -exec rm -fr {} \;
find ~/public_html/ -name "_themes" -exec rm -fr {} \;
find ~/public_html/ -name "_vti*" -exec rm -fr {} \;
find ~/public_html/ -name ".htaccess" -exec mv {} {}.`date +%F` \;
find ~/public_html/ -name "postinfo.html" -exec rm -fr {} \;
