How to remove files with special characters in Linux

I recently found myself having to remove a file with special characters. Using rm only gave me “rm: unrecognized option”, which forced me to take off the gloves.

To remove a file with dashes, slashes or other special characters, the easiest way is to access the file using its inode. To get the inode of a file, just do a ls -li. When you have that number, use find to delete the file using the following command:

find . -inum [inode] -exec rm -i {} \;

Good hunting!

Shell script to show a file and optionally delete it

I needed to open a number of files and depending on the content, delete them. Here is a quick bash script to cat the file and ask a question to delete the file afterwards.



if [ -d $1 ]
     echo "Enter a directory to clean"
     exit 1

for file in `ls $DIR`
     $VIEWER $DIR/$file
     echo -n "Delete file (y/n)? "
     read RESP
     if [ $RESP == "y" ]
          echo "Deleting $DIR/$file"
          rm -f $DIR/$file

You can change the viewer to something else, if you don’t want to use cat, and instead of deleting the file, you might want to move it somewhere else instead.

Unity, and Ubuntu Light

Unity, and Ubuntu Light is a post from Mark Shuttleworth, describing the future of Ubuntu as a netbook and light web browsing operating system.

A few months ago we took on the challenge of building a version of Ubuntu for the dual-boot, instant-on market. We wanted to be surfing the web in under 10 seconds, and give people a fantastic web experience. We also wanted it to be possible to upgrade from that limited usage model to a full desktop.

He continues to talk about touch being a target input for this OS, so making it easy to navigate, changing applications with the touch of a finger has added to the design decisions.

Ubuntu 10.04 LTS released

Ubuntu 10.04 LTS was just released with amazing new features and fixes including:

  • New Ubuntu Software Center
  • New splash screen using plymouth
  • UbuntuOne Music Store (with Rhythmbox integration)
  • New “Memenu” that lets you post to twitter/ (using Gwibber) and also change your IM status in Empathy.
  • Lots and lots of bug fixes

This is a LTS release, meaning that it will be supported until 2013 for desktops and 2015 for servers.

More at Lifehacker

Updating the Postfix HOWTO

The time has come to update the Postfix HOWTO for Debian and Ubuntu on the website. There are lots of changes done in the Postfix and Dovecot distribution, as well as input from lots of commenters. The release of the latest Debian distribution called Etch, there have been some major improvements of various components.

Within the next couple of weeks, I will publish an updated version with hopefully additional features such as DSPAM and other important components for creating an enterprise grade mail server.

I have realized that it is impossible to manage such a large document as a normal post, so if there is time, I will create it using Latex or some other tool to manage large documents.

Automate system administration tasks using Nagios

As a system administrator, one often have to do repetitive tasks such as checking for free disk space, check mail queues and monitor critical services. If there are only a handful of servers, this task may not be very intimidating, but there are many times when there are many servers to monitor, or just for the sake of automation. This is where Nagios comes in.

Nagios is a host and service monitor designed to inform you of network problems before your clients, end-users or managers do.

This is exactly what we need to make an automated system for monitoring! I will not go into details on how to set this up, since there is an excellent quick start guide available on the website. Instead I will focus on how Nagios has eased the burden of managing a large number of servers.

I have ready made templates for servers and when a new server is added, I just create a copy of the template and add or remove the services needed to monitor the server.

Public services are easy to monitor directly from Nagios, but private data such as disk space and CPU load demands a local service running on each of the servers. This is where NRPE comes into play. NRPE is a daemon which listens on the network and will respond to Nagios queries, using standard Nagios plugins. In Debian and Ubuntu, just install the nagios-nrpe-server package, and in Windows NSClient is very usable and easy to configure.

The last thing is alerts management. All servers that someone else manages, or is in charge of, should receive the Nagios alerts for that server. It will dramatically lighten the administration burden if it is possible to delegate as much as the server / service responsibility to other people. For extremely critical services, there should be an SMS gateway, which sends a message to the administrator or someone in charge of the server. This ensures that attention is immediately brought to the problem.

Run virtual servers using XEN

Running virtual servers may save you a bundle on server costs, but in the same time create a more secure environment by separating services into logical hosts. This guide will show you how to setup a XEN virtual server using Debian, but it may also be used on Ubuntu if that it preferred.


The first task is to install all required software packages. Installing the virtual xen package will in turn install all required programs like a new libc6, kernel with virtual support and the xen hypervisor. Installing xen-tools makes it very easy to create new virtual servers.

# aptitude install xen-linux-system-2.6.18-6-xen-vserver-686 xen-tools

After installing the new kernel and libs, you will need to reboot the computer to use it.


The virtual hosts need some way to access the network, so we have to create a network bridge for them to use. Open the file /etc/network/interfaces and create a section like the following. Be sure to change the network settings to reflect your own network.

iface xenbr0 inet static
bridge_ports eth0

Open up the xen configuration file /etc/xen/xend-config.sxp in your favorite editor and make the following changes.

(network-script network-bridge)
(vif-script vif-bridge)
(dom0-min-mem 196)
(dom0-cpus 0)

The configuration file contains lots of comments, so I will not go into detail about every change.

The last configuration is for the xen-tools package /etc/xen-tools/xen-tools.conf, which we will use to create the virtual machines. Be sure to change the network settings and home directory to match your envionment.

dir = /home/xen
dist   = etch
gateway   =
netmask   =
cache = no
passwd = 1
mirror =

The rest of the values can probably be left alone, but do take a look at them to see if you need to custmize anything.

Now to create a new virtual host, just write the following and debootstrap should start installing a fresh Debian system.

xen-create-image –ip= –

When the installation part is finished, just start the host (or create in xen speak), using the following command.

xm create /home/xen/domains/

If you add the -c option, you will attach to the virtual console and you will see all output from the guest.


Now enjoy your new virtualized server!

Ubuntu 7.10 – The Gutsy Gibbon released

The time has come for the new Ubuntu version to be released. The Gutsy Gibbon is here with lots of new features including desktop search, NTFS writing, encrypted hard disks and AppArmor. You can read more about the new features in the release notes.

Updating to 7.10 is very easy and just involves starting the update manager and press upgrade.


If you don’t want to upgrade or is doing a new installation, just head over to and download your ISO image now!

There was a small meetup in Stockholm yesterday with people from the Ubuntu-SE forums and #ubuntu-se IRC channel. My camera photos did not turn out very well, but hopefully someone else will have some images.

Add proper SSL/TLS support for all applications using stunnel

I really like Evolution both for email and its calendaring features. The problem is that one of my email accounts requires an SSL client certificate to be able to connect. Thunderbird supports this out of the box, but Evolution does not. Instead of patching Evolution itself, it would be much easier to just proxy the requests. Here is where stunnel comes in.

Using stunnel, it is possible to setup an SSL connection and have Evolution run an unencrypted channel through it. Since this will open a tunnel directly to the mail-server, it is very important to only bind stunnel to localhost. Otherwise, anyone will be able to use your tunnel to connect to your server!

So in my scenario I want to use a client certificate in SSL. The following command does everything I need:

stunnel -d localhost:9930 -r mail.xx.yy:993 -c -p ~/mail.pem

It will setup a listening socket on port 9930 and connect it to mail.xx.yy port 993 and use mail.pem for the client certificate. Evolution can now be setup using localhost:9930 as the email server and not using SSL encryption, since it will be added by stunnel.

If you would want this for SMTP, which usually uses explicit SSL (you need to start it using STARTTLS), stunnel even has support for that. Just extend the previous command to this.

stunnel -d localhost:20025 -r smtp.xx.yy:25 -c -p ~/mail.pem -n smtp

Using -n smtp will tell stunnel to create the TLS connection before it lets Evolution proceed with its connection.

Test Ubuntu without repartitioning your harddrive

Many people in the support channels on IRC ask if there is a way to try Ubuntu without having to repartition the drive. There is of course the possibility to run it from the live-CD, but it is very slow and the settings are not permanently stored.

Let me introduce Wubi.

Wubi is a free software installer, specialized for installing Ubuntu and its derivates (Kubuntu and Edubuntu). What makes Wubi special is that it is a Windows based installer, which installs everything into a special loop-device. The user will see this disk images as a normal file within Windows, but it contains the entire Ubuntu installation.


I have not yet had the opportunity to try the Wubi installer, but will of course test this when the time is right. Do note that this is beta software, so don’t be surprised if everything still does not work.

It is the perfect way for people interested in trying out Ubuntu for a while without committing to change the filesystem or having to format or other potentially dangerous operations.