How to administer Ubuntu Server remotely using Webmin
NOTE: If you're jumping into this guide here and have not been following from the start then it's worth mentioning that this guide has been tested on Precise Pangolin 12.04LTS, Maverick Meerkat 10.10, Lucid Lynx 10.04, Karmic Koala 9.10, 9.04 Jaunty, and 8.10 Intrepid.
Webmin is a fantastic application which makes the administration of Ubuntu Server a breeze. It's a web-based interface enabling you configure and maintain your server without having to go near any configuration files or learn any Linux commands.
To install Webmin via Putty you first need to go to http://www.webmin.com/download.html and look under the heading "Debian package suitable for Debian, Ubuntu or other derived Linux" to determine the latest version. At the time of writing this is webmin_1.580_all.deb.
NOTE: As and when later versions of Webmin are released you do not have to re-install the application from scratch using these instructions. Each time you launch Webmin via your browser Webmin automatically checks to see whether a newer version has been released and offers to perform the upgrade for you.
TIP: If you're using Putty and are going to be following this guide step-by-step then you can save yourself some typing by simply highlighting each command, right-clicking on it and selecting Copy. Then toggle over to your Putty Session and right-click once more. The command you've just copied from here will be automatically pasted into your Putty Session.
So, once you've determined the latest Webmin version type/paste the following command into a Putty Session:
which will download the package into your current directory. Obviously you should replace webmin_1.580_all.deb with whatever the latest version is called.
Now type the following commands:
sudo apt-get update
sudo apt-get install perl libnet-ssleay-perl openssl libauthen-pam-perl libpam-runtime libio-pty-perl libapt-pkg-perl apt-show-versions
this will install the packages required by Webmin. Now type:
sudo dpkg -i webmin_1.580_all.deb
to unpack it. Obviously, as above, replace webmin_1.580_all.deb with whatever the latest version is called.
NOTE: If Webmin says that it encountered errors preventing it from installing then type the following command to fix. Webmin will then re-install itself automatically:
sudo apt-get install -f
Once it's completed it should report a message along the following lines:
Webmin install complete. You can now login to https://MyMediaServer:10000/ as root with your root password, or as any user who can use sudo to run commands as root.
I recommend changing the Webmin password by typing the following command:
sudo /usr/share/webmin/changepass.pl /etc/webmin root YourNewPassword
where YourNewPassword is the password you want to use. This will return a message along the lines of "Updated password of Webmin user root".
You can now delete the Webmin installation file by typing:
To launch Webmin type the following string into the address bar of your browser:
where mymediaserver is the name you gave your server when you installed Ubuntu. Instead of using the server name the IP address of the server will work just fine.
The first time you launch Webmin your browser will likely complain about the certificate for this site so just add the site as an exception to continue.
You should then be prompted for a username and password. Enter root for the username and use the password you just created above. You should then see the Webmin Home Screen similar to the one below:
Using cron to run a script each time the server starts
Often you want to run a script each time your server boots. For example, in the How to run VNC on startup guide we wrote a script to launch VNC. One way to get this script to run on boot is to add it as a cron job. This is very easy to do using Webmin. So, within Webmin click on System and then Scheduled Cron Jobs. Then click the Create a new scheduled cron job option at the top of the screen that opens.
Click the button next to the Execute cron job as and choose the username you created when you installed Ubuntu. Hint: your username appears in a Putty/Terminal session prompt. eg. yourusernameappearshere@MyMediaServer.
Note: If the script you've written needs to be run as root then obviously you'd choose root in the Execute cron job as section instead of your username. If the script needs to be run as any other user then obviously enter that username instead.
Enter the name of your script including the full pathname eg. /home/htkh/MyScripts/StartVNC.sh >/dev/null into the Command box, replacing htkh with your own username, MyScripts with the name of the folder you created to store your scripts and StartVNC.sh with the script name. The >/dev/null parameter will discard any output the script may produce. If your script actually needs to produce any output then it should be piped to a file. See the Monitor server temperatures scripts for an example of piping output to a file.
Enter a suitable description in the Description field.
In the When to Execute - Simple schedule drop-down list choose When system boots then click the Create button at the bottom of the screen.
Now's probably a good time to test it. I'd recommend first testing that you've set the job up correctly in Webmin. You can do this by clicking on the job you've just created from the long list of cron jobs. Then click the Run Now button at the bottom of the screen. You should see a message similar to the one you saw when you tested it from a Putty/Terminal session. If you don't then go back and check your settings.
Still stuck? Now what you were looking for? Then head over to the Discussion Forum!