Category Archives: Linux

Install Alsa Audio Driver on Ubuntu

I recently upgraded to the latest version of Ubuntu, which is currently version 12.04. Version 12.10 is just a little over than a month away from being released. With my Ubuntu 12.04 install, I was experiencing some crashing issues with the Unity desktop which drove me nuts. I ended up taking some extreme measures.

I went and installed Xubuntu instead of Ubuntu. Xubuntu uses the Xfce desktop interface. It’s much simpler and quite stable, except for the sound. Why can’t I get a problem-free distro for once. The default PulseAudio audio driver in Xubuntu was stuttering, especially when playing Youtube videos. So, I ended up removing the Pulseaudio and installing Alsa instead.

So, here are the steps I took to get my sound working.

$ sudo apt-get remove --purge alsa-base pulseaudio
$ sudo apt-get install alsa

I also had to edit the /etc/modprobe.d/alsa-base.conf file. Add this line at the end of the file.

options snd-hda-intel model=generic

Save and reboot.

Install DD-WRT on Cisco E1200

The Cisco E1200 is a relatively inexpensive wireless access point. I bought one from Amazon for under $50 dollars. It’s a Wireless-N device with transmit speeds to up to 300mbps. It operates in the 2.4Mhz band, with two internal antennas, and four Fast Ethernet ports. It comes with Cisco Connect, and support for IPV6, as well as a guest access feature.

It gets even better. Starting in the spring of this year, DD-WRT open-source firmware is now supported on this device. DD-WRT will give the Cisco E1200 stability, and features that you normally see only on high-end wireless routers. With DD-WRT, you can create virtual networks or guest networks just like on the original Cisco firmware. Plus, you’ll get a ton of other features.

You can purchase the E1200 for under $50 dollars. There are two versions of the E1200. Depending on what you end up with, you can download the appropriate DD-WRT firnware for the E1200 version 1 or version 2.

Finally, here’s a screenshot of my Cisco E1200 running DD-WRT.

Mangler A Ventrilo Compatible Client for Linux

If you’re working with Ventrilo, you will learn quickly that there’s no Ventrilo client for Linux. It has been under development since 2005. Seven years later, it still hasn’t happened.

Good news, bad news. Bad news first. The bad news is I don’t think there will be a Ventrilo client for Linux ever. But, don’t fret. There’s good news. There’s a Ventrilo compatible client for Linux called Mangler. You can download the client from Mangler’s website.

Just download the appropriate version for your desktop. I’m using the 64-bit Debian-based package for Ubuntu 10.04. I downloaded it and ran the install via Gdebi Package Installer. The Mangler icon will be added under the Internet of the Gnome 2 menus, the default Ubuntu 10.04 desktop manager.

By the way, Mangler works great. I was able to transmit and receive signals from a Mangler client to a Ventrilo client and vice versa. Awesome app!

Install Ventrilo Server on Ubuntu 12.04

Ventrilo is a VoIP group communications software used by business users, gamers, or anyone needing group communication. A typical setup usually requires a Ventrilo server and some Ventrilo clients connected to it. The client software is available on Windows and the Mac.

Ventrilo server is available on many platforms such as Windows, Mac, Linux, Solaris, FreeBSD and NetBSD. Ventrilo server is available in two versions: (1) the public version which defaults to port 3784 with up to 8 users, (2) and the pro version that is configurable that can run on multiple servers and thousands of users.

This article will show how to install Ventrilo Server on the latest version of Ubuntu Linux, currently version 12.04. Credit goes to Ben Wagner for his article on installing Ventrilo server on Ubuntu 10.10.

Download

First, download the latest Linux version of Ventrilo Server from Ventrilo’s website.

Upload and Unzip

FTP the tar file to the home directory of your web server. Unpack the zipped file.

$ tar -xzf ventrilo_srv-3.0.3-Linux-i386.tar.gz
$ cd ventsrv

Create Ventrilo user

$ sudo useradd ventrilo

Move Binaries

Move the binaries to /usr/bin and make them executable.

$ sudo mv ventsrv/ventrilo_srv /usr/bin/ventrilo_srv
$ sudo mv ventsrv/ventrilo_status /usr/bin/ventrilo_status
$ sudo chmod +x /usr/bin/ventrilo_srv /usr/bin/ventrilo_status

Move config file

$ sudo mkdir /etc/ventrilo
$ sudo mv ventrilo_srv.ini /etc/ventrilo/ventrilo_srv.ini
$ sudo chown -R ventrilo:ventrilo /etc/ventrilo

Create the Start/Stop scripts

Insert the contents of this script into the ventrilo file. Make the file executable. Add the scripts to the boot sequence.

$ sudo nano /etc/init.d/ventrilo
$ sudo chmod 755 /etc/init.d/ventrilo
$ sudo update-rc.d ventrilo defaults

Start Ventrilo

$ sudo /etc/init.d/ventrilo start

* Starting VOIP server ventrilo
8931 (process ID) old priority 0, new priority -5 [ OK ]

Stop Ventrilo

$ sudo /etc/init.d/ventrilo stop

* Stopping VOIP server ventrilo [ OK ]

Customize Config

Edit the Ventrilo config file.

$ sudo nano /etc/ventrilo/ventrilo_srv.ini

The contents will look similar to this.

[Server]

Name=ServerName
Phonetic=Servername
Auth=0
Duplicates=1
AdminPassword=password
Password=password
SendBuffer=0
RecvBuffer=0
Diag=0
LogonTimeout=5
CloseStd=1
TimeStamp=0
PingRate=10
ExtraBuffer=0
ChanWidth=0
ChanDepth=0
ChanClients=0
DisableQuit=0
VoiceCodec=3
VoiceFormat=18
SilentLobby=0

Pay attention to VoiceCodec and VoiceFormat. I’m using 3 and 18 respectively, so it’s compatible with the Mac OS clients.

Firewall Rules

The standard default port for Ventrilo server is port 3784. With the public version, you can connect up to 8 users concurrently. If you have a firewall installed such as iptables, you will need to open up port 3784 for both TCP and UDP. Here are the rules you will need to add to /etc/iptables.firewall.rules.

# Allow Ventrilo
-A INPUT -p tcp --dport 3784 -j ACCEPT
-A INPUT -p udp --dport 3784 -j ACCEPT

Apply the new rules.

$ sudo iptables-restore < /etc/iptables.firewall.rules

Just connect the Ventrilo clients to the server.

That's it.

Fail2Ban

Fail2ban is an intrusion prevention framework written in Python. It operates by monitoring logs and running certain scripts based on findings. A good example where Fail2ban is used, is when there are repeated failed password attempts to a SSH port. Typically, the offending host is locked out for a period of time.

Fail2ban is ideal when there’s a brute force attack on a server. It will slow down an attack since the blocked host is locked out for a period of time. Although, it prevents attack from a single host, it shortcoming is, it fails to protect against a distributed attack from a network of computers.

Fail2ban is generally used with firewall programs such as Iptables, which are available on most Linux based servers. Fail2ban updates the firewalls rules when successive failed attempts occur on the system, therefore locking out the remote host for a certain period of time.

To install Fail2ban on Ubuntu or Debian from the Terminal:

$ sudo apt-get install fail2ban

You can edit the config file to update the settings. For example, you can increase the bantime from 600 to 1200 seconds. Or you can increase maxretry from 3 to 6.

$ sudo nano /etc/fail2ban/jail.conf

Run Crontab As A Certain User

Crontab is great when you want to run a program or a script at certain times of the day, week or month. You just schedule crontab, and it will run for you automatically, almost all the time, without a hitch. Crontabs are great if you have certain requirements that you want to run at specific times of the day. Now, each system user has their own individual crontab.

To run Crontab as a yourself, you simply type in the Terminal.

$ crontab -e

The crontab format is typically: * * * * *  /var/www/yourscript.sh

But, I’m not going to go into details about crontab in this post.

If you need to run Crontab as another user, simply use the -u switch.

$ crontab -u username -e

If a user doesn’t have permission to run crontab, you may need to run it as sudo.

$ sudo crontab -u username -e

Simple Invoices 500 Internal Server Error

Simple Invoices is a free, open source, web based invoicing system that you can install on your server, desktop, or at a service provider. I installed Simple Invoices on a webhost company I rather not mention. The application was working fine, until they tweak their PHP settings several months back. As a result, the PDF export in Simple Invoices no longer worked. I was bummed. So, I was forced to run Simple Invoices from my home server, which was fun, but the issue was, I can’t access it outside of the house.

So, I decided to install Simple Invoices on my new account at Linode. Now, the funny thing was, the application won’t even come up. Not even a login page. So, I searched online for a possible solution to my dilemma. Some suggested to increase the php memory settings to 128M, but that didn’t work out for me. At one time, I thought I had a missing pdo_mysql module, but that wasn’t the case. Then, I stumbled into something that led me to the ultimate discovery.

Simple Invoices has this configuration file called config.ini located inside the config folder. One thing this application doesn’t like are extra characters inside the config file. I happen to like funky passwords with interesting characters like +-)!@#. My MySQL password happens to have a close parenthesis in it. Essentially, this extra character caused the entire application to not start. So, I change my password, and sure enough, the application worked.

So, if you ever get a 500 internal server error with the Simple Invoices application, make sure you don’t have any of those extra characters inside your config.ini file. I wasted two hours trying to fix this issue, only to be surprised by such an idiotic requirement. That means I can’t use difficult passwords for this application. I think this is either a design issue or a funny requirement of the Zend Framework, which by the way, Simple Invoices is written on. It was somewhat funny, but I wasn’t amused.

Use UUIDGEN For Passwords

An impenetrable system is only as good as its weakest password. Computers systems are often attacked using brute force. Most users tend to use really simple and easy to guess passwords. The use of complex passwords on the other hand, makes it almost impossible for them to remember. That’s why passwords typically fall in the 6-8 character range.

For systems and applications, that don’t need human intervention, when communicating to databases and other systems, a much more complex password can be assigned. These passwords typically do not need to be typed-in on forms, so they can be long, difficult and outrageous. There’s a Linux utility called UUIDGEN which randomly creates and generates unique universal identifiers.

A typical output would be:

150152b0-cd0e-11e1-9b23-0800200c9a66

These keys are perfect for systems and applications. For example, WordPress requires a username and password to talk to the MySQL database. The database credentials are typically stored in wp-config.php file. A key generated by UUIDGEN can be used in this scenario. This is just one example where long and difficult passwords can be deployed. They can be used for other purposes as well.

So, if you have access to a Linux system, to generate a unique key, all you have to do is type the command, “uuidgen” in the Terminal.

WordPress Blank Dashboard

I recently moved one of my blogs to Linode, a VPS hosting company. I noticed right away, when I logged in as admin, that the WordPress Dashboard, displayed a blank page. That’s not good. So, I started removing plugins by renaming the plugin directories until I found the offending plugin. Sure enough, it was a custom plugin I wrote myself.

Nothing has changed. The plugin hasn’t been touch. WordPress is the same latest version. The only thing that changed was the host server. So, I started looking into my PHP installation. What could possibly be missing? When I looked into my plugin code, I noticed some references to curl. I realized my server was missing a php5-curl module on the new host server.

A simple command to install php5-curl on the new server does the trick.

$ sudo apt-get install php5-curl

In this particular case, a missing module in PHP, caused the plugin to die unexpectedly, resulting in a blank Dashboard page within WordPress. Removing offending plugins temporarily fixes the issue, but it doesn’t get to the root of the problem. In my case, I was able to narrow it down to the missing PHP curl module that my plugin desperately needs.

In any case, everything is back to normal as expected, except for the blog, which is serving pages exceptionally fast, since I’m now running at Linode.

Linux Nano Editor

In metric terms, nano means one billionth of a unit, or 10-9. Apple has a product called the iPod nano. In Linux terms, Nano is simply a terminal editor. If you’re looking for an alternative to the vi editor, then consider using Nano.

Nano is derived from the words Nano’s ANOther editor. Nano is an enhanced Pico clone, Pico being another Linux terminal editor. Nano is a little bit quirky in the beginning if you’re coming from the vi world. But, once you’re used to the editor, you’ll be glad you tried it.

In my opinion, I think you can do editing faster in nano than in vi, once you get used to all the controls. Here are several common and important controls within Nano that you should be familiar with: Crtl-O to save, Ctrl-X to quit, Ctrl-K to cut, Ctrl-U to paste. Ctrl-Y to page up, and Ctrl-V to page down.

Read up on the basics of the nano editor.