Sunday, 25 November 2012

Linux Tips :How to build SVN server, Step by step


How to build SVN server, Step by step

There are many configurations for svn, here a some short instuctions to get a basic svn repository available over http.
  1. Install required packages:
    apt-get install subversion apache2 libapache2-svn
  2. Create an Directory-Structure:
    mkdir -p /var/svn/repos/
    
  3. Create a Repository:
    cd /var/svn/repos/
    svnadmin create --fs-type fsfs <your-repository>
    
  4. Now Create your Project-Struckture to import in the repository:
    mkdir -p /tmp/myproject/trunk /tmp/myproject/tags /tmp/myproject/branches
    
  5. Import the Project to the Repository:
    svn import /tmp/myproject file:///var/svn/repos/<your-repository> -m "initial import"
    
  6. Make it accesseable over http:
    cd /etc/apache2/sites-available
    touch subversion.conf
    vim subversion.conf
    
  7. Now edit the empty file with this configuration:
    NameVirtualHost *:80
    
    <VirtualHost *:80>   
      <Location /svn>
          ErrorDocument 404 default
          DAV svn
          SVNParentPath /var/svn/repos
          SVNListParentPath off
          Require valid-user
          AuthType Basic
          AuthName "subversion access"
          AuthUserFile /var/svn/.htpasswd
          AuthzSVNAccessFile /var/svn/authz 
      </Location>
    </VirtualHost>
    
  8. enable dav_svn module for apache:
    a2enmod dav_svn
    enable VHost configuration: 
    a2ensite subversion.conf
    
  9. now restart the webserver:
    /etc/init.d/apache2 restart
    
  10. Create an htpasswd:
    htpasswd -c /var/svn/.htpasswd user
    
  11. Create the access control file for the repository:
    touch /var/svn/authz
    
  12. edit the empty authz file:
    vim /var/svn/authz
    
  13. Give read/write rights to for user:
    [your-repository:/]
    user = rw
    Let's try to checkout the the repo over http: 
    svn checkout http://your-server/svn/your-repository
    

MySql Tips: How to track the source of IP-Addresses that cause aborted connect in mysql?


How to track the source of IP-Addresses that cause aborted connect in mysql?

mysql> show global status like 'aborted_connects';
+------------------+-------+
| Variable_name    | Value |
+------------------+-------+
| Aborted_connects | 161   |
+------------------+-------+
or in the terminal if you run
admin@DBServer$ mysqladmin ext -uroot -p | grep Aborted_connects
Enter password: 
| Aborted_connects                  | 161     |
this number means that you have 161 failed trials to connect to your mysql server for some reason. maybe somebody trying to hack you.
now to trace who is causing such connections, let us go ahead with tcpdump in a screen as below:
admin@DBServer$ screen -S TCPDUMP
#this will open a screen for you
admin@DBServer$  tcpdump -s 1500 -w tcp.out port 3306
#now to detach your screen click "CTRL + A + D"
#and to reattach it (enter it again) run screen -x TCPDUMP
Now when you get more aborted connections, stop the tcpdump and stringily your tcp.out as shown below
admin@DBServer$ strings tcp.out
Host 'XXX.XX.XX.XXX' is not allowed to connect to this MySQL server

Wednesday, 14 November 2012

apache tips: prevent hot-linking with htaccess

prevent hot-linking with htaccess

Believe it or not, there are some webmasters who, rather than coming up with their own content will steal yours. Really! Even worse, they won't even bother to copy to their own server to serve it up, they'll just link to your content!  no, it's true, in fact, it used to be incredibly common. These days most people like to prevent this sort of thing, and .htaccess is one of the best ways to do it.

This is one of those directives where the mileage variables are at their limits, but something like this works fine for me..
Options +FollowSymlinks
# no hot-linking
RewriteEngine On
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?corz\.org/ [NC]
RewriteCond %{REQUEST_URI} !hotlink\.(gif|png) [NC]
RewriteRule .*\.(gif|jpg|png)$ http://ajayadas.com/images/hotlink.png [NC]
You may see the last line broken into two, but it's all one line (all the directives on this page are). Let's have a wee look at what it does..

We begin by enabling the rewrite engine, as always. 

The first RewriteCond line allows direct requests (not from other pages - an "empty referrer") to pass unmolested. The next line means; ifthe browser did send a referrer header, and the word "corz.org" is not in the domain part of it, then DO rewrite this request.

The all-important final RewriteRule line instructs mod_rewrite to rewrite all matched requests asking for gifs, jpegs, or pngs, to an alternative image. 

There are loads of ways you can write this rule; Google for "hot-link protection" and get a whole heap. Simple is best. You could send a wee message instead, or direct them to some evil script, or something.

Firefox Tips:Firefox Browser running but not open

Firefox Troubleshooting:


The fix was to uninstall Firefox and then manually delete in the registry (using the program regedit.exe provided by Microsoft) most entries for Firefox (especially those in HKEY_CURRENT_USER and HKEY_LOCAL_MACHINE), then reinstalling Firefox. It now opens normally.


Chrome Troubleshooting:



I right click on the Chrome shortcut, get the Properties and click on the Open File Location button. This takes me to folder
 
C:\Users\myuserid\AppData\Local\Google\Chrome\Application
 
Sure enough, there is a file in that folder called debug.log and it's just what I was looking for, an error log in plain text. In Notepad, it looks like gibberish, but displayed in a better text editor, such as Notepad++, the errors are easy to read. 
 
There seem to be a pair of errors generated every time I try to run Chrome. The first pair is below.
 
0706/215116:ERROR:client_util.cc(394)
  Failed to load Chrome DLL from
  C:\Users\myuserid\AppData\Local\Google\Chrome\
  Application\20.0.1132.43\chrome.dll

0706/215116:ERROR:client_util.cc(442)
  Could not find exported function
  RelaunchChromeBrowserWithNewCommandLineIfNeeded

Printer Tips:Troubleshooting HP Printer That Is Not Printing Black Ink

Issue:HP Office Jet 4500 Desktop printer did not print black inkjet.

Printing Problems

  • An HP printer, particularly the inkjet printer, can encounter printing problems. One of the printing problems a person may experience is when the HP printer will not print black ink. Oftentimes, the owner believes the black ink is low and needs a new replacement, only to find out that the new printer cartridge does not solve the problem.


Troubleshooting Steps

  • One can perform certain troubleshooting steps in order to find the root of the problem. Oftentimes, through a series of trials and errors, a person can find the real problem and find a resolution. The first troubleshooting step an owner can take is to make sure that the plastic protective tape on the new black cartridge is off. Many HP printer owners commit this simple mistake possibly due to absent-mindedness or maybe due to distractions while loading the new black ink cartridge. Others simply forget to do so.
    Next, the owner should calibrate the HP printer. Some owners think that they can skip through this process because they already calibrated the printer after it was purchased. One thing to remember is that every time there is a need for a new printer cartridge, calibration is one of the steps to perform right after loading. You can run "Self Test Diagnostic," as well as, "Print Cartridge Alignment" in order to get the black ink to work.
    You can also try cleaning the black ink cartridge. Remove the blank ink cartridge from the HP printer; use a cotton swab to clean the laser or scanner block. Wipe away dirt, grime or any dried ink that may prevent ink from flowing. You can also try cleaning the printer heads.
    If you are having issues on an HP Laserjet printer, go to the menu, click "Diagnostics," then print the "PQ Troubleshooting Pages." If black ink does not print, go to "Disable the Cartridge" and switch the magenta and black cartridges on the menu. Then, print the pages again. If black ink does not print, then the problem may be the toner cartridge.
    At times, when black ink does not print, it can signify a problem with a printer's laser. The owner of a HP printer may see an error on the LCD screen, indicating that there is a problem with the laser assembly.
    Another problem could be the wiring connection at the laser or scanner; check if the plugs are loose. Contact HP Support for further assistance.


Wednesday, 7 November 2012

Linux Tips:Run Crontab / Cronjob every 10 Minutes or every 5 minutes


Linux Tips: Run Crontab / Cronjob every 10 Minutes or every 5 minutes



\
*/10 * * * * /path/to/command
*/05 * * * * /path/to/command


linux / unix find size of a folder


to find folder size easy way is to check with du command
du - sch 
or you want to see file size of each item inside folder
du -ach

Linux Tips # SOLVED - Pure FTP Connection Error : Error loading directory


1. How to SOLVED - Pure FTP Connection Error : Error loading directory


enable ftp pots
iptables -A INPUT -s 0/0 -p tcp --dport 20 -j ACCEPT
iptables -A INPUT -s 0/0 -p tcp --dport 21 -j ACCEPT

enable port for passive mode
iptables -A INPUT -s 0/0 -p tcp --dport 30000:50000  -j ACCEPT
save iptables for future
iptables-save

restart iptables
/etc/init.d/iptables restart

whala!   my client says IT WORKS !!

enjoy 
change configuration for passive mode
vi   /etc/pure-ftpd/pure-ftpd.conf
PassivePortRange 30000 50000
Restart  Pure-ftpd
/etc/init.d/pure-ftpd restart



2. Linux Tips # Pure FTP fix for “failed to retrieve directory listing”.


I was setting up pure-ftpd on a system that needed FTP access for users. The users were using FileZilla. For firewall on the server (running RHEL5), I was using iptables. Was having a difficult time getting FTP with TLS to connect and when I was able to get it to connect I would get the error: “failed to retrieve directory listing”.
Error: Connection timed out
Error: Failed to retrieve directory listing
Here is the fix:
# cat /proc/sys/net/ipv4/ip_local_port_range
32768      61000
Make sure ports used do not fall within that range (used by the system). So pick 10000 to 20000, for example.
# iptables -I INPUT 2 -p tcp –dport 10000:20000 -j ACCEPT
# iptables -I OUTPUT 2 -p tcp –sport 10000:20000 -j ACCEPT
Also need port 21 (port 20 was not needed):
# iptables -I INPUT 2 -p tcp –dport 21 -j ACCEPT
# iptables -I OUTPUT 2 -p tcp –sport 21 -j ACCEPT
Save your iptables of course and then restart:
iptables-save > /etc/sysconfig/iptables
service iptables restart
Then in pure-ftpd, go to conf file (/etc/pure-ftpd.conf and set the following line:
PassivePortRange          10000 20000
service pure-ftpd restart