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.

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.

Laplink PC Mover migrates Windows Users to new machines

Moving users to new Windows machines is a pain. PC Mover helps automate the process, and it even assists when you are migrating users between Windows versions, such as upgrades from Windows XP to Windows 7.

Despite being lead to believe otherwise, PC Mover does not fully migrate OutLook accounts. Rather it will migrate the account server connection but it does not migrate the OutLook messages. I confirmed this with their technical support people.

You can migrate messages by copying the OutLook.PST file from the old machine to the new machine. I found I had to do this each time I migrated a user from Windows XP to Windows 7 on a new machine. Everything else, however, migrates smoothly. To do this:

1. Make sure the new machine is connected to the network.
2. If you can (or need to) register the computer with the Microsoft Domain Controller (under Control Panel, go to System ->Computer Name, and see that the computer is a member of the domain.
3. Log in to the new computer with the target user’s domain account. This will create a new user profile on the new computer.
4. Log off, and log in again as the Domain Administrator. This will give you rights to perform the migration on the new computer.
5. Install and run PC Mover on the new computer.
6. Log in as an administrator on the old computer.
7. Install PC Mover on the old computer. (I use a thumb drive for this).
8. Run PC Mover on the old computer. It will find the new computer on the network .
9. Choose the user’s domain account on the old computer for migration to the new computer. (This is the reason for step 3 above. Before doing this, I received an error message from PC Mover on the old computer saying that it can’t migrate the domain account. I’m presuming that is because the account didn’t exist on the new computer.)
10. In general, you don’t want to migrate old versions of applications that won’t be used on the new machine. So, these being Dells, I didn’t migrate things like Roxio CD Creator from the old machine to the new one. Also, if you already have applications installed (Office 2007?) on the new machine, you don’t need to migrate the whole application again.

One thing that is helpful is there is a rollback function, so if the migration doesn’t work as expected, you can roll back and try again with different settings.

Tech Friday: Installing Windows Small Business Server 2011

I’ve received  a Dell T110 server, to install here at Microdesign GHQ.  I originally got it with two 250 gigabyte disks, I’ve been fooling around with various images and DVD disks trying several ways of installing it.  Some ideas:

1. SBS 2008 or 2011 requires a minimum of 8 megabytes of RAM, with twelve megabytes recommended for a production server. One reason I broke down and bought new hardware is that I had no recent Windows workstation that I could repurpose that could use more than 4 megabytes of RAM. I tested several candidates using the Crucial on-line tester. Then in desperation I went the Dell web site, and tried there as well. My latest workstation hardware, circa 2005, was too old. 

2. Being a cheapskate, I configured the server with two 250 gigabyte drives, thinking I’d mirror the drives. But it looks like Dell wants 9 megs or so for a utility partition, and that  the Windows installer won’t mirror anything before installation, so the operating system itself will go on a single drive. I’ll configure the second drive for data for starters, and then buy another one to mirror, so that I have mirrored data disks. This is what we ended up doing with the FreeNAS server that we’re using for student data; the O/S is on its own drive. Presumably, if that drive fails, then you could reinstall on a fresh drive, and the data remains intact on its own array. 

The only way around this predicament is to get a RAID controller that does all of the mirroring or RAID in hardware. The controller then “presents” the array as a single drive to the operating system.  

3. The higher RAM requirement also precluded playing with the O/S in a virtual machine… at least with Parallels.  This may be a mixed blessing. Even on dedicated hardware the installation is taking over an hour from DVD. So, in a VM the whole thing would be really slow.

4. Using the technique described last fall  for Windows embedded booting, I’m preparing a USB drive as an alternate boot media, just to see if that works, and if it does if it is any faster. This involves formatting the USB drive, and copying the bootloader files from the Windows setup DVD.

5. The downloaded .iso DVD image for Windows SBS 2011 is larger than the typical 4.7 gigabyte  single-sided DVD. I had to go to Staples and buy double-sided DVDs which hold 8.5 gigs. I never knew they existed, but I’m happy to see that both my Mac Superdrive, and the server DVD reader can read them.

FreeNAS: Automate Drive Mappings for Windows Users

This is the third in a series about FreeNAS, the free network attached storage application which allows you to create an inexpensive but highly capable network file server for backups, iTunes, and general file sharing. Our application is a server for student data. We want to give each student a secure folder in which to store files that they create and use when working in our student computer labs.  The two previous postings are:

Creating a FreeNAS server for student data

Adding students and creating folders 

Note that the first link picks up at the point that the FreeNAS server software has been installed on to server hardware with a minimal configuration. The FreeNAS web site has links to several tutorials as well as the official setup guide.

By the way, FreeNAS installs really nicely within a virtual machine so you can easily test it out. I’ve got it running in Parallels on my MacBook, with software RAID 5 providing redundant disk storage.

Mapping a drive to a student folder

Once I set up the student’s folder and account on the FreeNAS server, I wanted to be able to give them the opportunity to access it from any workstation in our student lab.  The cleanest way I could think of was to create an icon on the desktop which runs a script. The script does the following:
1. Asks for the student login name
2. Asks for the student’s password
3. Maps the H: drive to the student’s folder on the FreeNAS server.

Student folders are named exactly the same as the student login, and they all appear under a shared folder called “StudentData”.  The full path is /mnt/StudentData/.  So, when student Myron Kapoodle logs in with his user name mkapoodle, the script takes him to: 

/mnt/StudentData/mkapoodle

Thus, when the student accesses drive H:, they find themselves in their own folder. They can’t select a folder “above” their own, and they can’t access anyone else’s folder, even if they can see it when browsing around the network neighborhood.

The Script

' VBScript to map a network drive.
' Heavily borrowed from ....
' Guy Thomas http://computerperformance.co.uk/
' Larry Keyes http://www.techfornonprofits.com
' ------------------------------------------------------'
Option Explicit
Dim strDriveLetter, strRemotePath, strUser, strPassword
Dim objNetwork, objShell, objFSO
Dim CheckDrive, AlreadyConnected, intDrive
strUser=""
strPassword=""

' This section gets the name and password
strUser=InputBox("Enter your User Name")
strPassword=InputBox("Enter your Password")

' The section sets the variables.
strDriveLetter = "H:"
strRemotePath = "\\freenas\StudentData\" & strUser

' This sections creates two objects:
' objShell and objNetwork and counts the drives
Set objShell = WScript.CreateObject("WScript.Shell")
Set objNetwork = WScript.CreateObject("WScript.Network")
Set objFSO = WScript.CreateObject("Scripting.FileSystemObject")
Set CheckDrive = objNetwork.EnumNetworkDrives()

If objFSO.DriveExists(strDriveLetter) Then
objShell.Popup "The H: Drive is already mapped"
objNetwork.RemoveNetworkDrive strDriveLetter
strRemotePath = "\\freenas\StudentData\" & strUser
objNetwork.MapNetworkDrive strDriveLetter, strRemotePath , false, strUser, strPassword
Else
strRemotePath = "\\freenas\StudentData\" & strUser
objNetwork.MapNetworkDrive strDriveLetter, strRemotePath , false, strUser, strPassword
End if

'Section which actually (re)names the Mapped Drive to eliminate naming problem.
Set objShell = CreateObject("Shell.Application")
objShell.NameSpace(strDriveLetter & "\").Self.Name = strUser
Wscript.Echo "Check : "& strDriveLetter & " for " & strUser
WScript.Quit

There is some extra stuff in there that attempts to fix an issue that appeared in Windows 7, where if the drive mapping is reused, it shows up with the name of the previous user.

Our student workstations have a single “student” local account.  Every student logs in to that account when they use the workstation. There are no individual user profiles. In some cases I have the student account log in automatically, and I’ll probably do this on all machines that use the FreeNAS network so that a student doesn’t have to log in twice…once to the desktop and once with their own user name and password on the FreeNAS server.

This script should be installed on each Windows workstation, with a desktop icon to appear on the desktop of the student account.

Two other observations and questions:

1. Obviously you can simply map a drive from the command line using Start->Run->CMD, and then at the prompt  type MAP H: /freeNAS/StudentData/mkapoodle.

2. I searched all over for a more elegant way to have a screen that came up that would ask for the name and password and then make the call to create the drive mapping. First I looked at C#, then, because Visual Basic has a “shell” command, I switched to VB. However that required a full-blown Windows installation of the .exe file, as well as a batch file which was called by the VB program. I finally decided I could live with two windows popping up; one asking for the name and another for the password.