Thursday, 10 November 2016

Ubuntu from Scratch

Well, my new lease computer arrived today, so I thought I’d log the steps to get a nice new clean install of Ubuntu. I decided to go with a clean install as I’ve had the same setup backed

Install


First off, begin a new HP with Windows 10 pre-installed, I had to work out how to disable Secure Boot so I could boot from a USB stick. ”Easy”, you might think, “just go into the BIOS and turn it off.” Well that’s what I thought you would do, but it didn’t work—no matter how I tried to change the settings, Secure Boot always reverted to being on.

However, a bit of searching found me this post which instructed me to boot into Windows, and power off while holding down the shift key. Ummm ... OK? Anyway, it worked, I was able to restart the computer having disabled Secure Boot and begin to install Ubuntu 16.04.1 from a USB stick.

While installing, I have a weird and wonderful way of setting up users. One thing I’ve been caught out by before is that the first user always has a UID of 1000. That was never a problem while I was the only user, right? Unfortunately, setting up other laptops for family members highlighted a problem, particularly with external HDDs. Generally I’ve made the main user the ”first” user, but since I’m the one looking after the machine, I always set myself up as a user so I can ssh in. Since I set up external HDDs as ext4 (why? because I can!), the files (and, in fact, the drive) can’t be accessed if I’m logged in as me.

Now, one was around this would be to make me the first user installed every time. However, I've settled on an alternative solution—I create my user after the first install, and I change my UID and GID to 5000.

sudo usermod -u 5000 dave
sudo groupmod -g 5000 dave

Easy! And if I do this before I’ve logged in the first time, I don’t have to worry about any existing files. And my ext4 HDDs work!

Apps

Next up, installing my go-to apps and other services:
  • GDebi—I just prefer this to the Software Installer for downloaded .deb files
  • CompizConfig Settings Manager (mainly because I love wobbly windows!)
    sudo apt-get install compizconfig-settings-manager compiz-plugins-extra
  • Chrome (head to http://chrome.google.com and download the .deb file)
  • Dropbox and InSync (Dropbox from the Software Installer, InSync from https://www.insynchq.com/downloads)
Lastly, install the drivers for our Brother laser printer and scanner using the Driver Install Tool from Brother’s website ... and now I’m in business! Rest of the setup in my next post.

Friday, 29 April 2016

ssh without passwords

One thing I’ve done quite a few times, but always have to look up how to do it as it’s a “do it once, then forget it” kind of thing.

Here’s how to do it:

  • On the client machine, run ssh-keygen
  • Once the key is created, run ssh-copy-id remoteuser@remotehost
You’ll be asked for the remoteuser password, the key is copied across, and ... that is it. You can now ssh remoteuser@remotehost and never need a password.

Friday, 22 April 2016

Ubuntu 16.04

After trialling the RC, I'm taking the plunge and doing a brand-new install of 16.04.

One thing I'm trialling is giving myself a different UID, rather than accepting the default "1000" that new users get. The main reason is for new to have the same UID on all the Linux laptops I manage, meaning things like external HDDs will "just work" for me. I've chosen 5000 as a good one, for no real reason other than I needed to pick a number over 1000 ;-)

I've started by creating a dummy admin user as part of the install, then used the User Accounts control panel to add me as an admin. Lastly, I need to set my UID before I log in:

sudo usermod -u 5000 dave
sudo groupmod -g 5000 dave

Lastly, I did an id on the admin user, and an id dave to see which groups were different. Doing

sudo usermod -a -G group name dave

for each group sorted all that. Now to log in and see what happens!

Tuesday, 2 February 2016

RDesktop

Since our school updated the servers to Server 2012, the standard install of RDesktop has problems with the pointer disappearing, or simply not connecting at all. Unfortunately, the latest version in the software centre (1.7.1) does not have the fix required to make this all work. So, I upgraded to RDesktop 1.8.3:

cd /tmp 
sudo apt-get update 
sudo apt-get install build-essential libx11-dev libssl-dev libgssglue-dev libpcsclite-dev 
wget https://github.com/rdesktop/rdesktop/releases/download/v1.8.3/rdesktop-1.8.3.tar.gztar zxvf rdesktop-1.8.3.tar.gz 
cd rdesktop-1.8.3 
./configure 
make 
sudo apt-get remove rdesktop
sudo make install

... and all was right with the world again!

Friday, 29 January 2016

ActivInspire and Linux

At school we have a number of ActivInspire Boards installed, and when they were “new” we had Windows XP machines running them. Now they are run on staff laptops running Windows 7, but I wanted to get them running on Linux.

From an older blog, I found some instructions:

Firstly, install the libjpeg62 library:
sudo apt-get install libjpeg62

(Edit: as I’m running 64-bit Ubuntu 14.04, I had to install the libjpeg62:i386 package instead ...)

Next, add the following into the ‘Other Sources’ in the Software Centre:
deb http://activsoftware.co.uk/linux/repos/ubuntu trusty oss non-oss

Now add the Promethean key:
wget http://www.activsoftware.co.uk/linux/repos/Promethean.asc && sudo apt-key add Promethean.asc

I found that I had to install ia32-libs, as ActivInspire requires it (even though it is a deprecated library ... sigh). I followed these instructions:

sudo dpkg --add-architecture i386 
cd /etc/apt/sources.list.d 
sudo echo "deb http://old-releases.ubuntu.com/ubuntu/ raring main restricted universe multiverse" > ia32-libs-raring.list 
sudo apt-get update 
sudo apt-get install ia32-libs
sudo rm ia32-libs-raring.list

... and now I can finally install ActivInpire!

sudo apt-get install activinspire activtools activdriver

Easy ...

Wednesday, 27 January 2016

Deleting Files

Sometimes, you want to delete all but one of a file from a folder. Using a GUI, it’s fairly straightforward—Ctrl-A will normally select the files, Ctrl-click on the file you don’t want to delete to de-select it, and ... delete.

What about from the command line? Sometimes (like on a headless server or when you ssh into the computer at work) you need to do the same thing from a shell. Here’s the best way I’ve found to do that:

find . ! -name 'file.txt' -type f -exec rm -f {} +

This will delete every file from the current directory except file.txt.  Nice and easy.

Raspberry Pi and Weather

I’ve just set up my new Raspberry Pi as a web server for the weather station my wife got me for my birthday last year.

The initial setup was very straightforward:
  • Plug the Raspberry Pi into the TV and power up
  • Configure the Pi to start into console mode (as I’m running the Pi as a headless server) and install ssh
  • Log on, startx and set up the USB wifi module.
... and the first interesting problem was that I couldn’t access the Pi using its name; ssh (and ping and everything else) could only use the IP address. Running
sudo apt-get install avahi-daemon
 got around this problem—I can now ssh to dave@raspberrypi.local :-)

Next issue—while the time had been set once the wifi had been set up, the time zone was all wrong. Running
sudo dpkg-reconfigure tzdata
allowed me to set the timezone correctly. Now I could shut down, move the Pi to where the weather station console is, restart and set up Cumulus. Again, it was fairly straightforward following the instructions:
  • Install mono-complete
  • Unzip the CumulusMX installation files into ~/CumulusMX
  • Run Cumulus using sudo mono CumulusMX.exe
At this stage, I haven’t plugged in the weather station. I was then able to set up the location, units etc using the web interface from my laptop. Once correctly set up, I then stopped Cumulus.

As the weather station was installed before Christmas, I wanted to ensure that all te data was downloaded. I edited the newly-created file Cumulus.ini:
StartDate=Monday, 21 December 2015
and created the file data/today.ini:

[General]
Date=21/12/2015
Timestamp=2015-12-21T00:00:00
CurrentYear=2015
CurrentMonth=12
CurrentDay=21

Running Cumulus again downloaded all the data from 21 Dec, and we were in business!

Last thing to set up was ensuring Cumulus kept running evening when I exited ssh, so I used the script kindly provided by slashmusic—this worked perfectly, and I now have my Pi running as a little webserver collecting weather information continuously!