Monday, December 27, 2010

Why the Church of BSD

BSD has been through many Holy Wars and has been called a religion by many people for a long time. Even it's experts are called Guru's , High Priests and Wizards. What BSD programmers do has sometimes been called VooDoo, Alchemy and Black Magic. People who violate our way of doing things are declared Heretics, and publicly flamed! We even have our own official canonical way of doing things and this is in the source code.

The Source code is our Bible.


It seems we are long over due for a formal Church of BSD.


Canonical is an adjective derived from canon. It essentially means "standard", "generally accepted" or "part of the back-story." Canonical in my context means reduced to the simplest and most significant form possible without loss of generality.
This word is usualy used by theologians and canon lawyers to refer to the canons of the Eastern Orthodox and Roman Catholic churches, adopted by ecumenical councils.


Hacker Slang - Holy Wars From answers.com
[from Usenet, but may predate it; common] n. flame wars over religious issues. The paper by Danny Cohen that popularized the terms big-endian and little-endian in connection with the LSB-first/MSB-first controversy was entitled On Holy Wars and a Plea for Peace. Great holy wars of the past have included ITS vs. Unix, Unix vs. VMS, BSD Unix vs. System V, C vs. Pascal, C vs. FORTRAN, etc. In the year 2003, popular favorites of the day are KDE vs. GNOME, vim vs. elvis, Linux vs. [Free|Net|Open]BSD. Hardy perennials include EMACS vs. VI, my personal computer vs. everyone else's personal computer, ad nauseam. The characteristic that distinguishes holy wars from normal technical disputes is that in a holy war most of the participants spend their time trying to pass off personal value choices and cultural attachments as objective technical evaluations. This happens precisely because in a true holy war, the actual substantive differences between the sides are relatively minor. See also theology.

What about Chuck?


The BSD Logo.

One another occasion a very christian individual was noticing the devil logo, I tried to explain it was a daemon, not demon or devil and didn't have any satanic meaning, again they freaked.

You have to admit, that's sort of a Satanic symbol if you ever saw one, right?


From: FreeBSD.com
"Many people equate the word ``daemon'' with the word ``demon,'' implying some kind of Satanic connection between UNIX and the underworld. This is an egregious misunderstanding. ``Daemon'' is actually a much older form of ``demon''; daemons have no particular bias towards good or evil, but rather serve to help define a person's character or personality. The ancient Greeks' concept of a ``personal daemon'' was similar to the modern concept of a ``guardian angel'' --- ``eudaemonia'' is the state of being helped or protected by a kindly spirit. As a rule, UNIX systems seem to be infested with both daemons and demons." (p403) The earliest (and most popular) renditions of the BSD Daemon were created by John Lasseter.

That cute little red guy with the pitch fork is named Chuck


First Drawing with the Daemon Logo

Dictionary.com defines Daemon as A program or process that sits idly in the background until it is invoked to perform its task.

Historicaly though I always though of Chuck as more of a Gremlin really very much like the one portrayed in a Bugs Bunny cartoon "Falling Hare (1943)" before it was restored.



Officially Gremlins started in the 1920 at a RAF term for a low-ranking man saddled with oppressive assignments.

Gus the Airplane Military Insignia
Although this terms really take on color in World War II as a "an imaginary gnomelike creature who causes difficulties in aircraft."

Military Airplane Insignias

Also the Irish Gaelic word gruaimin, "ill-humored little fellow."

Drawing from Roald Dahl's book, "The Gremlins" Front Cover


This very much conjures up visions of these little gremlins running about secretly doing things.


From Roald Dahl's book, "The Gremlins"
"I've just found a nest of widgets," he said, and looked around in triumph. "Widgets?" said Stuffy. "Widgets? Never heard of them!"
But Jamface went on. "As I said, I've just found a nest of widgets located in the rear turret of my plane. There were twelve of them . very young ones."
"What are widgets?" asked Gus.
"It's very simple," said Jamface. "Widgets are the young of gremlins and fifinellas. No one knows until they grow up whether they are going to turn into males or females, but it's usually males; in each nest of twelve widgets only one will eventually turn into a fifinella."

The Church of BSD: Background

We are not a Satanic Cult Although we may be a cult, this has yet to be determined


One day I was at a restaurant explaining process control to one of my disciples.
I was mentioning how we have to kill the children (child processes) if they become unresponsive. Or we can even set an alarm for the children to kill themselves. That the parent need to wait (wait3) and acknowledge that the child has died or else it will become a zombie. The look of horror the woman sitting across had was unforgettable. I tried to explain it was a computer software thing but it was too late, she fled terrified, probably to call the police or something. I didn't really want to stick around too long to find out.
From: man ps Z Marks a dead process (a ``zombie'').

Hey, you just can't make up shit like this.

Don't forget that you have to Fork to Spawn Children, and the only way to Kill

On another occasion while being filmed doing a live video streaming event with Arthur C. Clarke, The camera filmed me key flying across the keyboard typing "kill 666". Just sort of odd the process ID, I didn't think much of it till It ended up in the final cut of a documentary video made about it.

And what about "chmod 666".

They say when you play a Microsoft CD backwards you can hear satanic messages...but that's nothing, if you play it forward it will install Windows! 
 
And what about Chuck?


 One another occasion a very christian individual was noticing the devil logo, I tried to explain it was a daemon, not demon or devil and didn't have any satanic meaning, again they freaked.

You have to admit, that's sort of a Satanic symbol if you ever saw one, right?

Read more at "What about Chuck".

BSD Unix History

Unix Started in AT&T Bell Labs in 1969. At time time is was freely shared as "scrap" The Berkely BSD 4.2 1983 OS was the first OS to support TCP/IP.
The Unix wars were the struggles between vendors of the Unix computer operating system in the late 1980s and early 1990s to set the standard for Unix henceforth. These battles are commonly held to have harmed the market acceptance of Unix and created a market gap that allowed the rise of Windows NT.

In the mid-1980s, the two common versions of Unix were BSD, from the University of California at Berkeley BSD4.2 released in 1983 , and System V, from AT&T. Both were derived from the earlier Version 7 Unix, but had diverged considerably. (This conflict was also known as the "UNIX wars" to some degree.) Further, each vendor's version of Unix was different to a greater or lesser degree.


A group of vendors formed the X/Open standards group in 1984, with the aim of forming compatible open systems. They chose to base their system on Unix.


X/Open caught AT&T's attention. To increase the uniformity of Unix, AT&T and leading BSD Unix vendor Sun Microsystems started work in 1987 on a unified system. This was eventually released as System V Release 4 (SVR4).

While this decision was applauded by customers and the trade press, other Unix licensees feared Sun would be unduly advantaged. They formed the Open Software Foundation (OSF), who released OSF/1, more closely based on BSD. AT&T and another group of licensees then formed UNIX International.

Technical issues soon took a back seat to vicious and public commercial competition between the two competing "open" versions of Unix, with X/Open holding the middle ground.

Linux kernel based on rewrite of Minux was released to the Internet in September 1991,

The first open source Unix port began in 1989 with 386BSD and first, incomplete traces of the port can be found in 4.3BSD NET/2 of 1991. It was first released in March 1992 (version 0.0) and in a much more usable version on July 14, 1992 (version 0.1).

Due to a lawsuit by AT&T, USL v. BSDi, some potentially so-called encumbered sources which existed within 386BSD were to be removed from all the derived systems, and the distribution of 386BSD was to be stopped. In late 1993


In 1993, AT&T sold Unix to Novell, who assigned trademark rights to X/Open. In 1996, X/Open and the OSF merged to form the Open Group, whose Single UNIX Specification is now the single standard for proprietary Unix. However, the damage to Unix's market share had been done.




BSD Unix

The BSD varients (FreeBSD, NetBSD, OpenBSD, etc) are UNIX based operating systems
that work on Intel PC based systems that have a reputation for being highly optimised,
highly secure and excellent (when decently configured) for keeping hackers at bay.


Linux does not compare all that well to BSD: having a reputation of being
a hacker's paradise to break into compared to BSD (FreeBSD at least).
FreeBSD (and the other BSD's) run some of the most intensely hit servers
on the globe, including ftp://ftp.cdrom.com. It can be said that the nicest
thing you can do for a hacker is replace Windows with Linux as not only is it
potentially easier to hack (one of the benefits of open source), but the system
becomes worth hacking into. The same cannot necessarily be said with BSD based UNIX's
which are built of sterner stuff to keep hackers at bay.


Thus the BSD based operating systems of which FreeBSD is one - have a reputation of being
better designed (by gurus no less!), more secure (and more security
conscious) and more robust than most other operating systems (including
Linux - an operating system - it is claimed - "written by kiddies - for kiddies").
Refer to:
FreeBSD, OpenBSD and SuSE 6.2 Eval Review by Keith Rankin
: "The differences between
FreeBSD and Linux used to be much more obvious than they are now.
Now it comes down to theology. The BSD world is still the 'high church' or Druid Unix. Blood will
be spilled on a stone altar at midnite when star systems are in
a certain alignment to learn the ways of this tribe. Linux is a
happier world. The spirits of Captain Kirk, Peter Pan and good beer come to mind."


("Buckets of Blood" and non-alcoholic prudery is official CCP14 computer operating system policy)

Remove all but the newest packages on hosts

Remove all but the newest packages on hosts

for h in $(ls XXX* | sed 's/\(\w*\)\..*/\1/' | sort -u ); do
ls -t $h*  | tail -n +4 
done | xargs sudo rm
 
list just packages. 
sed 's/\(\w*\)\..*/\1/'  

this turns "XXXyyy-1.23.rpm" in to XXXyyy-1
sort -u 

then only give me unique package names.
for h

indexs through each type of package.

Then we pass each package type $h* in to a ls -t that sorts by time,
tail -n +4  

this removes the first 3 lines from what it list in the ls, just the 3 newest versions
xargs 

then takes this list of files from everything before and passes it as an argument to rm

After IPv4, How Will the Internet Function?

from Slashdot:

"36 countries in the world have over 100% per-capita usage of mobile phones, and this is driving a real crunch on IPv4 addresses as more and more of these devices are data-capable. The mobile network operators are acting fast to deploy IPv6, and T-Mobile USA has had an IPv6-only trial going on for over 9 months now using NAT64 to bridge to IPv4 Internet content. It is interesting to note that the original plan for IPv6 transition, dual-stack, has failed since IPv4 addresses are effectively already exhausted for many people who want them. Dual-stack also causes many other issues and has forced the IETF to generate workarounds for end users called happy eyeballs (implying that eyeballs are not happy with dual-stack), and a big stink around DNS white-listing. How will you ensure that your network, users, and services continue to work in the address-fractured world of the future where some users have only IPv4 (AT&T ), some users have only IPv6 (mobile and machine-to-machine as well as developing countries), and other Internet nodes have both?"

Progress In Algorithms Beats Moore's Law

"Seen on the blog 'Algorithmic Game Theory,' a report to congress and the president about past and future advances in information technology notes that, while improvements in hardware accounted for an approximate 1,000 fold increase in calculation speed over a 15-year time-span, improvements in algorithms accounted for an over 43,000 fold increase."

Friday, December 24, 2010

Ubuntu blocking X11 solution

My servers are OpenSuSe and my personal machine is Ubuntu. On a local area network, I can run my X11 editor and edit files on the server. But remotely, like from home, it was not clear.

This did it. Add to /etc/ssh/ssh_config

ClearAllForwardings yes

I also explicitly set the ssh server

X11Forwarding yes

it is not clear if this is the default


Today (2010-12-29), I also noted in /etc/ssh/ssh_config

ForwardX11 yes

tc

Tuesday, December 21, 2010

The Mysteries of the Unix Date Command.

To do any math on dates is very difficult in any language. But in the Unix/Linux shell this can be a breeze.

This is done by converting all data time in to Seconds.

In Unix this is done by counting seconds from UTC or Universal Constant Time, 1/1/1970

So once you convert in to second, you can do math as usual, then convert time back to date time.


Example of how to convert back and forth

Conversion from Seconds UTC to string
-bash-3.2$ date --date "1970-01-01 1292970890 sec utc"
Tue Dec 21 14:34:50 PST 2010

Conversion from string to Seconds UTC
-bash-3.2$ date --date "12/21/2010 14:34:50 PST" "+%s"
1292970890
-bash-3.2$ date --date "Dec 21 14:34:50 PST 2010" "+%s"
1292970890

Current time
-bash-3.2$ date "+%s"
1292979451

Get Seconds UTC file creation date.
stat -c %Y filename
ls -l
-rw-r--r-- 1 jsokol jsokol       8 Sep 22 18:36 t
 
-bash-3.2$ stat -c %Y t
1285205797


So for doing math on time:


Get file age

(In Bash)
Returns how many hours old
expr \( `date +%s` - `stat -c %Z $filename` \) / 3600

Return age of oldest file in directory
expr \( `date +%s` - `stat -c %Y \`ls -t | tail -1\` ` \) / 3600

Create Shell alias of this
alias oldest='expr \( `date +%s` - `stat -c %Y \`ls -t | tail -1\` ` \) / 3600'

bash process ID PID

$$, My PID
$!, My Child PID
$PPID, My Parent PID

bash command line

#!/bin/bash
echo "$*"
echo "$@"
echo "$_"
echo "$#"

./test a b c
a b c
a b c
c
3

Friday, December 17, 2010

Ansi color codes in Ruby


#!/usr/bin/ruby
esc="\e["
st=""
x=30
 while x < 38 do
   y=40
   while y < 48 do
     st +=  esc+"#{x};#{y}m #{x};#{y} "
     y+=1
   end
   puts st+esc+"0m\a"
   st=""
   x += 1
 end
puts esc+"0m"



This output's



With a little work I am sure this can be made in to a simple function or library.
or just something you can send with a puts.

Ruby to MBox format.

I have over the past 20+ years written many scripts to deal with incoming mail.
I can process statistics from machine generated alert E-mails, rebroadcast E-mails and generate pages from them based on there content.


I was using a the IMAPClient library in Perl for this, but when my IMAP Mail server was migrate to an SSL based TLS/IMAP everything broke.

TLS encrypted port 993 RFC2595 RFC3501

After many long hours of struggling to get IMAPClient to work over SSL I just had to give up. It looks like something is just broken in that lib, I tried opening my own SSL socket then passing it to the lib, I tried having the lib itself connect to the SSL socket, no luck.

The Ruby net/imap just seems better written and it does work. Unfortunately it's lacking the message_to_file  function which I had to replace that functionality.



A small change in the scripts below could also simulate .forward also or support mail dir.
If you do that, please send me a copy  


In Perl for Non-secure IMAP
#!/usr/bin/perl

use Mail::IMAPClient;
my $imap = Mail::IMAPClient->new( Server       => 'mail.yourdomain:143',
                                   User         => 'jsokol',
                                   Password     => 'yea-right')
        or die "IMAP Failure: $@";

 foreach my $box qw( alarmpoint ) {
   my $file = "/uhome/jsokol/crapmail/". $box;
   $imap->select($box);

   my @msgs = $imap->search('ALL')
        or die "Couldn't get all messages\n";

   foreach my $msg (@msgs) {
     open my $pipe, "| formail >> $file"
       or die("Formail Open Pipe Error: $!");
     $imap->message_to_file($pipe, $msg);
     close $pipe
       or die("Formail Close Pipe Error: $!");
     $imap->delete_message($msg);
   }

   # Now expunge the messages and close the folder
   $imap->expunge($box);
   $imap->close($box);
 }

 $imap->logout();


I am just learning Ruby, so please excuse some of this code.

In Ruby secure TLS/IMAP
#!/usr/bin/ruby
require 'net/imap'

        server = "mail.yourdomain.com"
        port = 993
        ssl = true
        username = "jsokol"
        password = "yea-right"


        Net::IMAP.debug = false
        conn = Net::IMAP.new(server, port, ssl)
        resp = conn.login(username, password)

        conn.select('test')
        conn.search(['ALL']).each do |sequence|

                env = conn.fetch( sequence,"ENVELOPE")[0].attr['ENVELOPE']
                xdate =  env.date.split(" ");

               wkday = xdate[0].sub(/,/,"")
               day = xdate[1]
               month = xdate[2]
               year = xdate[3]
               time = xdate[4]


               if (day.length < 2)
                   day = "0" + day
               end

                box  = env.from[0].mailbox  + "@" +  env.from[0].host + "  " + wkday + " " + month + " " + day + " " + time + " " + year

                fetch_result = conn.fetch( sequence,  "RFC822")[0].attr['RFC822']
                if fetch_result
                     File.open( "MAILOUT" , "a") {|file|  file.write ("From #{box}\n#{fetch_result}\n\n\n") }
                end

                conn.store(sequence , "+FLAGS", [:Deleted]) # remove this line if you don't want to deltete these E-mails.
        end
        conn.expunge # remove this line if you don't want to deltete these E-mails.
        conn.logout
        conn.disconnect

Google Public DNS

Few people are aware of this but Google offers a DNS service.

This is particularly useful in a number of situations.

*If you are inside a corporate firewall and want to test host DNS entries appear to the outside world.

*If you don't trust your local ISP, or their DNS is having issues.

I often run scripts to check massive blocks of IP's


#while read ADDR
for ADDR in $IPLIST; do
 DNSR=`host $ADDR 8.8.8.8 | tail -1 | awk ' {print $NF}' | sed 's/3(NXDOMAIN)/NONE/'

echo  "$HOST : $ADDR $DNSR" >> ADDR-LIST.txt

done

Google Public DNS IP addresses

The Google Public DNS IP addresses are as follows:
8.8.8.8
8.8.4.4

Using Google Public DNS

8.8.8.8, A DNS Number for Faster Browsing

Thursday, December 16, 2010

Lua Programming

Lua is a sexy little language out of Brazil.


http://wiki.eluaproject.net/Overview

http://wiki.eluaproject.net/

Ruby programming

Been learning Ruby lately. Didn't think I'd like it better then Perl But I do.

I will post some links I have found useful on this page.

Ruby Basic Tutorial

Ruby in Twenty Minutes

Ruby in 100 Minutes

Ruby 101: Substrings in Ruby

Some files space is just wasted

Recently, while testing some software that did directory tree displays, I noted 1,505,297 bytes used just to store the names for the /usr directory for Linux. Or 28000+ subdirectories.

Again, that is 1,505,297 bytes just for the directory names.

tc

Saturday, October 02, 2010

Oil and Lube

One would think that computers are not in need of regular maintenance, in fact they are. After some time in operations - months or years, any original lubricants are gone. Recently, SVBUG was gifted several servers that had seen their prime, but were still useful. A little Oil and Lube did the trick.

Here are a couple of Tutorials on :

How to Remove and Apply Thermal Compound By Jeremy Blum (aka sciguy14)
http://www.youtube.com/watch?v=I3gx6c62D7I

Quiet noisy computer fans with a drop of oil by Greg Shultz
http://articles.techrepublic.com.com/5100-10878_11-5034842.html

tc

Tuesday, September 28, 2010

BSD Event Feed and RSSFeed

Looks like a semi-official BSD Events list,

http://twitter.com/bsdevents

The RSS Feed is on the right below the menu junk. It's also below:

http://twitter.com/statuses/user_timeline/23451058.rss

tc

Tuesday, August 31, 2010

Super Computer taking over?

In a recent story (May, 2010), SEC Chairman Admits: We’re Outgunned By Market Supercomputers, a luddite might find reason to fear big brother. But in fact a mystery remains from the so-called "Fat Finger Incident" on May 6, 2010. The incident, such that it was, trigger "a total drop of 9.16 percent from the previous day’s close".

I'm sure conspiracy theories will abound as to the reason for this - including the demise of certain individuals. More to the point of this article, it cannot be sufficiently underestimated the problems the stock market has created.

It has been reported that because modern stock trading is essential completely electronic --- that dealers look to have their computers as close to the trading computers as possible. The idea is to be able to process orders microseconds quicker than the competition.

In fact it has also been reported that traders are "snipping" as the market moves. That is, "snipping" makes a few cents, if not hundreds of a cent as the market (or a particular stock) moves in a direction. It has even been suggested that dealers are making these "few cents" on their own client's "trades". It has even been suggested that these dealers, having prior knowledge of the limits of their clients, are pushing the pricing to the limit.

This last scenario, as suggested, means the buyer is actually paying more than they would have had the closing price not been known to the dealer.

If this is true, then it appears the dealers are undermining the confidence of their own business.

tc