Tag Archives: Linux

Left4Dead2

Some time during the last year I got myself a steam account. Originally, I just wanted to see where Linux gaming was. My verdict: The choices are limited and most games are only available for Windows. But those that are available on Linux (Half Life 2, Portal, Left4Dead, …) are just as playable on Linux as on Windows.

At any rate, during the holiday season Steam gave away Left4Dead2 for free. That’s why I and most of my steam friends at uni have it and why we meet online to play it from time to time, such as today. Guilty as charged, there’s a little video game addict in me ;)

Left4Dead2After all: you have to be prepared for the ultimate zombie apocalypse. Apart from that it’s probably a good idea to make sure you and your colleagues at work (the place where you are most likely going to be when it’s going to happen) are working like a well-oiled zombie defence machine.

Actually that justification sucks …

Logitech K810 + Ubuntu

The Logitech K810 is a nice keyboard, but it does not work with Ubuntu out of the box. Still contrary to what some websites might lead you to believe, it does work. The following instructions worked for me on Ubuntu 13.10 & 14.04.

  1. Start a terminal (terminal 1)
  2. Install the tools needed for this walk-through
    sudo apt-get install bluez-hcidump bluez-utils blueman
  3. Enable Bluetooth on your Ubuntu machine (you might have a hardware button, don’t forget about that)
  4. Start the bluetooth manager (blueman) from your start menu, dash, or whatever other way of starting programs your desktop has
  5. Start another terminal (terminal 2) – yep you’ll need two for this exercise
  6. Get the K810 into pairing mode by pressing the button on the back of the keyboard and then one of the device buttons on the front (F1-F3). You should see the bluetooth light flashing now.
  7. In terminal 1 run
    hcitool scan

    if the K810 is found this should give you something like

    Scanning ...
           xx:xx:xx:xx:xx:xx   Logitech K810
  8. Copy the address of your K810 (that’s the xx:xx:xx:xx:xx:xx)
  9. In terminal 2 run
    sudo hcidump -at | grep pass
  10. In terminal 1 run
    sudo bluez-simple-agent hci0 xx:xx:xx:xx:xx:xx
  11. In terminal 2 you should now see the passkey which is a number
  12. Type that code on your K810 followed by enter
  13. The bluetooth manager should now show the K810.
  14. In blueman select the K810 and mark it as “trusted”
  15. Now click on Setup and follow the dialog box.
  16. Tada, you’re done, you can now close all terminals as well as blueman.

The Function Keys

By default, the function keys (the ones above the numbers row) are assigned to special functions like media control, which I find annoying. – Every time you want to do something normal like Alt-F4 or search via F3 you need the Fn key. Logitech’s windows software on the other hand lets you invert the Fn key. Actually all the Windows software does is to send a certain string of commands to the keyboard, which some clever Linux Guru has reverse engineered and coded into a nice little program, that can be found at  http://www.trial-n-error.de/posts/2012/12/31/logitech-k810-keyboard-configurator/. I’ll again add a step-by-step guide:

  1. Optional: Go to http://www.trial-n-error.de/posts/2012/12/31/logitech-k810-keyboard-configurator/ and read about how he did it ;)
  2. Install a compiler
    sudo apt-get install build-essential
  3. Download and extract Mario’s program
    wget http://blog.chschmid.com/media/k810_conf-v0.1.tar.bz2
    tar -jxf k810_conf-v0.1.tar.bz2
    
  4. Compile it
    ./build.sh
  5. Run it
    sudo ./k810_conf -d /dev/hidraw<x> -f on

    You will have to replace <x> by the hid number that was assigned to your keyboard. In my case it is hidraw2. Of course there are more clever ways, but just work through the numbers brute force starting with hidraw0. – Mario’s program is clever enough to detect if it’s not the K810.

The Making of me.chschmid.com, Part 8: Backup Strategy

Apart from some minor owncloud glitches me.chschmid.com is running pretty smoothly right now. It’s doing a great job, both as my server and my Desktop replacement. But I can’t guarantee that it will stay that way. Neither can I expect the hard disk drives (HDD) to last forever nor can I guarantee that some idiots won’t burn down the apartment building by setting their Christmas tree on fire. (Don’t laugh, it has happened to my sister)

Burning_Logitech_12 Used under CC BY-SA 3.0, originally by Diether

So a backup strategy is in inevitable. Now for the first scenario (a dying HDD) people have come up with a solution known as RAID. However that is not what I am doing. For simplicity, I just copy most of my important stuff from one HDD to another once a day. – Actually the server does this automatically via a cron job file /etc/cron.d/cSBackupLocal

12 4    * * *    root    /usr/local/bin/cSBackupLocal.sh;

which executes a simple rsync script /usr/local/bin/cSBackupLocal.sh that does

# Backup data from first hard drive (me1) to second hard drive (me2)

# GIT - My life and stuff
rsync -a --delete /media/me1/git/   /media/me2/Backup/git

# Music - My other life support
rsync -a --delete /media/me1/Music/ /media/me2/Backup/Music

# owncloud
rsync -a --delete /media/me1/ocdata/ /media/me2/Backup/ocdata

The second scenario (house burning down) can not be dealt with that easily. E.g., with the two HDDs that do the mirroring once a day at the same location, a fire would destroy both. So you have to have a copy at some other place.

My most important things (about 20 megs) I have in an encrypted archive that is synced to Dropbox. Things like my Keepass file and Scans of important documents. – You are right, they might give that file to the NSA or something, but as it is encrypted they’ll chew on it for a while.

The only viable solution for my more extended remote backup is to have an external hard drive, that I bring for doing a backup every now and then. When it is not plugged into my server for backup it is stored away safely somewhere else. – As in not within a 5 km range of my apartment. Obviously this system has flaws, like if there is a fire the day I do the external backup, I am still screwed. – But I guess that is as safe as it gets.

The Making of me.chschmid.com, Part 7: Some More Client Software

Ubuntu comes with almost everything that you can think of out of the box. And almost all of those little exceptions can be found elsewhere. So here’s how to install a couple of those things that I just would not want to miss ;)

Spotify

sudo add-apt-repository "deb http://repository.spotify.com stable non-free"
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 94558F59
sudo apt-get update
sudo apt-get install spotify-client

Screenshot-from-2013-07-23-195423

jdotxt

I have written an app to keep track of my todos, lets install it!

sudo add-apt-repository ppa:chms/jdotxt
sudo apt-get update
sudo apt-get install jdotxt

owncloud client

Can be installed as described at http://software.opensuse.org/download/package?project=isv:ownCloud:devel&package=owncloud-client

sudo echo 'deb http://download.opensuse.org/repositories/isv:ownCloud:devel/xUbuntu_13.10/ /' >> /etc/apt/sources.list.d/owncloud-client.list
sudo apt-get update
sudo apt-get install owncloud-client

The Making of me.chschmid.com, Part 6: Connection to the World

So far the server was in a protected environment, but it’s time to let it see the world! This involves three things:

  • Setting up the server firewall
  • Configuring the dyndns stuff
  • Setting up the router

Server Firewall

You only want those ports to be open that you really need. I’d recommend using ufw for configuring your firewall. In my case

sudo ufw allow ssh
sudo ufw allow http
sudo ufw allow https
sudo ufw deny proto udp to any port 137 from 192.168.22.1
sudo ufw deny proto udp to any port 138 from 192.168.22.1
sudo ufw deny proto tcp to any port 139 from 192.168.22.1
sudo ufw deny proto tcp to any port 445 from 192.168.22.1
sudo ufw deny proto tcp to any port 9000 from 192.168.22.1
sudo ufw deny proto tcp to any port 5901 from 192.168.22.1
sudo ufw deny to any port 3483 from 192.168.22.1
sudo ufw allow proto udp to any port 137 from 192.168.22.0/24
sudo ufw allow proto udp to any port 138 from 192.168.22.0/24
sudo ufw allow proto tcp to any port 139 from 192.168.22.0/24
sudo ufw allow proto tcp to any port 445 from 192.168.22.0/24
sudo ufw allow proto tcp to any port 9000 from 192.168.22.0/24
sudo ufw allow proto tcp to any port 5901 from 192.168.22.0/24
sudo ufw allow to any port 3483 from 192.168.22.0/24

which means allowing access to SSH, HTTP and HTTPS from anywhere in the world and to the squeezebox server and the Samba server only from the local network but not from the router.

Dyndns Stuff

My provider gives my router a new IP (= unique address on the web) from time to time. To be able to find my router/computer from the outside world, I have to report my IP to someone who can help me find it any time.

Here is how it works: me.chschmid.com points to chschmid.mooo.com and chschmid.mooo.com I have tell what my current IP is when it has changed. It’s less complicated than it sounds

  1. Get an account at http://freedns.afraid.org/
  2. Download the latest IPdetect from http://ipdetect.sourceforge.net/
  3. and set it up as described in the readme file ;)

By the way if your router is running on a modified firmware such as DD-WRT, this task can also be handled by your router and configured via its web interface. Just search for Dynamic Domain Name Service (DDNS). Sadly DD-WRT is not an option for me as the 5 GHz support is broken for my router :(

The Router

First I had to tell my router that my server should always get the same local IP 192.168.1.200 based on its MAC address.

static_ip

And secondly ports 22, 80 and 443 have to be forwarded to that local IP. Here’s a screenshot what this looks like in my case.

port_forwardingNow this calls for some champaign! The server is set up and online! You can take a look at some server stats at https://me.chschmid.com.

The Making of me.chschmid.com, Part 5: Server Configuration

With the base OS up and running it’s time to install and configure all the services. By the way it is important that the server is not connected to the Internet directly yet. – Working behind a router is ok. You just don’t want that out your server can be accessed via the web already.

server

SSH

SSH is a secure way of accessing your machine from anywhere. You can transfer files, run commands, tunnel services and probably much more using SSH in an easy and encrypted way. After the server installation SSH is running already. But I did some modifications to the config file “/etc/ssh/sshd_config” to make it even more secure. Basically I added one line

AllowUsers christian cs-git

to only allow incoming connections for those two users. Restarting the ssh daemon can be done via

sudo service ssh restart

Apache

I don’t want my machine to be accessible via HTTP, but only through the more secure HTTPS. So I configured port 80 to redirect to 443 and enabled https. I also added the following lines to my https config file

SSLProtocol all -SSLv2 -SSLv3
SSLHonorCipherOrder On
SSLCipherSuite
ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:ECDH+3DES:DH+3DES:RSA+AES:RSA+3DES:!ADH:!AECDH:!MD5:!DSS
SSLCompression Off

to make the encryption more robust. – You can check how robust your encryption is via https://sslcheck.globalsign.com.The apache server can be restarted again via

sudo service apache2 restart

Owncloud

… can be installed easily via an opensuse repository at http://software.opensuse.org/download/package?project=isv:ownCloud:community&package=owncloud. The configuration works via the web interface https://localhost/owncloud.

In my case I just transfered the complete database from my old machine to the new server.

Samba Server

The Samba Server is used to share files locally, so that I can download the music files stored on the server from my tablet whenever I am in my local network and stuff. – Again Samba should be installed already and only needs to be configured. I added

[media]
    comment = Media
    path = /home/media
    browsable = yes
    guest ok = yes
    writeable = no
    write list = media
    force group = media
    create mask = 0775

to my “/etc/samba/smb.conf” to share what is in the /home/media folder and allowed following symlinks

follow symlinks = yes

I forgot of course I also created a user media using “sudo adduser media”. I again restarted smbd and nbmd

sudo service smbd restart
sudo service nmbd restart

Squeezebox Server

I use this system to stream my audio across multiple devices (including my Raspberry Pi). To install the server run

sudo add-apt-repository "deb http://debian.slimdevices.com stable main"
sudo apt-get update
sudo apt-get install logitechmediaserver

Misc

I also installed and configured the following things

  • A vncserver (x11vnc)
  • The Plex Media Server (can be found in Ubuntu’s repositories)

Im glad you made it to the end of this rather boring post, but that is what servers are all about: Running boring stuff in the background that makes our lives easier and more connected.

The Making of me.chschmid.com, Part 4: The Operating System

With all components where they should be and the machine booting, installing an operating system (OS) was the next step. GNU/Linux was the obvious choice and all of my machines run on Ubuntu, so Ubuntu it is.

As the machine is intended to act as server, Ubuntu 12.04LTS would make sense, however as my Xeon Haswell CPU (E3-V1245V3) is relatively new, the Linux Kernel and drivers that come with 12.04 are not a perfect fit for the hardware. – So Ubuntu 13.10 it is.

It was as simple as this: Download the 13.10 server image from http://www.ubuntu.com/, put it on an USB drive using http://www.pendrivelinux.com/ (Windows) or the Startup Disk Creator (Linux). Restart the machine, enter the boot menu by pressing F12 and boot from the USB drive. The setup is quit intuitive. As I started with an empty SSD, all I had to do is select automatic installation using LVM on the empty hard drive. To start with I selected LAMP, OpenSSH and Samba as server roles.

The computer rebooted after the installation leaving me with a login prompt.

login

After login I installed all the stuff that I would need to also run the PC as desktop.

sudo apt-get update
sudo apt-get dist-upgrade
sudo apt-get install ubuntu-desktop vlc vainfo lm-sensors calibre texlive-full ipe audacity p7zip thunderbird eclipse wine git-core keepass2 gparted filezilla inkscape chromium-browser kile qjackctl virtualbox virtualbox-guest-additions-iso pavucontrol pulseaudio-module-jack joe rosegarden xdotool musescore dconf-tools openjdk-7-jdk libva-intel-vaapi-driver ufw gufw nautilus-open-terminal smartmontools gksu gimp build-essential devscripts debhelper javahelper

Finally reboot the machine and you should be greeted by a graphical user interface.

sudo shutdown -r now

Lenovo Thinkpad X121e + Ubuntu 12.04 x64

I have already blogged about how cool my new Thinkpad X121e setup running on Ubuntu 12.04 x64 is. I’d like to get a little bit more technical in this post. First of all, as so many have asked before: AMD E-450s (but also E-350s) can play Full-HD videos in Linux!!!

So here’s my setup

Lenovo Thinkpad X121e
Processor: AMD E-450
Graphics: Radeon HD 6320
8GB RAM
WIFI: … see below

Installing Ubuntu 12.04 is really easy, just download the *.iso from ubuntu.com, create a bootable flash drive using the Universal USB Installer from www.pendrivelinux.com and boot from it.

Everything should work out of the box but these three things:

1.) Full-HD video acceleration

First of all: Yes I can watch Full-HD videos on my machine! Here’s what you have to do:

The standard open source driver that comes with Ubuntu can’t do it and you need additional software to really get it working. First you need to install the proprietary driver from AMD. Right now it seems that only Catalyst 12.4 is working for the E-450. (I tried the 12.6 version just yesterday, AMD did not sign it for the E-450, so leave your hands from this one). Although Ubuntu offers you to install the proprietary driver, I would do it manually. Here’s how to

1.1.1 Get the 12.4 driver for Linux x64 from AMD’s website (Not the 12.06 version!!!!!)
1.1.2 Follow the steps from https://help.ubuntu.com/community/BinaryDriverHowto/ATI, scroll down to the “Manually installing Catalyst” section and do everything as stated there, except replace the version number with 12.4.

So far so good, now reboot your machine. To play Full-HD movies you’ll have two options
1.2.1 Use the XBMC that plays along with XvBA (see http://forum.xbmc.org/showthread.php?tid=116996 for how to install it) for watching Full-HD stuff
1.2.2 Open a terminal and use “sudo apt-get install xvba-va-driver libva-glx1 vainfo” to install a kind of wrapper for AMD’s XvBA needed. Also install VLC, open it and select “Use GPU accelerated decoding” under Tools -> Preferences -> Input & Codecs. After restarting VLC you should be able to watch Full-HD properly. If you are having problems search the web for “AMD vaapi xvba-va-driver” or similar terms. It worked for me out of the box.

2.) WIFI

The Wifi card that comes with the machine, is a real horror for Ubuntu. I even tried to download the driver from Realtek (which is the manufacturer of the card) directly and compile it myself. Even with that I did not get a stable connection when the signal was weak or when I was in a WIFI crowded area. What solved my problem was buying an Intel 6200 WIFI card and a half-> full size PCI card adapter, which was 15€  for both on ebay. – Remove your Realtek card, plug the WIFI card + adapter into the spare port of your PC and you’re good to go. The Linux kernel 3.2 supports the Intel 6200 out of the box.  Some might ask why not to use the port where I removed the Realtek WIFI card. Well that is because the Lenovo BIOS won’t let you use it there (Unless you modify the bios which is really tricky and dangerous)

3.) The trackpoint

I’ve never had a trackpoint before, but I really love it now. It is a shame that  one out of 10 time when I start the computer it does not work. The following commands make it work again:

>> sudo modprobe -r psmouse
>> sudo modprobe psmouse

It takes a few seconds for psmouse to load, but then everything should work again. I am thinking about putting this code into /etc/rc.local or something, but right now I just type it every time I have problems.

I hope this guide is helpful. Let me know if you’re having problems or suggestions!