check smtp from commnad line

telnet smtp command line image

When working with Linux servers, you need to get mails from them,
they like to alert you on different issues like “help – im dying from lack of space” etc.

mail forwarding

you can easily setup mail forwarding in your sendmail through an external mail server.
all the sendmail config files are in /etc/mail.
edit the mailertable file and add a line like this:

domain    smtp:company_mail_server

for example – lets say you work for data.com and you want to send mails to the data.com domain from your Linux machine through the data.com mail server which is called mail.data.com, so your line in mailertable should be:

data.com    smtp:mail.data.com

test mail

to check that your company mail server will actually allow you to forward mails through it, you need to connect to the smtp service and try to send a mail, this will work from the command line:

telnet mail.data.com 25

this will try to connect to the mail server smtp port and if there is no firewall problem then you should see something like 220 localhost.localdomain ESMTP Sendmail 8.13.8/8.13.8 as a reply.

at this point you try to send a mail through the server.

send mail from command line

telnet to the machine and copy paste this text after editing it:

helo domain_name
mail from: test@email
rcpt to: test@email
data
From: test@email
Subject: subject
whatever you want the mail to have in the body.
.

(the “.” in the end will finish the mail – dont forget it).

so lets explain:
helo domain_name – change the domain_name to your domain – data.com for example
mail from: the email you want the mail to look like it was sent from – test@data.com
rcpt to: who you want to get this test mail – admin@data.com
so the new updated test text would look like:

helo data.com
mail from: test@data.com
rcpt to: admin@data.com
data
From: test@data.com
Subject: test mail from command line
this is test number 1
sent from linux box
.

if there arent any permissions issues the mail server should show you something like: 250 2.0.0 n4CNnNPG003499 Message accepted for delivery

mail queue

there is another nice command line tool to show you whats your Linux server current mail queue: mailq:

[root@centos mail]# mailq
/var/spool/mqueue (1 request)
—–Q-ID—– –Size– —–Q-Time—– ————Sender/Recipient———–
n4CNnNPG003499        0 Wed May 13 02:49 test@email
(host map: lookup (email): deferred)
test@email
Total requests: 1

Technorati Tags: , ,

SEO guides – the best i found on the net

best seo guides

SEO – the art of search engine optimization, is a subject worth learning, and im reading and searching for information and tutorials about it all the time. many sites are talking about SEO and give a lot examples and full guides, but this week i found two really great guides worth reading and applying.

SEO Tutorial

The first guide is from The Dough Blogger which is in interesting site,
it has only 3 pages at all, and yet it has a Google Page rank of 4, which is impressive for such a small site.
The tutorial itself is The Ultimate Guide to Starting a Money Making WordPress Blog,
and you can grab at it here.
Although some of the recommendations in it i didn’t apply to my site, there were other that i did the first thing after going over the tutorial, a great example would be the theme <h2> tags.
In the theme im using here, the right sidebar has widgets in it, and their titles from the wordpress default are <h2>, which makes Google think the important words on my site are pages and categories.
Another point i found interesting is the update Services: when you publish a new post the wordpress software can push that post to different update services, but for that you need to add them to the wordpress config.

Make money online case study

Now this guide left me awake until 4 AM, i couldn’t stop reading it, it was so inspiring and moving.
On the googlelady site i found this guide, with the weekly steps she did to generate revenue from her new from scratch web site.
she started a new fresh site, with no page rank, and on a niche she doesn’t know anything about, and with only 100$ in her budget, and a 3 months time limit.
after 3 months she created 11,000$ from that site.
Its an amazing guide and im still reading it over and over and applying the lessons.

Free SEO Tools

Another good link is for the good guys at gscripts with their Free SEO Tools page,
they have backlink checker – which will also show you the page rank for each link,
keyword density tool for you to count the most appearing words on your site,
and search engine position tool – which helps you find your location on the list for a specific search keyword.

I’m starting to apply these guides now, and ill update when i see results!!

Technorati Tags:

installing wordpress on windows

installing wordpress on windows image

In my last post i talked about installing apache and mysql on windows for development needs, and now we can add to that install a wordpress blog.

when i do changes to the php code on wordpress i first test it on the local version of the them to make sure its good before going with it public.

1) get the wordpress files

first thing – download the wordpress install file from the website,
the default html folder for xampp is C:\xampp\htdocs so lets create a folder for our blog there: C:\xampp\htdocs\testblog and unzip the wordpress files into that location.

2) setup the MySQL user and database

go to http://localhost/phpmyadmin/index.php and choose the Privileges tab,
find the “Add a new User” link.
fill in a user name – anything you want, and a password.
in the “Database for user” section make sure to check: “Global privileges” press the “Check All” link to give the user all the privileges (this is something you should do only on a development server!!! )

press the Go button.

at this point its best to reload the privileges tab and use the “reload the privileges” link to make sure the user is loaded.

3) edit the wp-config.php file

go to C:\xampp\htdocs\testblog where all the blog files are located and rename wp-config-sample.php to wp-config.php, edit the file and setup:
edit the DB-NAME line and replace “putyourdbnamehere” with the username we created a minute ago,
replace “usernamehere” with the the same user name we just used,
“yourpasswordhere” should be replaced with the user’s password,
and also you have the “Authentication Unique Keys” part where you need to create keys for your blog,
you can use this wordpress.org page which will create the keys for you. copy and paste the keys to the config file.

4) run the wordpress config php

if you installed the wordpress files into “testblog” folder, the install file will be at: http://localhost/testblog/wp-admin/install.php

choose a blog title and an email, and you have your own development blog running.
don’t forget to change the admin password first thing…

you can access your new blog at: http://localhost/testblog/

from here now you can do all the changes and testing you want, including themes and plugins, before you upload them to your live blog.

Technorati Tags: , , , ,

Apache and MySQL on windows

xampp apache and mysql on windows

Although I’m a great Linux fan, i still have Windows on my personal computer, since the computer is not used by me alone, and although i have various Linux OS installed on this same computer, most of the time its on the windows mode. so what do i do when i need to test something on wordpress or mediawiki?

For that reason i needed a development environment on my home computer that will run Apache, MySQL, php and Perl. There are some ways to go about that – i could have installed Cygwin, which is a Linux-like environment for windows.

Another way to go about it is to install the windows version Apache and mysql and php and perl.

These two options are fine solutions but they will need some more work on them , other then the point and click option which is xampp.
xampp for windows version 1.7.1 on default will include all of these:

  • Apache HTTPD 2.2.11 + Openssl 0.9.8i
  • MySQL 5.1.33
  • PHP 5.2.9
  • phpMyAdmin 3.1.3.1

and if you want to can add Perl 5.10.0-2.2.11 from their Add-Ons page.

The install process is a next,next,next version of a regular windows install, and in the the end you have everything installed into the default location at C:\xampp.

xampp control panel

This is the windows control panel that stops and starts the Apache and MySQL for you if you don want to install them as services, personally i prefer to start them when I’m developing since they are resource heavy applications.

Some default file locations:
the html and php files are installed to C:\xampp\htdocs
Perl scripts should be placed here: C:\xampp\cgi-bin
the php.ini (php config file) can be found at: C:\xampp\apache\bin\php.ini
httpd.conf (apache config file) is located in: C:\xampp\apache\conf

Note that for Unix Perl scripts you need to replace the first line with the location of the Perl binary on your windows, so it should look like:
#!”C:\xampp\perl\bin\perl.exe”

Another not is that the xampp on default is set to work with php 5 , but you can from the xampp configure page which is at http://localhost/xampp/ , use the “PHP switcher” and change the install to work with php 4 instead.

And that’s it – your local development website is ready and is available at: http://localhost/ to play with.

Technorati Tags: , , , ,

13 books and magazines for linux sysadmins

This is a list of books and magazines i read through the years to learn my job,
there are many other good books as well, but these are my must haves.

1) Magazines:

linux format linux magazin

These two magazines I have been reading for years and they keep getting me fresh ideas and money savers for work,
they have some tutorials for beginners, some more heavy weight material, and fun projects for the free time (ach, whose kidding, what free time…).

although the info in them is usually a little out of date – they are published once a month and the industry is moving so fast, they do have a lot of good ideas in them, and it much more fun to snuggle with a color magazine then sit in front of the screen to read.

2) DNS:

DNS and BIND (5th Edition)

DNS and bind – every Linux sysadmin should know networking as well, and DNS is one of the pillars of the Internet,
even if you are not responsible to a DNS server, if you are working with anything related to the web or networking, you are using DNS, and knowing this subject good will help you solve many networking and web related problems.

3) Sys Admin handbooks:

linux_system unix_system

These are two books from the same authors, both are fantastic easy to use, in depth system administration books,
but you should buy just one out of the two since they very much a like.

so which one to buy? that depends on what flavors of unix/linux you need this info for:
UNIX System Administration Handbook (3rd Edition)
if you have many different unix servers at work you should get the unix book, it covers Solaris 2.7, HP-UX 11.00, Red Hat Linux 6.2, and FreeBSD 3.4.
a little out dated, but still very helpful as it will show you how to do the same thing in the different systems.

Linux Administration Handbook
on the other hand, if you have different linux versions running this book covers redhat, suse and debian – again showing you how to do the same thing in the different flavors.

4) PHP scripting

Different scripting languages are good for different things, PHP is good for building web interfaces for actions you wish your users to do without a shell account on your server.
php allows you to easily build forms and web pages to manipulate files on your server, and changing passwords, restore and backup files, etc…

php_cookbook programming_php

Programming PHP
Is the php book to start with, it takes you through the step of learning a new language and writing easy code.

PHP Cookbook
this php book will give you real world questions and answers for php coding – like how to open and read each word in a local or remote files, working with other web pages etc..

5) PERL scripting

PERL is faster to use when you want to do heavy weight work on databases or files and text manipulation and sorting.

Learning Perl, 5th Edition
The learning perl book will teach you perl from the beginning with real live samples and mind you – perl is tricky.

Programming Perl (3rd Edition)
this is a more in depth book for perl.

6) Bash shell

bash is the most popular shell for the linux environment, its strong and flexible and allows you to do many manipulations from the command line on files and texts, and its a great scripting tool to ease the work of a weary linux sysadmin (or lazy – its a great moto – always write something once).

Learning the bash Shell: Unix Shell Programming

and

bash Cookbook: Solutions and Examples for bash Users

as you can see by now, i really like the combination of a learning book and a cookbook 😉

7) security

hacking_linux_exposed
Hacking Exposed Linux, 3rd Edition

learning what your enemy knows will help you better understand where to look for security holes,
working in this job turns you slowly into a paranoid sysadmin if you wish to continue working, and this book will give you an insight into where likely holes in your servers will be and how to clear them.

8). IT management

practice_system
Practice of System and Network Administration, The (2nd Edition)

Never forget, your not only a linux sysadmin, you are also working in the IT environment and your decision and work is not just linux, you also need to consider network and the other servers and services around you.
this book is about the practice itself, not the technical stuff which we should all learn, and its based on the vast years of experience the authors have.
for example – how to build a support system – the people the software etc,
or how to structure your mail system so you will have place for growth when the company grows.

one of the best books I have read!!!

Technorati Tags: , , ,

disable selinux

The new selinux mechanism provides many security policies through ACL management,
it wil greatly enhance your overall security on your server, and you can read some about it on wikipedia.
but when working on a development server it can slow work down, so sometimes disabling this feature is the best and fast option.
for example when your web server or php script wont delete a file it has full permissions on, this could be caused by selinux.

first check if selinux is enabled:

/usr/sbin/getenforce

will show you the current status for selinux.
the usage for the command is:

/usr/sbin/setenforce –help
usage: /usr/sbin/setenforce [ Enforcing | Permissive | 1 | 0 ]

and to disable it you can either run:

/usr/sbin/setenforce Permissive

or edit this file:
/etc/selinux/config
to set the selinux settings on boot.

Technorati Tags: , ,

proxy settings for the command line

  

When using applications from the command line,
you will sometimes need to setup a specific proxy for them to use, if you don’t have a direct access to the Internet from the server you are working on.

in some of these application you can setup this through the app switches itself, but simpler apps just use the system network settings.

to fix this you can first check what current settings you have now with:

ENV | grep -i proxy

this should show you the current proxy settings you have.

to add your own settings do:

export http_proxy=”http://<proxy-server-ip>:<port>”
export ftp_proxy=”http://<proxy-server-ip>:<port>”

for example:

export http_proxy=”http://192.168.0.10:8080″

after that, just run your command line app, it should pick up and use these settings.

   

 

Technorati Tags: , , ,

Check a web page exists

Here is a short method to check if a web page exists from a perl script,
this script will test the existense of a page and do something as a result:

#!/usr/bin/perl
use LWP::Simple;
print “Content-Type: text/html\n\n”;

$url = “http://site.com/“;

if (head($url)) {
# ok document exists
print “OK: found $url”;
} else {
# something is not well
print “PROBLEM: $url is missing”;
}

This script is using the libwww-perl package.

Technorati Tags: , ,