UpFront

diff -u: What's New in Kernel Development

Zack Brown

Issue #193, May 2010

Last year, I wrote about Mathieu Desnoyers' efforts to re-license some userspace read/copy/update (RCU) code from the GPL to the LGPL. At the time, Mathieu was going through the laborious process of getting permission from all the contributors, but IBM held a patent on some of the ideas in the code and had licensed the patent only for use in GPL software. Subsequently, Mathieu wrote to me to give an update on the situation. Apparently, IBM graciously extended its patent license to include the LGPL. And, regarding the remaining kernel contributors, such as Ingo Molnar, who didn't want to release their code under the LGPL, Mathieu was able either to redo the work of those contributions himself or to piece together those bits successfully into a separate GPL-only file, while the lion's share of the code now also could be released as LGPL and the headers under a BSD-style license.

This is one of the few cases of a relatively large number of contributors being sought out and asked permission to re-license their code. As you can see, Mathieu had to resort to some workarounds in a couple cases, such as redoing a contributor's work himself, and his experience may pave the way for other re-licensing efforts. I know several folks have expressed an interest in re-licensing the entire Linux kernel under the Open Software License, and Linus Torvalds has said he might prefer that license over the GPL v2 if he had the choice. But, the Linux kernel is most likely way too big ever to get permission from enough contributors to re-license.

By the way, anyone who wants to correct or augment anything I say here each month is welcome to contact me at zacharyb@gmail.com, as Mathieu did with his update.

A recent effort to enable devtmpfs by default on all kernel compiles has met with some opposition. Kay Sievers pointed out that all major distributions include it in their upcoming releases. Although that may be true, Alan Cox noted that the current releases of those same distributions—that is, the releases in use by nearly everyone—don't include it. At the very least though, it does seem that devtmpfs no longer will be marked “experimental”. It's a bona fide feature, at this point, and probably in the relatively near future when the standard distributions really do ship with it, the kernel folks will enable it by default, as Kay recommends.

The list of stable trees that will continue to be supported is being updated. Greg Kroah-Hartman announced that the 2.6.27-stable tree will be actively maintained by him until sometime around the middle of 2010. At that point, it's expected that Willy Tarreau will take it over from him, but through that time, patches will be fewer and fewer. Instead, Greg said that the 2.6.32-stable tree will be the next long-term stable tree, and he expects to maintain it for another two or three years. One of the primary reasons for keeping this kernel alive is that the major distributions went with that version, so it made sense to provide the distribution maintainers with clean upgrade paths. But, Greg also made it clear that this would have to be a two-way street—he'd maintain the 2.6.32-stable kernel just as long as the distribution maintainers kept feeding him fixes. There's no need to wait until 2.6.27 is put to bed either. As Willy said, everyone should feel free to start sending in fixes for the 2.6.32 tree right away.

Listening on the Command Line

Joey Bernard

Issue #193, May 2010

Linux has tons of programs for listening to audio, including Totem, Rhythmbox, MPlayer and VLC. Each of those examples run in an X11 environment. What if you want to listen to music on the command line? Well, let's take a look. Before we do though, note that this article assumes you have a working audio subsystem on your machine.

Most distributions now use PulseAudio as the audio server, which provides a standard wrapper around the actual audio hardware. This way, software simply needs to talk to the PulseAudio server and doesn't need to worry about the messy details of how to talk to each soundcard out there. The PulseAudio system also includes utilities you can use on the command line. To simply play an audio file, do this:

paplay --volume=32768 example.mp3

This plays the audio file example.mp3 at 50% volume (volume is set between 0 and 65536, or it can be silent or 100%). The paplay utility can play any audio format supported by the libsndfile library, so you should be able to play most audio files you encounter. If you don't have any audio files, use the included parec utility. This program grabs raw audio data from your audio card's input and dumps it to standard output; you can pipe this off to a file to save for later. To play back this raw data, use the included pacat utility. It takes raw audio data and dumps it out to the audio card's output speaker.

What if you want to listen to a whole list of audio files? Several choices are available for handling entire playlists from the command line, such as cplay and moc. Both programs give you a file list on startup, and from there, you can play individual files or construct playlists. Both programs use shortcut keys to create, edit and otherwise manage your playlists.

cplay

moc

You also can make your computer talk to you from the command line. Several utilities can give your computer a voice, including Recite, Festival and eSpeak. The simplest is Recite. It takes text from standard input and outputs audio to the speakers. There aren't many options available. To make a text file speak, execute:


recite <example.txt

You also simply can execute recite, then start typing. Remember that Recite won't see the end of your typing until you press Ctrl-D to mark the end of input. Then, it speaks the entire text you just typed.

Festival provides more options. To get a basic output of text to audio, execute:

festival --tts example.txt

You also can use other languages. The default is English, but for Spanish, Russian or Welsh, use the command-line option --language <string>. Festival also uses Scheme as a scripting language, which opens it up to a huge amount of modification. Spend some time reading the manual at www.cstr.ac.uk/projects/festival/manual for more information.

The last utility is eSpeak, which has several other available command-line options. You can set the amplitude with -a <integer> (0–20; the default is 10), the pitch with -p <integer> (0–99; the default is 50) and speed with -s <integer> (in words per minute; the default is 160). Several voices are available; find out which ones are installed on your system by using the option --voices. Once you select one, use the option -v <voicename> to use it. Then, dump it out to a .wav file with the -w <wave file name> option. A full command line looks like this:

espeak -v en-scottish -w example.wav -f example.txt

You can play it with:

paplay example.wav

Now your computer will speak in a Scottish accent, sort of. Speech synthesis still isn't perfect.

Now that you have all these audio files, you may want to do some processing on them, and sox is a useful tool for doing just that. One utility included in the package is called soxi. It gives you file information about your audio files. In its most basic form, you can use sox to change the file format of an audio file simply by running:

sox example.wav example.au

sox uses file extensions to figure out that you are intending to convert the file example.wav (in wav format) to example.au (in the Sun AU format). You also can do processing on the audio through command-line options. Set the number of bits per sample with -b <bits>. Set the number of channels with -c <channels>. Setting it to mono would be -c 1, and stereo would be -c 2. You can set the sample rate, in Hertz, with -r <rate>. Additionally, many options apply filters to audio files. Read the manual page for more information on sox. Here's an example command line:

sox example.wav -b 8 -c 1 -r 8000 example.au

The above takes an input file called example.wav and converts it to 8 bits per sample, mono (or 1 channel), with a sample rate of 8,000Hz and writes it out to a file with an AU format.

The sox package also contains two other utilities, play and rec, which provide another way of playing audio files and recording audio to a file. sox also provides the full spectrum of processing and filters.

I chose the above example so I could show you one last interesting trick. On Linux systems, you can cat this output file (with this specific file format) directly to the device file /dev/audio. This dumps the output directly to the soundcard. So, if you want to be sneaky, you can convert some files to the AU file format with the sox command above, copy them over to your target machine, and cat them to /dev/audio when you want to make a nuisance of yourself. Now you can enjoy your music and play with audio files, without the overhead of a GUI application.

Non-Linux FOSS

Mitch Frazier

Issue #193, May 2010

For many Linux power users lost in a Windows world, the most glaring omission is the lack of an SSH client. Of course, there's Cygwin and all the good things that come with it in addition to an SSH client (and server), but if you're looking for something a little more lightweight or if you want a GUI SSH client, PuTTY probably is the tool you need. In addition to SSH, PuTTY also supports Telnet and Rlogin.

PuTTY supports most of the features Linux users are used to having: X11 forwarding (you'll need a separate X server for this), port forwarding, tunneling and so on. PuTTY supports SSH-1 and SSH-2 and has support for public key authentication. PuTTY comes with the pscp and psftp companion tools for command-line access to SCP and SFTP.

Because it's a GUI application, PuTTY's settings, including those for different hosts, are configured and stored via the GUI interface. Only when you've actually made a connection to a host do you interact with a terminal window.

PuTTY is mature program. The first release listed in the changelog, 0.45, is from 1999. The latest is 0.60, released in 2007. PuTTY is available from www.chiark.greenend.org.uk/~sgtatham/putty.

PuTTY Configuration

LJ Index, May 2010

1. Millions of hits for a search for “Google” on Google: 1,980

2. Millions of hits for “Yahoo” on Google: 1,590

3. Millions of hits for “Microsoft Bing” on Google: 22.1

4. Millions of hits for “Google” on Yahoo: 5,790

5. Millions of hits for “Yahoo” on Yahoo: 10,700

6. Millions of hits for “Microsoft Bing” on Yahoo: 88.4

7. Millions of hits for “Google” on Bing: 177

8. Millions of hits for “Yahoo” on Bing: 270

9. Millions of hits for “Microsoft Bing” on Bing: 3.9

10. Millions of hits for “Linux” on Google: 294

11. Millions of hits for “Linux” on Yahoo: 1,550

12. Millions of hits for “Linux” on Bing: 253

13. Millions of hits for “Windows” on Google: 831

14. Millions of hits for “Windows” on Yahoo: 3,660

15. Millions of hits for “Windows” on Bing: 384

16. Rank of Google in results for “search engine” on Google: 5

17. Rank of Yahoo in results for “search engine” on Yahoo: 1

18. Rank of Bing in results for “search engine” on Bing: 100

19. Rank of Dogpile in results for “search engine” on Google: 1

20. Rank of Dogpile in results for “search engine” on Bing: 1

1–3, 10, 13, 16, 19: Google

4–6, 11, 14, 17: Yahoo

7–9, 12, 15, 18, 20: Bing

Vendors: Let Us Do Your Dirty Work!

Shawn Powers

Issue #193, May 2010

It wasn't too long ago that all geeks worth their salt had full-blown computers in their living rooms connected to their TVs, running software packages like MythTV, GeeXBoX, XBMC or something similar. Although those packages still are great ways to consume media, they're far from the only ways to do it. Now you can buy embedded media players off the shelf. Popcorn Hour, WDTV Live, Roku, ASUS O!Play and dozens of other embedded devices (most if not all running Linux) will plug in to a television and play video, audio, photos and so on.

The only problem is with customization. Although vendors certainly win when it comes to hardware, their software often leaves a lot to be desired. Hopefully, hardware manufacturers will take what they've learned in the computer world and transition to the set-top box world. Spend time on the hardware and let someone else do the software! Imagine an off-the-shelf device that supplied HDMI, infrared remote, onboard Flash storage and enough flexibility to install your own front end. Now, imagine that device was less than $100. With the Roku SD costing less than $80, it's certainly not a pipe dream.

So vendors, are you listening? We just want to make your life easier! You supply us with awesome hardware, and we'll supply you with awesome software. And, it will be open source—no licensing required.

Let's Party Like It's 1999!

Shawn Powers

Issue #193, May 2010

Studies show taking frequent breaks from work increases productivity, makes for a more pleasant work environment and reduces stress. Although there probably are healthier ways to spend your occasional breaks from work, game emulators certainly provide a fun way to relax. Assuming you're tech-savvy enough to land a job that allows you to use Linux, and that you're geeky enough to desire a way to play old Nintendo games, I think it's safe to assume you will be able to procure ROM images for those games you legally own—you know, those games sitting in a box in your parents' basement.

With the addition of emulators like ROCKnes, iNes, zsnes and their ilk, you can spend those 15-hour, er, -minute, breaks playing classics like Super Mario Brothers, F-Zero, Zelda and so on. If you can land a USB game controller, it will make the experience that much more fun. Let's not fool ourselves, although World of Warcraft might be addictive, it doesn't hold a candle to those 30-hour sessions of Dragon Warrior we used to play over the weekend instead of doing homework. Have fun, and try not to get fired!

Send E-mail with Telnet

Kyle Rankin

Issue #193, May 2010

Poor telnet has gotten a bad rap over the years due to the fact that if you use it for remote logins, your password shows up in plain text. However, even though you should use SSH for remote sessions, you shouldn't completely throw away telnet. After all, telnet is just one way to connect to a remote port and send text commands to it. When you start poking around at a number of protocols like HTTP and SMTP, you'll find that if you know the right commands, you can telnet into those ports and act like a more sophisticated client.

One way I use telnet is to test whether a mail server works. Sure, I could use an e-mail client, but then I'd have to reconfigure it. Plus, sending an e-mail with telnet is a nice geeky party trick (well, maybe the parties I go to), especially if you forge your FROM address.

First, use telnet to connect to port 25 on your mail server:

$ telnet mail.example.net 25
Trying 123.234.123.234...
Connected to mail.example.net.
Escape character is '^]'.
220 mail.example.net ESMTP Postfix

Next, use the HELO command to tell the server what domain you are coming from. It will respond with its name:

HELO microsoft.com
250 mail.example.net

After that, use the MAIL FROM: command to tell the server the e-mail address this e-mail is coming from. The fun part here is that you can make the FROM address appear to be from anyone. If the mail server accepts it, it will reply with 250 Ok:

MAIL FROM: bill.gates@microsoft.com
250 Ok

We're in! Okay, now use the RCPT TO: command to tell the server to whom you are sending the e-mail:

RCPT TO: lj@greenfly.net
250 Ok

Finally, let's type in the body of the e-mail. Type DATA and press Enter. The mail server will respond with instructions to end your e-mail body with an empty line containing a single dot. After this point, I typed in a Subject header and the rest of the body of my e-mail, but you can add as many headers as you want here. When you're done with the message, type a period on a line by itself:


DATA
354 End data with <CR><LF>.<CR><LF>
Subject: Linux is awesome
Hi,

It's Bill. I just wanted to let you know 
Linux is awesome.

Sincerely,
Bill Gates
.
250 Ok: queued as 12BDBE6FEE9

When you're finished with your e-mail session, type quit to exit:

quit
221 Bye
Connection closed by foreign host.

They Said It

If computers get too powerful, we can organize them into a committee. That will do them in.

—Bradley's Bromide

The Internet is the Viagra of big business.

—Jack Welch, Chairman and CEO, General Electric

At some point we must have faith in the intelligence of the end user.

—Anonymous

There are two major products that came out of Berkeley: LSD and UNIX. We don't believe this to be a coincidence.

—Jeremy S. Anderson

One machine can do the work of fifty ordinary men. No machine can do the work of one extraordinary man.

—Elbert Hubbard

Any teacher that can be replaced by a computer, deserves to be.

—David Thornburg

Those parts of the system that you can hit with a hammer are called hardware; those program instructions that you can only curse at are called software.

—Anonymous

Participate at LinuxJournal.com

Katherine Druckman

Issue #193, May 2010

One of the best things about the new LinuxJournal.com is the ability to interact with the Linux Journal staff and your fellow readers. Visit www.linuxjournal.com/participate to search for other readers or find Linux Journal editors and make connections. You'll also find forums, community events and our IRC channel. There are many ways to be a part of our growing community, so check them out and jump right in.

When you visit authors' profiles, you'll see a list of all their articles as well as what they've been up to on LinuxJournal.com. You'll also see their favorite articles, and if you log in, you can leave them a message. We hope you'll make some connections and think of us as your virtual LUG. I look forward to connecting with all of you!