UHS2 – Admin tools

Written by Haydn Williams

Making sure services auto-start

You’ve taken the time to set up all the services you need on your server, so it’s probably best to make sure that if (i.e. when) you have to reboot, they all start again automatically. You can see the current status of services on your system by issuing:

chkconfig

To turn something on or off by default, use the -s switch, the name of the service, and the default sate:

sudo chkconfig -s apache2 on

Wake-on-LAN

Our server doesn’t need to be turned on 24-hours a day, but equally I don’t want to have to go into the cupboard under the stairs to turn it on each time I do want to use it. Wake-on-LAN is a feature which lets you wake a machine up from a suspend state, just by sending a ‘MagicPacket’ to it over the network. To enable it, you’ll first have to make sure that your motherboard supports it, and that it’s turned on in your BIOS settings. To enable support in Ubuntu, you’ll need a package called ethtool. If it’s not already installed, you can get it using apt-get. Running it without any switches will give you information about the network connection you pass to it:

ethtool eth0

Note that there is a section relating to Wake events:

Supports Wake-on: pumbg
Wake-on: g

You can get a definition of each of the letters by running man ethtool, but the crucial thing here is that ‘g‘ represents the LAN-based MagicPacket method we’ll be using. In my case it’s already enabled, but if yours says ‘d‘, which means support is turned off, then you can activate it with the -s switch:

ethtool -s eth0 wol g

There are a couple of ways of making sure WOL support is maintained across reboots; check them out in the Ubuntu Community Documentation and on Tim Child’s blog.

Obviously once you’ve enabled support for WOL on your server, you’ll need some way to send the MagicPackets that wake it up. The programs I use are WakeOnLan on my Mac [edit: apparently now defunct] and iNet WOL on the iPhone.

Remote Access

For the reasons of ease-of-access outlined above, combined with the fact that you may not have a monitor and/or keyboard attached to your server, the ability to access it from other machines can be very useful. There are basically two ways to do this.

1) SSH

An earlier post dealt with installing SSH, and you may use it in conjunction with Subversion, for example. However, it’s also very useful for giving you a command-line login to a remote machine. Simply start SSH with your login details:

ssh user@192.168.0.1

Enter your password and you’ll have a Terminal prompt on the remote box. The advantage of this is that you can do it even if there’s no-one logged onto the server; this puts it at a definite advantage to the next method.

2) Remote Desktop

SSH is great for a lot of things, but in it’s vanilla form it doesn’t let you run anything with an X window GUI. As it’s name would suggest, remote Desktop lets you use a VNC connection to show the desktop of a remote machine on a client, exactly as though you were sat in front of the remote monitor. It’s easy to set up in Ubuntu – just open the “Remote Desktop” application and decide on the appropriate settings.

Remote Desktop settings in Ubuntu 11.04
Remote Desktop settings in Ubuntu 11.04

The system helpfully informs you whether your machine can be connected to just from the local network (more secure) or from the internet at large (less secure). Remote Desktop can be very useful, but there is a caveat to bear in mind: someone must be logged on to the remote machine for it to work.

The alternative is to use a program called vnc4server. This can be installed using apt-get, but again there is a caveat. With the introduction of Unity instead of GNOME in v11.04 of Ubuntu, VNC access seems to have got a little confused. The steps below will let you connect to a server without needing to be logged on already, but you’ll only be able to access the GNOME version of Ubuntu (AKA “Classic”), and there’s rumours that may not be available in future releases. If you do want to do it, steps I gleaned from here and here are summarised below:

  1. Install vncserver with:
    sudo apt-get install vnc4server
  2. Ensure you’re logged in as a “Desktop” user for the next steps; if you start your VNC server logged in as an Administrator account then anyone connecting using VNC will have root access.
  3. Start the VNC server to create a settings file:
    vncserver :1
  4. Choose a password when prompted. This will be required when connections are made to the server. It can be changed with the command vncpasswd.
  5. Kill the server so we can change the settings: vncserver -kill :1
  6. Edit the settings file ~/.vnc/xstartup
  7. Remove the comment markers from the first two lines, replace ‘exec‘ with ‘.‘, and finally comment out the final line. Your amended file should look like this:
    #!/bin/sh# Uncomment the following two lines for normal desktop:
    unset SESSION_MANAGER
    . /etc/X11/xinit/xinitrc
    [ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
    [ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
    xsetroot -solid grey
    vncconfig -iconic &
    x-terminal-emulator -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
    #x-window-manager &
    
  8. Restart the server:vncserver :1
  9. Log out of the machine
  10. Connect from your remote machine (I use Chicken of the VNC on my Mac – weird name but a nice program).

If everything’s gone well you’ll have a GNOME session, i.e. Ubuntu “Classic”, logged in as whichever user you chose in step 2) above. If things have gone very well, you may even have Unity, according to this article, although I still only get GNOME. It seems I’m not the only one who has struggled with this, either.

3) Extra Bits and Bobs

Finally, a couple of things you might want to consider if you like tweaking things, gleaned from BillMal. Startup Manager gives you a bit more control over Grub, while Ubuntu Tweak does exactly what its name would suggest. You’ll need to add a software repository to get Ubuntu Tweak, so the code to install using apt-get is as follows:

sudo add-apt-repository ppa:tualatrix/ppa
sudo apt-get update
sudo apt-get install ubuntu-tweak

Startup Manager and Ubuntu Tweak are both GUI applications, as is another useful pre-installed one which provides more customisation options, named CompizConfig Settings Manager.

No Comments