Category Archives: Hardware

Set default text editor in Ubuntu

I was looking at our crontab on our backup server. This server is an Ubuntu 12.x LTS machine, and the logs for this were being sent to my predecessor, and I wanted to change the eMail address. The usual procedure is to run the following command to see and edit the contents of the crontab file:

crontab -e

This brings up the crontab file for the root user.  Crontab is probably for another day, but basically the script shows a MAILTO address that I wanted to change.

MAILTO=”myusername@mydomain.org”
# Edit this file to introduce tasks to be run by cron.
#  m h  dom mon dow   command
0 23 * * * rsync -avz root@192.168.214.71:/opt/mysql_backup/ /backup/hive
0 18 * * * /backup/scripts/rsync_agave.sh
0 17 * * * /backup/scripts/rsync_basil.sh
0 1  * * * /backup/scripts/rsync_mysql1.sh
0 4  * * * /backup/scripts/rsync_mimic.sh
0 2  * * * /backup/scripts/rsync_petal2.sh

Running the crontab-e opens up the file in the default editor. Well, I didn’t even realize I had a default editor on this machine, and the file opened in vim, which is an archaic program, beloved by Unix freaks.  I prefer the nano editor, especially because I don’t use a text editor much, and I know how nano works.

After some digging it appears that the default editor is set as an environment variable specific to the user.  It can be changed by running the following command:

export EDITOR=nano

You can view your current environment variables, by typing

printenv

There will be a line similar to

EDITOR=nano 

In Ubuntu, you can also use the following command: 

sudo update-alternatives –config editor

This will bring up a list of editors from which you can choose your favorite.

Advertisements

Powershell: Get Computer Configuration

I’m a great fan of the Belarc Advisor. This system profiler gives you an extensive inventory of just about anything you need to know about your computer. One exception is the kind of memory that is installed. (It will tell you how much is installed, and how many free slots you may have if any). The free version of Belarc is for personal use only; use on a corporate, educational or corporate network requires a license. So, it may be of interest to look at Powershell’s capability for returning information about computers.

My use-case is memory information.  I’ve got a slow machine that I think may be slow due to the fact that it only has limited memory. Of course, you can find the amount of installed memory of a machine using the Control Panel ->System applet.    Screenshot_060915_090137_AM

The down and dirty about the memory can be obtained by querying the Windows Management Instrumentation (WMI), a database of objects which are related to the Windows operating system. To restrict this to a memory query, you simply specify memory object.

Get-WMIObject CIM_PhysicalMemory

To make a long story short, this call will provide a host of information abou the physical memory chips that are installed in the machine. You can restrict the information by choosing which of the fields you actually want to see, by putting the call in the form of a SQL query.

This call duplicates the line above….returning everything available about the installed memory.

GetWMIObject -query "Select * from  CIM_PhysicalMemory"

This call returns a subset of the memory information. First the select statement gets all of the memory attributes (fields), and then the output is piped to the Format-Table cmdlet, specifying just the fields we want to appear in the table.  The -auto attribute will format field widths of the table, so the information for each record appears on one line.

Get-WmiObject -query "Select * from CIM_PhysicalMemory" | 
Format-Table name, capacity, datawidth,speed, manufacturer, devicelocator, partnumber -auto

Screenshot_060915_094312_AM

Caveat: Everything above was run on my Windows 7 machine. I also tried running this on the Windows 10 preview running in a VirtualBox VM, and didn’t get any response. I don’t know if this is related to Windows 10,  the fact that it is still a preview…  or that it is running in VirtualBox.

References & Thanks:
http://www.computerperformance.co.uk/powershell/powershell_wmi_memory.htm
https://msdn.microsoft.com/en-us/library/aa394347%28v=vs.85%29.aspx

Odds and Sods: Resurrection, DocBoxes

After much fiddling, I seem to have been able to get my domain techfornonprofits.com to map directly to this blog, which is hosted with bloodspot.com. For a week or two it seemed it was lost in the ether, and I’m still not exactly sure what fix finally was. But, between Google/Blogger, and my domain host at Network Solutions, it looks as if the DNS records have finally got sorted out. Techfornonprofits, the blog was started when the Blogger program was relatively new, before it was purchased by Google. My first entry was in February of 2001 which seems like ancient history now.

I’m trying to sell a few DocBoxes. These are industrial-strength Mini-Itx machines originally sourced from Logic Supply. The have AOpen cases and motherboards, using Intel Celeron chips, with 1 meg of memory, a 60 or 80 Gig hard drive, and a CD or DVD-ROM. I originally had them loaded with Windows XP embedded, or Windows 7 embedded, but have reformatted them to use Xubuntu, which is Ubuntu configured to use the XCFE interface, a lightweight front end which seems to work well with the limited 1 meg of RAM on these machines. The best thing that I liked about this was a stock installation of Xubuntu automatically found the wireless network interface, and my wireless router and my printer. With XP and Windows 7 I had to go rooting around to find drivers for both of these things.

Nothing precludes running the boxes on Windows…I’ve tried it with a stock Windows 7 Professional installation as well as the embedded versions. In their original lives, they were running Windows XP Embedded. The units might have a number of applications:

  • Granny or kiddie workstation 
  • Thin client
  • Industrial controller
  • Process controller
  • Mini file or media server 
  • Lightweight web server  

The picture shows the docbox with a Logitech Orbit camera on top, which was the original configuration. I’m experimenting with how best to advertise and sell these, with a couple options, Craigslist, eBay via Global Garage, a third-party seller, and Do-It-Myself eBay.

Rebootolator: Execute a Remote Linux Shell Script from Windows

Ok,  so, your mission, should you decide to accept it, is to restart mySQL and Apache on a remote server. This restarts a balky web site hosted by Apache, and also restarts a mySQL server which is used for a back-end for Drupal.

You want to execute this from your Windows computer.

The target computer runs CentOS 5.6 This is an (ancient) Red Hat Linux derivative, running (ancient) mySQL and Apache.

I ended up using PLink called from a Windows .CMD file to execute a bash shell script.  The shell script looks like this:

Rebootolator

#!/bin/bash -p
# Rebootolator – Reboots Apache and mySQL on a target Server
# LK Microdesign June 25, 2014
TERM=”xterm”
export TERM
clear
echo
echo ‘Rebooting Apache and mySQL on myServer’
echo ‘———————————–‘
echo ‘Restarting mySQL’
/etc/init.d/httpd restart
echo ”
echo ‘Restarting the Apache web server.’
/etc/init.d/mysqld restart
echo ‘Reboot procedure completed’


Note this script is not stored on the target server, but simply put in the same folder as the windows cmd file on my windows box.  

Now for the Windows command file: 

Reboot.CMD

:: Batch file to restart services on myServer
:: Restarts mySQL and httpd 
:: Uses the Rebootolator shell script
:: LK/Microdesign August 12, 2014  
@echo off
cls
echo. 
echo.
plink -ssh username@192.168.xxx.xxx -m rebootolator.sh -pw mypass
echo.
echo.

pause >nul | echo Press any key to exit. 

So, lets deconstruct the Windows Reboot.CMD file.
The first four lines are comment lines. Turns out, you can use two colons to preface a comment in Windows, (who knew?) instead of REM.
Line 5 turns off output to the screen.
Line 6 clears the screen.
Line 7 and 8 put in blank lines.
All the work happens on line 9, using the PLINK command. PLINK is the command line version of PUTTY, a free open source terminal program for Windows workstations. Both PLINK and PUTTY are pretty wonderful and highly recommended if you need to access Linux machines from Windows.
-ssh means “use the secure socket layer protocol to log into this machine”
username@192.168.xxx.xxx is a administrator’s account on the target machine,  probably the root account.
-m rebootolator.sh is the name of the shell script (above) that needs to run on the target machine.
-pw mypass is the password for the account used to log into the machine.

Deconstructing the Rebootolator.sh script:
#!/bin/bash -p  just means this is a BASH script
The two commands that actually restart the mySQL server, and the Apache server are: 
/etc/init.d/httpd restart
/etc/init.d/mysqld restart

The rest, (the echo commands) write out what  is happening at the command line. The Term command is my attempt to avoid a harmless error message that occurs when the script starts to execute.

Since I didn’t realize I could host the Rebootolator.sh script in my Windows folder, I originally though I’d have to log into one Linux box, and then execute the script on the target box.  Turned out the whole thing was simpler using PLINK, which is the equivalent of SSH and SSHPASS programs used to access remote machines from the Linux command line.

Refurbished Desktop Computers

Refurbs are for when you have more time than money. I’m not sure about the exact figure, but in many cases, I think I’ve ended up spending several hours per unit getting a refurbished computer back online after a hard drive failure, or just having to spend hours updating Windows and Office so that I’m confident getting the machine on the network.

We got several “really good deals” from NewEgg, for refurbished Lenovo desktop computers at $214.00. These appeared to be of “office quality”, included Windows 7 Pro, and were nicely finished. Unfortunately, we have had 2/3 of the Western Digital Blue hard drives start to fail at some point. This has created no end of extra heartache for the users and an enormous amount of work for the IT staff.

NewEgg has been fine on returns, however, providing UPS shipping labels, and RMA procedures over the web.

OK….so much for NewEgg.  We’re looking at alternatives.  (we have more time than money).

Techsoup has Dell refurbished computers that are prepared by a third party. For example:


Dell OptiPlex 755 Core 2 Duo Windows 7 Desktop 2.0 Ghz – 2.6 Ghz 
$286.00 
Min of 160Gb drive
Min of 2Gs RAM 
Windows 7 Professional 64 bit. 
Also includes: 
Office 2010
Adobe Flash,Reader 

One advantage here is that if you need licenses for Windows 7 and Office, they are included in the price. You would spend the $286.00 on those if you bought at retail, and maybe quite a lot less if you have a Microsoft Open, agreement. But, it like getting the hardware free.

The Dell Outlet looks promising with several machines in the $315-$390 range which still include Windows 7 as opposed to Windows 8, and have at least 500Gb drives, and 4 Gigs of RAM. These have more up-to-date processors than the Techsoup machines, and are certainly not as old. Most Dell Outlet machines were either not delivered, or were taken back within the warrenty period.

I’ve had solid results with Dell Outlet computers at the workstation and server level; mixed results with standard desktop machines, and a real disaster with older SX-series Optiplexes.  The best seem to be the larger ones; towers or mini-towers. Smaller machines, “mini-desktops” may have suffer from the suboptimal cooling, and the older components may have reached their design end-of-life earlier than those installed in a larger case.

One thing we have often found is that dual monitors are wonderful, and this is something that I would recommend for anyone as a matter of course. If you need an extra monitor card, these can be found from NewEgg starting at around $35.00. Best to wait until you have received the machine, because there can be variations in the slots, and the available adapter space that aren’t evident from the web page.

On the Mac side, I’ve purchased several Macbooks, iPods, iPads, from the Apple Store. These have always worked flawlessly. The Refurb store has a 21.5 inch iMac for $1099, which is the model from September 2013. The cost is only $200 or so less that of a new, similar iMac. It includes 8 gigs of RAM, and 1 terabyte hard drive, and of course the Mavrick OS, and iWork. If you’ve got more money than time, and just want to get to work, this might be the way to go.

Spicy Server Pix

Shocking! Server Interior Revealed!

Click on the images to see them full size.

Here’s a picture of my new Dell T110 server, with the cover off.

Here’s a little more detail. You can see the two drives mounted on the left hand side, with two conveniently vacant drive bays for a couple additional SATA drives. Upper middle are the four memory slots, each filled with a 2 megabyte chip for a total of eight megabytes. All the black stuff on the right is the shroud covering the heat sink. The unit is absolutely silent.

Finally, here it is in the final configuration. I’ve got an older Maxell external USB 250 megabyte drive as a backup device. The Small Business Server 2011 backup is much improved over Windows backup software that came with earlier Windows server software…almost as good as the Mac Time Machine.

This is the first purpose-bought server that I’ve bought in more than ten years for my business. I had a couple in the nineties. Then for two or three iterations, I’d buy Dell Precision workstations to use as my personal workstation, and then I’d bump them down to be a server. All of these machines have been very reliable. I even used one of the Optiplex GX270 desktops as a production server for more than six months.

Tech Friday: More on Windows Small Business Server 2011

So, after fiddling for a week, I decided to commit, and make the SBS 2011 my real office server, at least for awhile. Amazing how much tweaking is required. Out of the box it doesn’t work out of the box, and despite the presence of numerous wizards and checklists, I find that it requires a fair amount of network knowledge to get things up and running. Ideas:

1. Under the covers, SBS 2011 uses Windows Server 2008, and Microsoft Exchange 2010.

2. In its default state, SBS assumes it will control everything, even unto DHCP. DHCP is usually enabled by default on most routers. It is the function that assigns an internal IP address to each workstation as it comes on the network. I prefer that the function stay with the router, so if the server is off for some reason, workstations can still get a legal IP address to be able to go out on to the internet. For the moment, I’ve acquiesced and given that function to SBS.

3. Since I’m planning to run Exchange, I needed to have a domain assigned to my SBS server. I have a fixed outward facing IP address from Comcast, my internet service provider. I assigned a “third level domain name” to my SBS server. This is often done for individual machines within a domain. So, for example of your company’s domain is kettleprises.com, you mail server might be mail.kettleprises.com, and your sbs server might be sbs.kettleprises.com. Third level domain names do not usually cost extra. I then configured a DNS server on the SBS box using the assigned third-level domain. So far, I haven’t been able to find my domain mapping using nslookup, so I’m a little worried that something is awry.

4. The above is not to be confused with the “windows domain”, which is a single name for the local area network’s SBS machine. I named mine ghq. SBS then translates this to ghq.local which is assigned to the server’s internal ip address.

5. The next issue, is to get the network workstations connected to the server. Before doing that, the help file suggests creating the user accounts on the server. Once you do that, you can go to the individual workstations, and run the web browser, and try to find http://connect. If this is successful, then you’ll see the following screen:

This is only a link to download a “launcher.exe” file which is a script which connects the computer to the network. If there are local user profiles available, it allows you to choose one to migrate to a domain account. (Again, showing essentially that the SBS developers assume that this is the first server of a one-server network, and you would only be migrating local workstation accounts to domain accounts anyway.)

If you can’t bring up the web page, then something is misconfigured, somewhere. It took me several tries to make sure everything was working as expected. I thought the last loose end was the fact that my third level domain name hadn’t propagated yet, but between the time I started writing and the time I’ve finished, it now appears under NSLOOKUP.