Sunday 12 May 2013

Installing Git on Ubuntu

I'm in the middle of replacing Subversion with Git - more details on Git to come shortly, but here's a quick overview on installation.

The details on the Git website/book itself do a full installation. As I only need it on a server, then rather than the full UI additions, a simple installation from source is lighter ...

From the Git source repositories, grab the latest version -

https://code.google.com/p/git-core/downloads/list

and untar this using tar -xvf "downloaded file"

To install within a typical /usr/bin location, first make then make install as per the INSTALLATION file. So, that's just 'make', no 'make all', 'make doc'; just 'make' with an appropriate prefix.
Then run a make install (as root).

This will give you git without any documentation. To get the documentation, rather than build it, which is a heavy process (installing asciidoc is large!) grab the manpages tarball from the same location above, and untar it to the man pages area:

tar -xf "downloaded manpages file" -C /usr/share/man --no-same-owner

(more useful info here).

Tuesday 19 March 2013

Replacing Nautilus with Nemo

As posted previously I've replaced Unity (meh) with Cinnamon on my Ubuntu laptop.

Cinnamon comes with a fork of the Nautilus file manager, called Nemo, which is a slight improvement I find. However, although various posts go through how to install Nemo, I found that it and Nautilus were competing to draw the desktop - such that on every other re-boot I was running one or the other.

So, as well as ensuring that any folder launch commands and file associations use Nemo over Nautilus, I also had to prevent Nautilus from auto-starting:

In Ubuntu the X-Server desktop menu set-up is held at /etc/xdg. Within this, folder autostart determines what starts automatically with the desktop. Remove the nautilus-autostart.desktop file from there (and make sure the Nemo install has added one). This should mean Nemo is preferred everywhere.

More excellent details here.

Friday 1 March 2013

Setting up vsftp for Virtual Users (Ubuntu)


vsftpd setup for virtual users is fairly straght-forward but most guides don't go through the 'why', so here I'm attempting to explain this in brief.


Install vsftpd

- I'll assume you've already done this(!)


Update Configuration

The configuration file is typically in /etc/vsftpd.conf.

Make the following changes:


virtual_use_local_privs=YES
guest_enable=YES
guest_username=xxxxx
user_sub_token=$USER
local_root=/home/ftpusers/$USER
chroot_local_user=YES
hide_ids=YES
user_config_dir=/etc/vsftpd/vsftpd-user-conf


where,

guest_enable=YES

sets 'guest' logon allowed. With Virtual Users, you'll actually be logging on as this guest logon, so this is the id that needs the appropriate access to any folders you point the virtual user at.

guest_username=xxxxx

the local user to actually run under - should be a 'real' user, not a system one. Something like 'vftp' might be appropriate. Create them as 'normal' and either root the virtual user's in /home/vftp; or create a new folder structure and chown it to 'vftp'.

user_sub_token=$USER

how to identify the remote/virtual user. In this case using their 'user' name (what they logon with).

local_root=/home/vftp/$USER
which local root/home directory they will be sent to. So for a user 'test' they will start in '/home/vftp/test' in this example.

chroot_local_user=YES
'YES' means they will be confined to that local_root directory.

user_config_dir=/etc/vsftpd/vsftpd-user-conf 
A directory to use for 'per user' overrides. This is optional, but if you want one of your virtual users to operate under a different local user, or go to a different home directory you can create a file in this folder to do this.

Example 

You have virtual users 'test' and 'admin'. Test should have the basic access of '/home/vftp/test' and will create files as the (local) user 'xxxxx'. The 'admin' user you want to be able to access and update any of the virtual user's data within '/home/vftps'. 
Therefore create a file called 'admin' in /etc/vsftpd/vsftpd-user-conf with:

local_root=/home/vftp

which overrides the local_root setting and puts the user into the server at the higher-up node. 
This is where you could restrict access to 'read-only' if required at user-level (using write_enable=NO).

Amend PAM

The typical pam used (although it's set in the .conf file) is /etc/pam.d/vsftpd.

Update this to use just password authentication:

auth required pam_pwdfile.so pwdfile /etc/ftphtpasswd
account required pam_permit.so


where /etc/ftphtpasswd is the user/password file to hold your virtual users.
Everything else in the PAM can go - that's for enabling only locally defined (real) users to logon via ftp.
(there's a chance that the local PAM does not include pam_pwdfile ability - it's missing from /lib/security - in which case it can be installed from package libpam-pwdfile)

Create Users

Build the file mentioned above - /etc/ftphtpasswd using the htpasswd utility.


Verify

Logon with a suitable FTP client to check that each user is confined to the appropriate location, with the correct access rights.

(this info gathered in part from this post)


EDIT
*****
Ubuntu 12.04 (or maybe vsftpd) at some point decided not to like the crypt passwords htpasswd creates, so following guide here, use:

  sudo htpasswd -c -p -b ftphtpasswd user $(openssl passwd -1 -noverify password)

Sunday 24 February 2013

Installing R Language support in Ruby

The R Language is a similar (yet open source) version of Metalab's MATLAB. R is available on most platforms, and there is a binding Gem for Ruby called RSRuby.

The installation is easy enough once you have R correctly installed.

Here are the steps on Ruby 1.8.7, with Gems >1.8 (probably the same on all version).

If you just try the basic Gem installation you get:

sudo gem install rsruby
Fetching: rsruby-0.5.1.1.gem (100%)
Building native extensions.  This could take a while...
ERROR:  Error installing rsruby:
ERROR: Failed to build gem native extension.

        /usr/bin/ruby1.8 extconf.rb
checking for main() in -lR... no

ERROR: Cannot find the R library, aborting.

*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers.  Check the mkmf.log file for more
details.  You may need configuration options.

Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/usr/bin/ruby1.8
--with-R-dir
--without-R-dir
--with-R-include
--without-R-include=${R-dir}/include
--with-R-lib
--without-R-lib=${R-dir}/lib
--with-Rlib
--without-Rlib

So you need to add some appropriate switches to enable the builder to find the R libraries.

Assuming you have R already installed, they are likely (under Ubuntu) to be at:

/usr/lib/R                       = binaries
/usr/share/R/include       = build libraries

First create an environment variable for the R binaries:

~$ export R_HOME=/usr/lib/R

then add this to your load path:

~$ export LD_LIBRARY_PATH=\$LD_LIBRARY_PATH:R_HOME/bin

Now, retry the installation:

~$ sudo gem install rsruby -- --with-R-dir=/usr/lib/R --with-R-include=/usr/share/R/include
Building native extensions.  This could take a while...
Successfully installed rsruby-0.5.1.1
1 gem installed
Installing ri documentation for rsruby-0.5.1.1...
Installing RDoc documentation for rsruby-0.5.1.1...

Test out the rsruby gem:

~$ irb
irb(main):001:0> require 'rubygems'
=> true
irb(main):002:0> require 'rsruby'
=> true
irb(main):003:0> r = RSRuby.instance
=> #-2147483648, "parse"=>#, "help"=>#, "NaN"=>NaN, "FALSE"=>false, "TRUE"=>true, "eval"=>#, "F"=>false, "T"=>true, "helpfun"=>#, "get"=>#}, @proc_table={}, @class_table={}, @default_mode=-1>
irb(main):004:0> r.help
=> "/usr/lib/R/library/base/help/NULL"
irb(main):005:0> exit

Just remember to set R_HOME permanently for your user in wherever you choose to add environment variables.

Saturday 19 January 2013

Cinnamon on Ubuntu


Since switching to Ubuntu 12.04 I've moved to using Cinnamon as my DE. I did give Unity a serious go for a couple of weeks, but after one evening trying to use it to support a software release - switching between 3 browser windows and 2 SSH sessions, it became obvious it wasn't suitable. For many reasons, documented all over the web.

So I installed Cinnamon and despite a few teething problems (I think mainly caused by my nVidia card) it works beautifully. Nice weather, battery, and monitor applets; a simple, clean look, and easily configurable. As nice as Gnome used to be.

One issue I had recently though is that Wine applications place their menu items within the 'Other' area of the Menu (see this post), and when attempting to tidy this up, Cinnamon locked up and refused to restart. Even re-booting didn't solve the problem. I was kind of stuck as I couldn't see where the configuration was, or how it had failed. A remove/purge and re-install didn't fix anything (as configuration is held at user-level this is 'safe' to do. In that, you don't lose any settings/applets).

The solution arrived via this post (searching for the syslog failure message - Cinnamon seemed stuck at launch) - however as I'd never edited my Menu prior to this incident I had no 'backup' of the cinnamon-applications.menu file. However, reading through the first post, above, the installation version seems to be at /etc/xdg/menus/cinnamon-applications.menu so copying that to ~/.config/menus and restarting sorted things out.

Incidentally, following this stack-exchange entry I found that deleting entries from ~/.local/share/applications/wine/Programs and again in the ~/.config/menus/applications-merged area achieved much the same thing as editing the menu in the DE, with less chance of issues(!)