Installing MoinMoin 1.9 on Ubuntu
This series about MoinMoin is something that is long overdue. Everything you need to know about installing and configuring MoinMoin (from here on we call it MM) is well documented at the above link and also on numerous blogs. Why do I write this article then? The following will distinguish my articles on MM with others on the net.
- The workflow described here is optimised towards backup and security
- This workflow reduces administration tasks during future server migrations
Note that these articles explain the workflow I follow. There are of course many other ways to approach the same problem. Please do let me know if you have a better method.
Software Required
MoinMoin Version
At the time of writing this, the latest stable version of MM is 1.9.3. However, you can adopt the methods described here on previous versions as well. If you are new to MM, there is less chance of you noticing any differences between the recent versions.
Platforms
I have been using this appoach on Ubuntu 8.04 LTS (Hardy Heron) onwards. Currently, I have Ubuntu 10.04 LTS (Lucid Lynx).
Requirements
Have a look at this link on MM website to have a list of dependencies for different versions.
Articles in this series will be describing MoinMoin 1.9.3 on Ubuntu 10.04 LTS. However, I would like to reiterate the point that you can use it on other combinations as well.
Installation
The actual installation of MM on Ubuntu is as simple as typing the following code:
sudo apt-get install python2.4-moinmoin
This will install MM at /usr/share/moin/ and the config files will be stored at /etc/moin/. The issue with installing at this location is that most of us dont normally backup /usr/share/. Personally, I prefer to keep all such important applications under /usr/local/applications/ directory. I take particular care to make regular backup of my /usr/local/ directory. This way the only thing I have to do in case of a server crash of some sort is to restore this directory. So, how do we install MM to /usr/local/applications?
- Download MM from here
- Extract using tar as follows
tar xvzf moin-x.x.x.tar.gz - Navigate to the directory where you extracted MM
- Install MM using:
python setup.py install --force --record=install.log --prefix='/usr/local/applications' --install-data='/usr/local/www/template
where:
–force = To overwrite outdated files in the destination (not needed in this case).
–record = This is the install log. Keep this safe, just in case.
–prefix = Our installation location. This is where our MM installation is now located.
–install-data = This where we are going to keep our MoinMoin instance. Read my second post in this series to see what we do with this directory.
Great! we have MoinMoin installed on our server. In my next post I will explain how to get our first wiki on the internet. All the above information is explained in much more detail in the MM website and also on the install.html file that comes with the MM download. But then, you wont be reading this if you have read those documents!
A Fast And Non-resource Hungry Backup Stategy For Ubuntu
I love command line, and I spend most of the day working with a black-and-white terminal. For this reason, ever since I started with Ubuntu, I have been using rsync and cron for backing up my files (in one of my previous posts, I have provided a detailed how-to on backing up subversion repositories using rsync). However, not so long ago, I came across a very useful GUI for rsync and cron based backup called ‘luckyBackup’. I liked this software as it allowed me to visualise all my backup cron jobs in a single window. For some reason the experience of using this tool was a bit more reassuring than what I used to do. Some of its features such as multiple profiles, exclude/include files/directories, synchronisation etc were found to be very handy.
Now that I have started working with RAW and DNG photographs, my workflow demands an efficient backup solution. I work on these files using Adobe Lighroom and Photoshop (I prefer them more than Gimp) on a VirtualBox WindowsXP. I have configured luckyBackup on my server to make backup of my RAW files every 12 hours to two independent locations – an internal backup only hard drive and a portable hard drive. luckyBackup emails me when the target directories are 25GB in size, so that I can then write it on to a Blue-Ray disk and lock it up safely.
SSHMenu – A Really Cool Gnome Addon
Checkout out this great tool for Gnome at http://sshmenu.sourceforge.net. This tool, in combination with ssh-copy-id, can help you switch between your ssh servers in one click. Type the following to try SSHMenu:
sudo apt-get install sshmenu-gnome
Note that you have to add it to the gnome panel to use it.
Triggering Commands on File/Directory Changes in Ubuntu
He we will introduce a new linux tool called Incron. It is similar to cron, but instead of running commands based on time, it can trigger commands when file or directory events occur. First of all, install incron using the command
sudo apt-get install incron
Before starting to use incrontab, we must give permissions for a user to use the service. To do this do:
nano /etc/incron.allow
and add the desired username to it.
Using incron is very much like using cron, ie. you can list, edit, and remove incrontab entries by using -l, -e and -r options, respectively. Have a look at the man page (man incrontab) for more options and the directions for usage.
man 5 incrontab will show the format of the crontabs we are going to create. Basically it is as follows:
path mask command
where path> can be a directory or a file that is watched. path> can be one of the following:
| IN_ACCESS | File was accessed (read) (*) |
| IN_ATTRIB | Metadata changed (permissions, timestamps, extended attributes, etc.) (*) |
| IN_CLOSE_WRITE | File opened for writing was closed (*) |
| IN_CLOSE_NOWRITE | File not opened for writing was closed (*) |
| IN_CREATE | File/directory created in watched directory (*) |
| IN_DELETE | File/directory deleted from watched directory (*) |
| IN_DELETE_SELF | Watched file/directory was itself deleted |
| IN_MODIFY | File was modified (*) |
| IN_MOVE_SELF | Watched file/directory was itself moved |
| IN_MOVED_FROM | File moved out of watched directory (*) |
| IN_MOVED_TO | File moved into watched directory (*) |
| IN_OPEN | File was opened (*) |
When monitoring a directory, the events marked with an asterisk (*) above can occur for files in the directory, in which case the name field in the returned event data identifies the name of the file within the directory.
Let’s create our first incron job. We’d like to monitor the directory /home/Downloads, and whenever a pdf file is downloaded into it, we want incron to activate a script that moves the file to another location. This is how we do it:
incrontab -e and put the following text into it.
/home/Downloads IN_CREATE /home/xxxx/.mvpdf.sh
Once the file is saved, type incrontab -l to see a list of incron jobs.
Test if everything is working as intended.
Custom .screenrc Configuration File
Screen may be the most useful Linux applications when it comes to getting things done through the terminal. This custom screenrc configuration file will provide you with a permanent caption line at the bottom of each window. This caption line will enable you to easily keep track of each terminal window and provide other helpful information such as host and current time.
When screen is invoked, it executes initialization commands from the files “/etc/screenrc” and “.screenrc” in the user’s home directory.
Simply create a file in your home directory with vim or some other editor.
$ vim ~/.screenrc
And place the following line in the file.
caption always "%{Wb} %H %{Bk}| %{Ck}%-w%50>%{Cb} %n %t %{-}%+w%<%{- Wk}%{Bk} | %=%{Wb} %C "
Now launch a new screen session for it to take effect.
Check Bandwidth Usage In Ubuntu
Install bwm-ng and/or iftop as given below:
sudo apt-get install bwm-ng
sudo apt-get install iftop
Enjoy!
Free Up Cache Memory in Ubuntu
Ever wondered how to remove the cache memory in Ubuntu? Linux kernels 2.6.16 and newer provide a mechanism to clear the inode, page, and dentry caches on demand. All you have to do is echo a value to the proc filesystem, and you’re done. Follow the recipe below:
As this is a non-destructive operation and dirty objects are not freeable, run:
sync
To free pagecache:
sudo sh -c "echo 1 > /proc/sys/vm/drop_caches"
To free dentries and inodes:
sudo sh -c "echo 2 > /proc/sys/vm/drop_caches"
To free pagecache, dentries and inodes:
sudo sh -c "echo 3 > /proc/sys/vm/drop_caches"
Hope this works for you all.
Inspecting Network Cards In Ubuntu
I was planning to upgrade my home network into Gigabit. Before I start to spend money on it, I wanted to check the capabilities of the network cards on my laptop. Here is how I did it.
Install ‘hwinfo’. Its quite an useful tool as it can check the configuration of any hardware. Refer the manpage of more information.
sudo apt-get install hwinfo
To display details of the network cards on the system, type:
sudo hwinfo --netcard
Alternatively one can use
lshw -C network
to display details of the network card. Read manpage for more on lshw.
Scheduling Commands With Crontab In Ubuntu
The following applies to any linux distribution
Crontab
Crontab is an integral part of most Linux distributions.It is a simple text file that holds a list of commands that are scheduled to be run at specified times. These commands, and their relative run times, are controlled by the ‘cron’ daemon and are executed in the system background.
Each user on a Linux system has their own crontab which contains the schedule of commands. In order to edit or create a crontab, one must use the text editor that is specified by the system, ‘nano’ being the default on my system. To create a crontab open a terminal and type:
crontab -e
‘nano’ will open with a blank window for the job schedule to be entered. Each line represents a seperate cron job entry – also known as a ‘cron job’.
Creating a ‘cronjob’
Each section in a cronjob is separated by a space, with the final section having one or more spaces in it. No spaces are allowed within sections 1-5, only between them. Sections 1-5 are used to indicate when and how often the task has to be executed. This is how a cron job is layed out:
minute (0-59), hour (0-23, 0 = midnight), day (1-31), month (1-12), weekday (0-6, 0 = Sunday), command
Example 1
01 04 1 1 1 /usr/bin/somedirectory/somecommand
The above example will run /usr/bin/somedirectory/somecommand at 4:01am on any Monday which falls on January 1st. An asterisk (*) can be used so that every instance (every hour, every weekday, every month, etc.) of a time period is used. Code:
Example 2
01 04 * * * /usr/bin/somedirectory/somecommand
The above example will run /usr/bin/somedirectory/somecommand at 4:01am on every day of every month.
The “/usr/bin/somedirectory/somecommand” text in the above examples indicate the task that will be run at the specified time. It is recommended to use the full path to the desired command as shown in the above examples. Crontab will echo any mistakes found in a cronjob. The crontab will start running as soon as it is properly edited and saved.
Other crontab options
crontab -l option causes the current crontab to be displayed on standard output.
crontab -r option causes the current crontab to be removed.
crontab -e option is used to edit the current crontab using the editor specified by the EDITOR environment variables ($EDITOR=vi crontab -e).
Note: The double-ampersand (&&) can also be used in the “command” section to run multiple commands consecutively.
Monitoring Real-time User Logins In Ubuntu 8.04 Server
‘whowatch’ is a console, interactive users and process monitoring tool. It displays information about the users currently logged on to the machine, in real-time. Besides the standard informations such as login name, tty, host and the user’s processes, the type of the connection (ie. telnet or ssh) is also shown. A particular user can be selected and his processes tree may be viewed. Trees are displayed with an additional column that shows the owner of each process. In the process tree mode SIGINT and SIGKILL signals can be sent to the selected process. Killing processes is just as simple and fun as deleting lines on the screen [information from somewhere on the www]. To install ‘whowatch’:
sudo apt-get install whowatch









