Posts Tagged ‘linux’

WARNING: MaxClients of 1000 exceeds ServerLimit value of 256 servers

Yesterday night I was ready to scream at my VPS, because I kept getting:

WARNING: MaxClients of 1000 exceeds ServerLimit value of 256 servers,
lowering MaxClients to 256. To increase, please see the ServerLimit directive.Read More

Sadly, in my tiredness and googleing I didn’t immediately find the answer until today shortly after I woke up, I finally found the solution here. In short “ServerLimit” MUST MUST gobefore MaxClients otherwise this error will show up, no matter how many times you check that you spelled everything right, and how many times you restart the service!

ServerLimit             1000
MaxClients              1000

Simple fix, but if you don’t know, it can be quite a headache!

Linux – Cat command

Heres a nice something some of you may find useful:

root@sat1 [/usr/local/apache/domlogs/ommited]# cat ommitedsite.com | awk ‘{print $1}’ | cut -d: -f1 | sort | uniq -c | sort -n
root@sat1 [/usr/local/apache/domlogs/ommited]#

Basically says how many times the ip has hit your site:

182 81.82.240.15
192 202.28.180.202
203 188.220.62.52
204 41.223.251.18
225 81.27.128.142
228 124.157.129.20

Looks good in terminal, usually I use it for checking if a box of mine is getting flooded or if theres simply getting too much traffic. That command looks like this:

netstat -ntu | awk ‘{print $5}’ | cut -d: -f1 | sort | uniq -c | sort -n

Obviously if your getting too much and want to analyse the outpout in a text file, append > output.txt, and use vi, or nano to look into it.

netstat -ntu | awk ‘{print $5}’ | cut -d: -f1 | sort | uniq -c | sort -n > output.txt

Hope this helps some of you.

cPanel VPS DNS problem

Well, another minor set back when setting up my VPS today, every time I tried to assign an ip address it would just sit there indefinitely, however if any of you need a fix, after a bit of google searching I stumbled upon this:

WHM -> Server Configuration -> Tweak Settings and checking Disable whois lookups for the nameserver IP manager

My server is running: cPanel 11.24.5-R38506 – WHM 11.24.2 – X 3.9, CENTOS 5.3 i686 virtuozzo.

The fix.

WinRAR on CentOS with cPanel

I’ve seen alot of people get stumped by an error that looks like this, rar: /lib/libc.so.6: version `GLIBC_2.7′ not found (required by rar) even I did for a while, after numerous google searches I found nothing, however today I finally ran into the site that saved me!

Basically

rm -rf /usr/bin/rar
ln -s /usr/local/rar/rar_static /usr/bin/rar

For me the location varied a little because I extracted everything in a different spot!

http://www.123tweak.com/how-to-install-winrar-on-centos/

Second Perl Experiment

After a bit of reading online and book reading (Learning Perl 2nd Edition), I came up with this;

#!/usr/bin/perl
# Revision 1 - 09-03-09 1530
# Countr Code list, stdin, perl
# SRC for codes: http://www.kropla.com/dialcode.htm

use Term::ANSIColor qw(:constants);
$Term::ANSIColor::AUTORESET = 1; #reset colors after each line

print GREEN "Please enter the country code you are trying to look up.\n";
$cc = <STDIN>;
chomp $cc;
if ($cc eq "1") {
print GREEN "United States of America or Canada.\n";
}
elsif ($cc eq "93") {
print RED "Afghanistan.\n"; }
elsif ($cc eq "355") {
print RED "Albania.\n"; }
elsif ($cc eq "213") {
print RED "Algeria.\n"; }
elsif ($cc eq "1684") {
print RED "American Samoa.\n"; }
elsif ($cc eq "376") {
print RED "Andorra.\n"; }
elsif ($cc eq "244") {
print RED "Angola.\n"; }
elsif ($cc eq "1268") {
print RED "Antigua.\n"; }
elsif ($cc eq "54") {
print RED "Argentina.\n"; }
elsif ($cc eq "374") {
print RED "Armenia.\n"; }
elsif ($cc eq "297") {
print RED "Aruba.\n"; }
elsif ($cc eq "247") {
print RED "Ascension.\n"; }
elsif ($cc eq "61") {
print RED "Australia.\n"; }
elsif ($cc eq "672") {
print RED "Australian Extrernal Territories.\n"; }
elsif ($cc eq "43") {
print RED "Austra.\n"; }
elsif ($cc eq "994") {
print RED "Azerbaijan.\n"; }
elsif ($cc eq "1242") {
print RED "Bahamas.\n"; }
elsif ($cc eq "973") {
print RED "Bahrain.\n"; }
elsif ($cc eq "880") {
print RED "Bangladesh.\n"; }
elsif ($cc eq "1246") {
print RED "Barbados.\n"; }
elsif ($cc eq "1268") {
print RED "Barbuda.\n"; }
elsif ($cc eq "375") {
print RED "Belarus.\n"; }
elsif ($cc eq "32") {
print RED "Belgium.\n"; }
elsif ($cc eq "501") {
print RED "Belize.\n"; }

Some of you may find this to be pretty elementary, but lets see what I can come up with in the next day or two. Essentially all this does is looks for a country that matches the code you put in. It does not include all countries, but I think I got the idea of elsif in perl.

Experimenting with Perl

Well, this is my first actual experiment with Perl. All it does is chmod 750 some fetch utilities. In my next build I want to set it up so that if the file exists, and if it doesnt, it will prompt you that the file is not on the system and it is being skipped.

#!/usr/bin/perl
# Revision 1 - 09-03-09
# Initial Build
# Chmod 750 of rcp, wget, lynx, links, elinks, scp, nc, ftp, telnet, curl
 
print ("Permissions?\n");
system ('chmod 750 -v /usr/bin/rcp');
system ('chmod 750 -v /usr/bin/wget');
system ('chmod 750 -v /usr/bin/lynx');
system ('chmod 750 -v /usr/bin/links');
system ('chmod 750 -v /usr/bin/elinks');
system ('chmod 750 -v /usr/bin/scp');
system ('chmod 750 -v /usr/bin/nc');
system ('chmod 750 -v /usr/bin/ftp');
system ('chmod 750 -v /usr/bin/telnet');

Lets see how this turns out over the next few days.

Update before I go to bed:

#!/usr/bin/perl
# Revision 1 - 09-03-09 0055
# Initial Build
# Chmod 750 of rcp, wget, lynx, links, elinks, scp, nc, ftp, ssh, telnet, curl
#
# Revision 2 - 09-03-09 0113
# If else statements are in place, they can handle if the file does or does not exist
 
print ("Permissions lol...\n");
$filename = '/usr/bin/wget';
if (-e $filename) {
print "Found $filename\n";
system ("chmod 750 -v '/usr/bin/wget'");
}
else
{ print "File $filename, not found\n";
}
$filename = '/usr/bin/curl';
if (-e $filename) {
print "Found $filename\n";
system ("chmod 750 -v '/usr/bin/curl'");
}
else
{ print "File $filename, not found\n";
}
$filename = '/usr/bin/rcp';
if (-e $filename) {
print "Founds $filename\n";
system ('chmod 750 -v /usr/bin/rcp');
}
else
{ print "File $filename, not found\n";
}
$filename = '/usr/bin/lynx';
if (-e $filename) {
print "Found $filename\n";
system ('chmod 750 -v /usr/bin/lynx');
}
else
{ print "File $filename, not found\n";
}
$filename = '/usr/bin/elinks';
if (-e $filename) {
print "Found $filename\n";
system ('chmod 750 -v /usr/bin/elinks');
}
else
{ print "File $filename, not found\n";
}
$filename = '/usr/bin/scp';
if (-e $filename) {
print "Found $filename\n";
system ('chmod 750 -v /usr/bin/scp');
}
else
{ print "File $filename, not found\n";
}
$filename = '/usr/bin/nc';
if (-e $filename) {
print "Found $filename\n";
system ('chmod 750 -v /usr/bin/nc');
}
else
{ print "File $filename, not found\n";
}
$filename = '/usr/bin/ftp';
if (-e $filename) {
print "Found $filename\n";
system ('chmod 750 -v /usr/bin/ftp');
}
else
{ print "File $filename, not found\n";
}
$filename = '/usr/bin/telnet';
if (-e $filename) {
print "Found $filename\n";
system ('chmod 750 -v /usr/bin/telnet');
}
else
{ print "File $filename, not found\n";

}
print “Permissions set to 750 across the board.\n”

And now the last revision of the night, colors.

#!/usr/bin/perl
# Revision 1 - 09-03-09 0055
# Initial Build
# Chmod 750 of rcp, wget, lynx, links, elinks, scp, nc, ftp, ssh, telnet, curl
#
# Revision 2 - 09-03-09 0113
# If else statements are in place, they can handle if the file does or does not exist
#
# Revision 3 - 09-03-09 0124
# Colors?
 
use Term::ANSIColor qw(:constants);
$Term::ANSIColor::AUTORESET = 1; #reset colors after each line, otherwise everything will be green and red
 
print ("Permissions lol...\n");
$filename = '/usr/bin/wget';
if (-e $filename) {
print GREEN "Found $filename\n";
system ("chmod 750 -v '/usr/bin/wget'");
}
else
{
print RED "File $filename, not found\n";
}
$filename = '/usr/bin/curl';
if (-e $filename) {
print GREEN "Found $filename\n";
system ("chmod 750 -v '/usr/bin/curl'");
}
else
{ print RED "File $filename, not found\n";
}
$filename = '/usr/bin/rcp';
if (-e $filename) {
print GREEN "Found $filename\n";
system ('chmod 750 -v /usr/bin/rcp');
}
else
{ print RED "File $filename, not found\n";
}
$filename = '/usr/bin/lynx';
if (-e $filename) {
print GREEN "Found $filename\n";
system ('chmod 750 -v /usr/bin/lynx');
}
else
{
print RED "File $filename, not found\n";
}
$filename = '/usr/bin/elinks';
if (-e $filename) {
print GREEN "Found $filename\n";
system ('chmod 750 -v /usr/bin/elinks');
}
else
{ print RED "File $filename, not found\n";
}
$filename = '/usr/bin/scp';
if (-e $filename) {
print GREEN "Found $filename\n";
system ('chmod 750 -v /usr/bin/scp');
}
else
{ print RED "File $filename, not found\n";
}
$filename = '/usr/bin/nc';
if (-e $filename) {
print GREEN "Found $filename\n";
system ('chmod 750 -v /usr/bin/nc');
}
else
{ print RED "File $filename, not found\n";
}
$filename = '/usr/bin/ftp';
if (-e $filename) {
print GREEN "Found $filename\n";
system ('chmod 750 -v /usr/bin/ftp');
}
else
{ print RED "File $filename, not found\n";
}
$filename = '/usr/bin/telnet';
if (-e $filename) {
print GREEN "Found $filename\n";
system ('chmod 750 -v /usr/bin/telnet');
}
else
{ print RED "File $filename, not found\n";
}
print "Permissions set to 750 across the board.\n"

Additional reading:
http://perl.about.com/od/programmingperl/qt/perlexists.htm
http://perl.active-venture.com/lib/Term/ANSIColor.html
http://www.linuxforums.org/forum/linux-programming-scripting/116383-how-can-i-use-wget-perl.html

Ubuntu 9.0.4 – Installing SSHD

So after isntalling a fresh copy of Ubuntu today, I try:

r00t@r00t-laptop:~$ sudo apt-get install openssh-server
Reading package lists… Done
Building dependency tree
Reading state information… Done
Package openssh-server is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
E: Package openssh-server has no installation candidate

No big deal, lets look up how to fix this online.

After a whole 2 minutes of googling I figure out all I need to run are:

sudo apt-get update

sudo apt-get install ssh-server

Done. Now fire up putty and try to connect or “ssh -p 22 localhost”.