Remember that if you are running any mysql or mysqldump commands to not include the password when you type it in. This is because the commands you type into the command line are logged & thus if you type the password directly into the command it will be logged. If however you do not enter the password directly into the commands then it is not logged as it goes to the program. (This may vary depending on your installation, but I still feel it is a better idea to enter it after the command.)
Remember that Linux, Unix, & BSD are all case sensitive. This is not like Windows or MD-DOS where things are case aware at best & may as well be case insensitive as far as I care.
Use of command | command example |
this will delete any file or folder named delme, in the current folder & all sub folders it has access to |
find . -name "delme" -exec rm -fr {} \; |
Set all files & folders to 755 permissions | chmod -R 755 * |
To kill php5 processes | killall -15 php5 |
To count subdirectories | find ./ -type d | wc -l |
To count files | find ./ -type f | wc -l |
To count subdirectories in the public_html folder | find ~/public_html/ -type d | wc -l |
To count files in the public_html folder | find ~/public_html/ -type f | wc -l |
To just fix permissions run the following commands | find ~/public_html/ -type d -exec chmod 755 {} \; find ~/public_html/ -type f -exec chmod 644 {} \; find ~/public_html/ -name \*.cgi -exec chmod 755 {} \; find ~/public_html/ -name \*.pl -exec chmod 755 {} \; find ~/public_html/ -name \*.pm -exec chmod 755 {} \; find ~/public_html/ -name .ftpquota -exec chmod 600 {} \; I wrote a php script to do this over here as I got sick of running this from SSH. |
Here are the commands to clean up the _ folders created by FrontPage | 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 {} \; |
to find files that might have database info (will find with the username signed in as) (.php files only) |
find ~/public_html/ -name \*.php -exec grep -Hl `whoami`_ {} \; |
to find files that might have database info (will find with the username signed in as) (all files) |
find ~/public_html/ -type f -exec grep -Hl `whoami`_ {} \; |
to find files that might have database info (replace username with the username of the account) (.php files only) |
find ~/public_html/ -name \*.php -exec grep -Hl username_ {} \; |
to find files that might have database info (replace username with the username of the account) (all files) |
find ~/public_html/ -type f -exec grep -Hl username_ {} \; |
will search for the specific string "mail(" & export to a mail-usage.txt file | find ~/public_html -type f -exec grep -Hl 'mail(' {} \; > ~/mail-usage.txt find ~/public_html -type f -exec grep -Hl 'mail (' {} \; >> ~/mail-usage.txt |
current folder (Print Working Directory) | pwd |
clear screen (This is similar to DOS's CLS command) | clear |
Restores a database as stored in the [database-file] (Replace "[database]" with the name of the database.) (Replace "[database-file]" with the name of the database file.) |
mysql -u`whoami` -p [database] < [database-file] |
Dumps a mySQL database to a file | mysqldump -u`whoami` -p [database] > [database-file] |
Dumps a mySQL database to a file with today's date | mysqldump -u`whoami` -p [database] > [database].`date +%F`.sql |
Removes "eval(base64_decode" till the "))" in them. This may cause problems if some of the files are supposed to have a base64_decode running in them. |
find ~/public_html/ -type f -exec sed -i 's/eval(base64_decode.*))\;//g' {} \; |
This will show you if cron is running (You should see at least two instances one as root & one from your grep) |
ps aux | grep crond |