Archive for Newbie

Slightly more advanced uses of find for finding files between two dates/times

I’ve used find commands before and talked about them on Unixsupport.com, however I recently needed to stack a few find commands and found it less then easy to search out support… so:

find . \( -ctime +1 -not -ctime +3 \) | xargs -I{} ls -l {}

find files, in the current directory, that were created more then 1 day ago, not, more then 3 days ago, then send them over to ls to show them to me

Comments

Simple Testing of SMTP with Telnet

SMTP is a pretty straightforward protocol, and thats why it is so simple for spammers to mess with, but it also makes it easy for us to test if its working.

Many times you want to verify your server before bringing it live in your MX record or even just test to make sure everything is good on your sendmail side.

Simple way of doing this is using telnet from the command line:

$ telnet your.mail.server.name.com 25

Trying your.mail.server.name.com…
Connected to your.mail.server.name.com.
Escape character is ‘^]’
220 your.mail.server.name.com ESMTP Sendmail 10.0.1/10.0.1; Mon, 13 Aug 2007 18:36:27 -0400 (EDT)

HELO your.doman.com
250 your.mail.server.name.com, nice to meet you!
MAIL FROM:you@your.domain.com
250 2.1.0 you@your.domain.com… Sender ok

RCPT TO:me@your.domain.com
250 me@your.domain.com… Recipient ok
DATA
354 Enter mail, end with “.” on a line by itself

Put your message here, and finish with a line that
only contains a period, so hit enter, then hit period, then hit enter, like below
.

250 2.0.0 l7DMerMV044784 Message accepted for delivery
QUIT

That should give you a good idea of what areas are having issues, so if you receive something like:
550 5.7.1 someone@someother.com… Relaying denied

you know that the mail server isn’t setup to receive messages for that user, or that the server is mis-configured for relaying.

Comments

Troubleshooting qpage - a paging daemon

A common monitoring system, Nagios, uses qpage for sending alphanumeric pages via a modem.. yes it sound insane, but think about what happens to your monitoring system when your internet connection drops, unless your using outside monitoring, your not going to get that email to send you a page.

I ran into an issue with the modem not dialing quickly enough and had a few tips for getting it going.

1) Make sure that your calling the correct dialing group.

2) Check the modem in minicom, load it up, and do a few

AT[ENTER]
OK
ATZ[ENTER]
OK

to make sure the modem is reset, and then do a

ATDT 2125551212[ENTER]
{it should pause and dial the number [in this case, 212-555-1212] and either tell you BUSY, CONNECTED, or error out.

Just thought I’d toss out a few reminders.

Comments

Setting up ip aliases in freebsd

Often times in a server environment your going to need to setup multiple ip addresses to the same ethernet card, it’s really a simple procedure, and the way that I generally do these things is create a file called /etc/rc.aliases and include the alias line in there:

If the IP is on the same netmask:

/sbin/ifconfig fxp0 alias 192.0.3.9 netmask 255.255.255.255

Otherwise, just specify the network address and netmask as usual:

/sbin/ifconfig fxp0 alias 172.16.0.223 netmask 255.255.255.0

once you’ve added each line, then add a line in the /etc/rc.local file

sh /etc/rc.aliases

This way when you want to edit the aliases on each server you have them all in one location.

Comments (1)

NTP — Keeping your clock in sync

One of the most insane things about working in the unix world is that it complains when the system clock on your computer is wrong. There is nothing more disturbing then when you create a tarball on another machine and extract it on yours and it complains that the files were created in the future.

A great way to deal with this problem is a system called ntp, network time protocol.

Network Time Protocol (RFC-1305), or more commonly known as NTP is pretty simple to setup, most OS’s are simply an RPM or ports tree install away.

(freebsd)
Connect to your machine and su - to root, then:

# cd /usr/ports/net/ntp
# make

# make install
# rehash

once thats done, simply run:

# ntpdate time.nist.gov
5 Nov 19:46:40 ntpdate[46439]: step time server 192.43.244.18 offset -2.467839 sec
#

This will update your server to the current time.

My suggestion is to set this up as a nightly cronjob,

# vi /etc/crontab

and add the line:

0 2 * * * root /usr/sbin/ntpdate time.nist.gov > /dev/null

and restart cron (

# killall -HUP cron

And you should be good to go!

Comments

using tar via ssh — for remote file transfers

Having to move large sums of data between boxes is part of an admins life… and sometimes those machines are across the country, and your moving a bunch of sensitive data, and the bosses want to make sure no one can sniff at it… ok, whatever boss ;)

So here’s what I do, use friendly unix tar, and ssh pipe it to another machine.

Lemme show you some examples:
This shows you how to send files FROM the local machine TO a remote machine.

$ cd directory-with-files
$ tar cf - . | ssh username@remoteserver.com “cd /directory-to-put-files; tar xf -” [ENTER]

Ok, you may be asking me to explain this madness:
Change to a directory with files you want to transfer

tar cf - . - create a tar file, with the name “-”, which means output to screen, in the directory “.” (currently in, or right here)

| ssh username@remoteserver - setup an ssh connection to the remote server
“cd /directory-to-put-files; tar xf -” [ENTER] - once connected, change directorys on the local machine, and then EXTRACT that tar file named “-” or output to the screen.

In this case, the output to the screen will be piped thru ssh to the other computer and boom your set.



Now, in order to reverse the logic and transfer FROM a server TO the local machine:

$ cd directory-to-put-files
$ ssh username@remoteserver.com “cd /directory-to-get-files; tar cf - .” | tar xf - [ENTER]

Try it out :)

Comments (1)

« Previous entries ·