Tuesday, January 25, 2011

Damn Small Linux

A couple of years ago I stumbled upon a Linux book that caught my attention. I'd never noticed it before on the bookshelves in my local bookstore. Being curious, I picked it up, skimmed through it and bought it on the spot. My life changed for the better that day. The book's title is "The Official Damn Small Linux Book." It renewed and further strengthened my commitment to all things Linux.

Damn Small Linux(DSL for short) is a full blown Linux distribution which is incredibly small in size, under 50mb. From the book-

"DSL is a is a fully functional mini-live CD desktop operating system. Despite its size, DSL can do just about everything you would expect from a modern desktop system, such as browse the web, send and receive email, write documents, manage files, play music, work with spreadsheets, and manipulate images."

DSL comes with the following applications-
  • Aterm Afterstep terminal emulator
  • Fluxbox XWindows Manager
  • Firefox web broswer
  • Dillo light weight web browser
  • Monkey web server
  • Lua programming language
  • Open Secure Shell
  • EmelFm file manager
  • gRun GTK based run dialog
  • Siag spreadsheet
  • Sylpheed email client
  • Rdesktop remote desktop protocol client
  • VNC remote desktop protocol client
  • XMMS multimedia system
  • Xpaint image manipulation and painting program
  • Nano text editor
  • Vim text editor
  • SQLite self contained RDBMS
  • and many, many more.

Monday, January 24, 2011

SQL

A coworker asked for some sql assistance today.  He needed to search on two separate text strings within the same field.  The output fields had to be from two separate tables.  I solved the problem by joining both tables on the id fields.  Here's the query.

SELECT d.address, t.timestamp, t.log_message
FROM devices d, log_messages t
WHERE (t.log_message like '%Core not running%'
OR t.log_message like '%Exception !! Did not get Update%')
AND d.id = t.device_id
ORDER by d.mac_address asc
into outfile '/tmp/sql_2011jan24.txt';

Monday, January 17, 2011

Ssh

I'm writing a Bash script that must be able to run a script on a remote host.  The specific requirements are the following-

1)Login to a remote Linux host.
2)Use Ssh keys for authentication.
3)Execute a script.
4)Logoff.

The script runs as a different userid than my login.  Ssh keys are used for authentication.  I've ran into a couple of problems getting the script to work.  Here's how I solved them.

-i Use a specific identity file.  The file can be owned by a user different from the one executing the script. 

-t-Forces pseudo-tty allocation.  Used to execute arbitrary screen-based programs on a remote host.

-v Verbose mode.  Causes ssh to print debugging messages about its progress.


Here's the line of code looks that accomplished my three objectives.  The -v switch was extremely useful for debugging during numerous code revisions.

/usr/bin/ssh -i /home/myuserid/.ssh/id_rsa -t user@remotehost.domain.com/home/user/home/dbquery.sh

Monday, January 10, 2011

Riding

A light snow fell Friday night.  On Saturday morning the temperatures hovered in the mid 20s.  The ground was frozen, there was no wind.  This is what's call ideal riding conditions.  Here's a shot of my local trail, Lake Fairfax/CCT.

Sunday, January 9, 2011

Sudoers

I've been writing a program for work.  It's almost finished, but I've been stuck trying to solve one problem for a couple of days.  The problem is not being able to run sudo in a shell script as user Nobody.  Nobody is the userid under which the Lampp Apache web servers runs.  After trying various solution, I found my answer here.  Here's the line I need to add to /etc/sudoers-

nobody ALL = NOPASSWD:


My script can now run ssh at system prompt from a cgi page without being prompted for a password or key information. Very cool!!!!!!