Useful commands #3: Deleting files with special characters in their filenames

Leave a comment

Successfully tested on Ubuntu Server 12.04 LTS 64-bit

Ever been stuck with a weird file you wanted to delete? You know, those lock files with special characters in their filenames left all over your Samba shares by some Windows applications (for instance)? Today’s post will help you get rid of them in a snap.

First of all, make sure your current directory is the one where your annoying file is located:

cd directory_containing_weird_file

Next, list directory’s content using the –inode option:

ls -i

You should now see a listing with a number at the beginning of each line. This number corresponds to the unique inode ID of each file and we’ll use it as identifier for the deletion, instead of our bizarre filename. Just do:

find . -inum inode_ID_of_your_file -exec rm -i {} \;

The recalcitrant IS wiped out for good this time!

That’s all Folks!

For further reading, you can take a look at ls and rm man pages which detail some other interesting options.

Installing Serviio media streaming server on Ubuntu

Leave a comment

Successfully tested on Ubuntu Server 12.04 LTS 64-bit

Having a home server to centralize and share documents over your network, publish websites or run your own mail server is pretty cool in fact, but today is time to have more fun with your computer rig. Let’s talk about multimedia sharing, streaming and transcoding with the installation of a DLNA server: Serviio.

First of all, head to Serviio website, look for the link to the latest archive for Linux and download it:

wget link_to_latest_serviio_archive

Create the /opt/serviio directory and unpack the file to it:

mkdir -p /opt/serviio && tar -C /opt/serviio -xvzf serviio_archive.tar.gz --strip-components=1

Then, create a serviio system user:

adduser --system --home /opt/serviio serviio

and assign the installation folder ownership to him:

chown serviio:nogroup -R /opt/serviio

Create another specific folder which will be used by Serviio to temporarily store the transcoded files (choose the path you prefer but make sure it points to a partition with sufficient free space as multimedia files can be huge):

mkdir /media/md0/.tmp

change its access permissions:

chmod 1777 /media/md0/.tmp

and then modify the /opt/serviio/bin/ script to point to this folder by adding the following parameter at the end of the JAVA_OPTS= line:


Now, install all the third party applications needed to have a fully working Serviio: First, install Java if it’s not already installed:

apt-get install default-jre

Then, build and install FFmpeg according to the instructions you’ll find in Serviio and FFmpeg Wikis (FFmpeg Wiki contains useful specific instructions dedicated to server/headless machines).

Finally, install dcraw if you need RAW images support:

apt-get install dcraw

We’re close to the end now. Let’s just make sure the DLNA server will be launched at startup. To do this, simply create an init script /etc/init/serviio.conf with the following content:

# Serviio - Media Streaming Server
# Serviio is a free media server. It allows you to stream your media files
# (music, video or images) to renderer devices (e.g. a TV set, Bluray
# player, games console or mobile phone) on your connected home network.

description "Serviio - Media Streaming Server"

env USER=serviio
env LANG=fr_FR.UTF-8

start on started networking
start on mounted DEVICE=[/UL]*
stop on shutdown


exec start-stop-daemon --start --make-pidfile --pidfile /var/run/ -c $USER --exec /opt/serviio/bin/

(the LANG setting is optional and can be used to define a specific locale)

You can now start the DLNA server (also stop or restart) using the service command:

service serviio start

As everything went fine (of course!), you should soon see the server on any UPnP/DLNA device connected to the same subnet. If not, look for suspicious entries in /opt/serviio/log/serviio.log. If you need a more verbose log, modify the org.serviio category as follows in /opt/serviio/config/log4j.xml:

<category name="org.serviio">
   <priority value="DEBUG"/>

and restart Serviio. Now, you should have some clues to help you solve the problem.

One last useful tip: Unfortunately, Serviio lacks a web console in our headless setup. You can find some, proposed by users on Serviio forum, but the easiest solution, for now, is still to install the console on a local Windows client to remotely manage your server settings. Before launching this console, make sure to edit the C:\Program Files\Serviio\bin\ServiioConsole.exe.vmoptions file on the client, add the following line:


and everything should be fine.

That’s all Folks!

For further reading, see Serviio very informative wiki and forum.

Useful commands #2: Removing old kernels

Leave a comment

Successfully tested on Ubuntu Server 12.04 LTS 64-bit

In a recent post, I explained how important it is to keep your operating system up to date. If you followed my advices, you may have noticed that Ubuntu’s package manager does not delete any old kernel when upgrading to a new one. It’s on purpose, just to have a known good kernel around in case the upgrade fails. While this is a rather reassuring behavior, you could also want to get rid of these old kernels (to free up some space on your hard disk for example). Let’s see how.

Before doing any cleaning, first write down your current kernel release. You’ll find it by running:

uname -r

Next, simulate the old kernels removal:

dpkg -l linux-* | awk '/^ii/{ print $2}' | grep -v -e `uname -r | cut -f1,2 -d"-"` | grep -e [0-9] | xargs sudo apt-get --dry-run remove

Here, the –dry-run parameter allows to see the events that would occur during real removal but no change is actually done to the system. Check all the informations displayed on screen to make sure there was no error and verify that your current kernel release was not listed anywhere.

If everything looks fine, you can run the command for real:

dpkg -l linux-* | awk '/^ii/{ print $2}' | grep -v -e `uname -r | cut -f1,2 -d"-"` | grep -e [0-9] | xargs sudo apt-get -y purge

Old kernels are history now.

That’s all Folks!

For further reading, see the Ubuntu wiki to understand why this removal is not so easy to automate.

Older Entries