linux poison RSS
linux poison Email
0

Quick Apache configuration tips

Enable Directory Browsing
Options +Indexes

## block a few types of files from showing
IndexIgnore *.wmv *.mp4 *.avi

Disable Directory Browsing
Options All -Indexes

Customize Error Messages
ErrorDocument 403 /forbidden.html
ErrorDocument 404 /notfound.html
ErrorDocument 500 /servererror.html

Get SSI working with HTML/SHTML
AddType text/html .html
AddType text/html .shtml
AddHandler server-parsed .html
AddHandler server-parsed .shtml
# AddHandler server-parsed .htm

Change Default Page (order is followed!)
DirectoryIndex myhome.htm index.htm index.php

Block Users from accessing the site
order deny,allow
deny from 202.54.122.33
deny from 8.70.44.53
deny from .spammers.com
allow from all

Allow only LAN users
order deny,allow
deny from all
allow from 192.168.0.0/24

Redirect Visitors to New Page/Directory
Redirect oldpage.html http://www.domainname.com/newpage.html
Redirect /olddir http://www.domainname.com/newdir/

Block site from specific referrers
RewriteEngine on
RewriteCond %{HTTP_REFERER} site-to-block\.com [NC]
RewriteCond %{HTTP_REFERER} site-to-block-2\.com [NC]
RewriteRule .* - [F]

Block Hot Linking/Bandwidth hogging
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$RewriteCond %{HTTP_REFERER} !^http://(www\.)?mydomain.com/.*$ [NC]
RewriteRule \.(gif|jpg)$ - [F]

Want to show a “Stealing is Bad” message too?
Add this below the Hot Link Blocking code:
RewriteRule \.(gif|jpg)$ http://www.mydomain.com/dontsteal.gif [R,L]

Stop .htaccess (or any other file) from being viewed
order allow,deny
deny from all

Avoid the 500 Error
# Avoid 500 error by passing charset
AddDefaultCharset utf-8

Grant CGI Access in a directory
Options +ExecCGI
AddHandler cgi-script cgi pl# To enable all scripts in a directory use the following#
SetHandler cgi-script

Change Script Extensions
AddType application/x-httpd-php .gne
gne will now be treated as PHP files! Similarly, x-httpd-cgi for CGI files, etc.

Use MD5 Digests
Performance may take a hit but if thats not a problem, this is a nice option to turn on.
ContentDigest On

Save Bandwidth
# Only if you use PHP
php_value zlib.output_compression 16386

Turn off magic_quotes_gpc
# Only if you use PHP
php_flag magic_quotes_gpc off


Read more
1

How To Make ISO image from CD

Use following command to create ISO image of CD
Note: /dev/hdc is my cdrom device

1. dd if=/dev/hdc of=/home/nikesh/example.iso bs=2048 conv=notrunc
— OR –

2. cat /dev/hdc > /home/nikesh/example.iso
Both commands do exactly the same, but the first one might be easier to remember.
Read more
1

How to recover damaged Superblock

If a filesystem check fails and returns the error message “Damaged Superblock”

Solution:

There are backups of the superblock located on several positions and we can restore them with a simple command. Backup locations are: 8193, 32768, 98304, 163840, 229376 and 294912. ( 8193 in many cases only on older systems, 32768 is the most current position for the first backup )

Now, suppose you get a ¨Damaged Superblock¨ error message at filesystem check ( after a power failure ) and you get a root-prompt in a recovery console, then you give the command:

# e2fsck -b 32768 /dev/hda5

System will then check the filesystem with the information stored in that backup superblock and if the check was successful it will restore the backup to position 0.

If this is not working try using the other copy of Superblock located at the above mention location in your HD.

Read more
0

How to crash Linux?

As root, you can do whatever you want.
Try this command, as root (reconsider if you really want to crash):
# cp /dev/zero /dev/men
As root, you can even erase all the files on your system with a similarly innocuously looking one-liner (don’t do it):
# rm -rf /

This is not to say that Linux is easy to crash, but that the system administrator (”root”) has the complete power over the system so think before when working on Linux as “root” user.
Read more
0

Create Linux Filesystem From An Ordinary File

Under Linux, you can create a regular file, format it as an ext2, ext3, or reiser file system, and then mount it just like a physical drive. It's then possible to read and write files to this newly-mounted device. You can also copy the complete file system, since it is just a file, to another computer.

First, you want to create a 20MB file or any size you want by executing the following command:

     $ dd if=/dev/zero of=disk-image count=40960

     40960+0 records in
     40960+0 records out

Next, to format this as an ext3 filesystem, you just execute the following command:

     $ /sbin/mkfs -t ext3 -q disk-image
     mke2fs 1.32 (09-Nov-2002)
     disk-image is not a block special device.
     Proceed anyway? (y,n) y

You are asked whether to proceed because this is a file, and not a block device. That is OK.

Next, you need to create a directory that will serve as a mount point for the loopback device.

      $ mkdir fs

You must do the next command as root, or with an account that has superuser privileges.

      # mount -o loop=/dev/loop0 disk-image fs

You can now create new files, write to them, read them, and do everything you normally would do on a disk drive. To make normal user to use this filesystem you need to give valid permission to the directory holding this filesystem.


Read more
Related Posts with Thumbnails