Saturday, March 8, 2008

nixCraft Linux Sys Admin Blog

nixCraft Linux Sys Admin Blog

Link to nixCraft Linux Sys Admin Blog

Lighttpd Control a Directory Listing With mod_dirlisting

Posted: 07 Mar 2008 10:48 PM CST

Lighttpd web server will generate a directory listing if a directory is requested and no index-file was found in that directory. mod_dirlisting is one of the modules that is loaded by default and doesn’t have to be specified on server.modules to work.

Task: Enable Directory Listings Globally

Open lighttpd configuration file:
# vi /etc/lighttpd/lighttpd.conf
Append / modify
server.dir-listing = "enable"
OR
dir-listing.activate = "enable"
Save and close the file. Restart lighttpd:
# /etc/init.d/lighttpd restart
To disable directory listing, use:
dir-listing.activate = "disable"

Enable directory listing only for a directory

You can also enable or disable listing on selected url / directory combination. For example, display directory listing only for /files/:
$HTTP["url"] =~ "^/files($|/)" { server.dir-listing = "enable" }
OR
$HTTP["url"] =~ "^/files($|/)" { dir-listing.activate = "enable" }

Further readings:

Related Posts:


Looking for the best talent? Post your job opening on this and 50+ top tech sites.

Copyright © nixCraft. All Rights Reserved. Browse all UNIX / IT Tech Jobs. Support nixCraft when you shop at amazon. Thanks!

Display IP Address Allocation Table According to Subnet Mask

Posted: 07 Mar 2008 10:24 PM CST

If you need a tabular representation of relationships and source of the various variables representing a chunk from /32 to /0 subnets use iptab command. This is useful if you are allocating IPs to end users. Following information is displayed with the command:
=> CIDR notation

=> Network Mask

=> Available Networks

=> Available Hosts per network

=> Total usable hosts

$ iptab
Sample output:

+----------------------------------------------+ | addrs   bits   pref   class  mask            | +----------------------------------------------+ |     1      0    /32          255.255.255.255 | |     2      1    /31          255.255.255.254 | |     4      2    /30          255.255.255.252 | |     8      3    /29          255.255.255.248 | |    16      4    /28          255.255.255.240 | |    32      5    /27          255.255.255.224 | |    64      6    /26          255.255.255.192 | |   128      7    /25          255.255.255.128 | |   256      8    /24      1C  255.255.255.0   | |   512      9    /23      2C  255.255.254.0   | |    1K     10    /22      4C  255.255.252.0   | |    2K     11    /21      8C  255.255.248.0   | |    4K     12    /20     16C  255.255.240.0   | |    8K     13    /19     32C  255.255.224.0   | |   16K     14    /18     64C  255.255.192.0   | |   32K     15    /17    128C  255.255.128.0   | |   64K     16    /16      1B  255.255.0.0     | |  128K     17    /15      2B  255.254.0.0     | |  256K     18    /14      4B  255.252.0.0     | |  512K     19    /13      8B  255.248.0.0     | |    1M     20    /12     16B  255.240.0.0     | |    2M     21    /11     32B  255.224.0.0     | |    4M     22    /10     64B  255.192.0.0     | |    8M     23     /9    128B  255.128.0.0     | |   16M     24     /8      1A  255.0.0.0       | |   32M     25     /7      2A  254.0.0.0       | |   64M     26     /6      4A  252.0.0.0       | |  128M     27     /5      8A  248.0.0.0       | |  256M     28     /4     16A  240.0.0.0       | |  512M     29     /3     32A  224.0.0.0       | | 1024M     30     /2     64A  192.0.0.0       | | 2048M     31     /1    128A  128.0.0.0       | | 4096M     32     /0    256A  0.0.0.0         | +----------------------------------------------+ 

iptab is nothing but a perl script and part of perl-Net-IP package. Here is script listing (download link):

#!/usr/bin/perl  eval 'exec /usr/bin/perl  -S $0 ${1+"$@"}'     if 0; # not running under some shell  use Net::IP; use strict;  print "+----------------------------------------------+ | addrs   bits   pref   class  mask            | +----------------------------------------------+ ";  my ($ip,$size,$class,$bits,$len);  my $ip = new Net::IP('0');  for my $len (reverse (0..32)) {          $ip->set("0.0.0.0/$len");          $size = $ip->size();          if ($size >=1048576) # 1024*1024         {                 $size /= 1048576;                 $size .= 'M';         }         elsif ($size >= 1024)         {                 $size /= 1024;                 $size .= 'K';         };          $len = $ip->prefixlen();         $bits = 32 - $len;          if ($bits >= 24)         {                 $class = 2**($bits-24);                 $class.= 'A';         }         elsif ($bits >= 16)         {                 $class = 2**($bits-16);                 $class.= 'B';         }         elsif ($bits >= 8)         {                 $class = 2**($bits-8);                 $class.= 'C';         }          printf ("| %5s %6s %6s %7s  %-15s |\n",                 $size,$bits,'/'.$len,$class,$ip->mask());  };  print "+----------------------------------------------+\n"; 

Related Posts:


Looking for the best talent? Post your job opening on this and 50+ top tech sites.

Copyright © nixCraft. All Rights Reserved. Browse all UNIX / IT Tech Jobs. Support nixCraft when you shop at amazon. Thanks!

Linux sudo Configuration

Posted: 08 Mar 2008 01:09 AM CST

Q. Can you tell me how to configure sudo to provide access to end users? How do I allow to run programs with the security privileges of another user using sudo?

Answer to "Linux sudo Configuration"

Looking for the best talent? Post your job opening on this and 50+ top tech sites.

Copyright © nixCraft. All Rights Reserved. Browse all UNIX / IT Tech Jobs. Support nixCraft when you shop at amazon. Thanks!

No comments: