Never been to TextSnippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world (or not, you can keep them private!)

« Newer Snippets
Older Snippets »
Showing 21-40 of 45 total

RARing files on Mac OSX 10.4

1) Download the application called RAR at

http://files3.rarlab.com/rar/rarosx-3.5.1.tar.gz

2) decompress that file and there'll be a folder called "rar".

3) in that folder there's a file called "rar" (with no quotes or extension)

4) In Finder, go to Go > Go To Folder, and type in "/bin".

5) drag the FILE called "rar" in to that bin folder. It will ask you for your password, so go type it in and continue.

6) open the terminal and go to the directory that has the file or files you want to rar.

7A) once in the folder housing the files you want to rar, type this:

rar a FileName.rar


7B) Alternatively, you can specify which file or folder inside the folder you're in, you want to rar:

rar a FileName.rar originalfilename.whatever


8) to make a multi file rar archive, type the following instead of the above and replace where you see "####" with the file size you want each part to be, in kilobytes (kb).

rar a -v#### FileName.rar originalfilename.whatever


Search for terms in Domlogs

for files in /usr/local/apache/domlogs/*; do grep "wget" $files; done;


-OR-

cd /usr/local/apache/domlogs
grep wget *
grep lynx *
grep curl *


Replace wget with other file names/terms you might want to search for.

If that takes too long, try doing it one by one:

grep wget a*
grep wget b*
grep wget c*
grep wget d*
grep wget e*
grep wget f*
grep wget g*
grep wget h*
grep wget i*
grep wget j*
grep wget k*
grep wget l*
grep wget m*
grep wget n*
grep wget o*
grep wget p*
grep wget q*
grep wget r*
grep wget s*
grep wget t*
grep wget v*
grep wget w*
grep wget x*
grep wget y*
grep wget z*


Alternatively, if you get an error like "Argument list too long":

for i in `ls /usr/local/apache/domlogs|grep -v 'bytes_log'`; do echo "checking on $i" && grep wget /usr/local/apache/domlogs/$i && grep lynx /usr/local/apache/domlogs/$i && grep curl /usr/local/apache/domlogs/$i; done > /root/grep-domlogs-results.txt
Then simply take a look at this file /root/grep-domlogs-results.txt

Looking up recent dictionary attacks

grep "dictionary attack" /var/log/exim_mainlog

Looking into DOS and DDOS Attacks

http://etechsupport.net/forum/showthread.php?t=434

top -d2
netstat -nap | grep SYN | wc -l
netstat -nap | less


If there are many httpd processes showing up after step 1, you might be under attack. If you get high numbers for the second one, you are almost definitely under attack. Use the third one to see the IP addresses, and then ban them from the server:

iptables -A INPUT -s ip.address -j DROP


Also try the following for fixing stuff:
cd /dev/shm
ls


And delete anything that's not supposed to be there.

locate bindz
locate botnet.txt
locate dc
locate ex0.pl
locate kaiten
locate r0nin
locate udp.pl
locate ...
lsof | grep .,
locate mybot

Ban IPs from a server

iptables -A INPUT -s ip.address -j DROP

How to tail logs

tail -200 /var/log/exim_mainlog
tail -200 /usr/local/apache/logs/error_log


To watch the log get updated in real time:
tail -f /var/log/messages 

Sims 2 File Limit Fix

sudo sysctl -w kern.maxfiles=22000
sudo sysctl -w kern.maxfilesperproc=20000


Type this into Terminal in Mac OSX to fix the file size limit for The Sims 2, allowing you to have more than 5000 downloads.

Add a New Rails App (Textdrive & Lighttpd)

Based on: http://forum.textdrive.com/viewtopic.php?id=5094

Get Lighttpd working on Textdrive first (http://manuals.textdrive.com/read/book/9), then to add new Rails apps (ex: typo.domain.tld) follow the steps below...

1. ssh into your account
ssh username@servername.textdrive.com


2. Create a new directory for your rails apps (if you don't have one already):
mkdir ~/apps/ (or whatever you want to name it)


3. Move into that directory:
cd ~/apps/


4. svn checkout the app you want:
Example:
svn checkout svn://leetsoft.com/typo/trunk typo


5. Move into that new app's directory:
Example:
cd typo


6. Change the first line of appname/public/dispatch.rb and appname/public/dispatch.fcgi to:
#!/usr/local/bin/ruby18


7. Set-up MySQL database:

a.
mysql -u username -p

b.
create database textdriveusername_appname;

c.
exit;

d.
mysql -u username -p textdriveusername_appname < db/schema.mysql.sql


8. Create a symbolic link to your app's public folder, inside of your public_html folder:
ln -s /home/username/apps/appname/public /home/username/public_html/appname


9. Add an $HTTP["host"] entry into your lighttpd.conf for the new app (ex: http://textsnippets.com/posts/show/6 and http://textsnippets.com/posts/show/187)

10. Kill all your dispatch.fcgi processes and your lighttpd process (ex: ttp://textsnippets.com/posts/show/206)

11. Restart lighttpd:
/usr/local/sbin/lighttpd -f /home/username/lighttpd/lighttpd.conf


12. Navigate to http://appname.yourdomain.tld


Kill Lighttpd & dispatch.fcgi Processes

From: hhttp://forum.textdrive.com/viewtopic.php?pid=43091#p43091

Kill the processes with:
killall -9 -u your_username lighttpd
killall -9 -u your_username ruby18

...or do a
ps aux

Look for the lighttpd and ruby18 process, take note of their PID (process ID - the first number in the row) and do a:
kill -9 pid (replacing pid with the PID you found)


How To Manually Update Cpanel

/scripts/upcp

/scripts/upcp --force

How To Restart Services

Restart Apache:
service httpd restart


Restart Services:
service chkservd restart


Restart Cpanel:
/etc/init.d/cpanel restart


Restart Bind:
service named start


Run anything in /scripts:
./scriptname

How To Locate Files

lsof | grep searchterm

How To Fix Bandwidth Updating

If bandwidth stats aren't updating:

/scripts/runweblogs username
/scripts/runlogsnow

How To Fix 403 Errors for public_html

If all the public_html folders got their permissions wrong:

chmod 755 /home/*/public_html

How To Empty /var

If /var is too full:

cd /var
du -sh *


If the log directory is the problem:

rm -f /var/log/*.1
rm -f /var/log/*.2
rm -f /var/log/*.3
rm -f /var/log/*.4


(The /var/log directory contains archived files that always end with a number: exim_mainlog.1. Any file ending with a number can be safely deleted.)

If the problem is with the exim_mainlog being too large, try rotating the logs:

/usr/sbin/logrotate -vf /etc/logrotate.conf


If you get an error about a duplicate log entry:

cd /etc/logrotate.d
rm -rf httpd.rpmorig.log


And try the rotate again.

If the problem is in spool:

cd /var/spool/exim/msglog
rm -rf *

How To Empty /usr

cd /usr/local/apache/domlogs/
rm -rf *.*
/scripts/restartsrv httpd

How To Empty /backup

If /backup/ is too full:

cd /backup/cpbackup/monthly/
rm -f *.gz
/scripts/restartsrv httpd


Check the space after this, and it should be fine.

How To Fix Incorrect Disk Space

/scripts/fixquotas
/scripts/updatemysqlquota

How To Turn Off/On Stats For One Account

http://forums.cpanel.net/showthread.php?t=15967&highlight=urchin

You can edit the:

pico /var/cpane/users/accountname


file and add settings for the stats packages.

skipanalog=1
skipawstats=1
skipwebalizer=1


That will turn them off and override the server setttings.

To update the stats now:

/scripts/runweblogs username
/scripts/runlogsnow

How To Fix Fantastico SourceGuardian Error

http://netenberg.com/forum/viewtopic.php?t=1937
http://www.netenberg.com/forum/viewtopic.php?t=2480

Please make sure to select "Sourceguardian" in WHM -> Tweak Settings (section "Software"). If that doesn't work:

pico /usr/local/cpanel/3rdparty/etc/php.ini


change:
extension_dir = ./ ;

to
extension_dir = ;


and
;;;;;;;;;;;;;;;;;;;;;;
; Dynamic Extensions ;
;;;;;;;;;;;;;;;;;;;;;;

to
;;;;;;;;;;;;;;;;;;;;;;
; Dynamic Extensions ;
extension="/usr/local/cpanel/3rdparty/etc/ixed/ixed.lin.4.3.10.pxp"
;;;;;;;;;;;;;;;;;;;;;; 
« Newer Snippets
Older Snippets »
Showing 21-40 of 45 total