UNetbootin Creates USB-Bootable Linux the Easy Way [Featured Download]

Posted on August 27, 2008 by Kevin Purdy.
Categories: Contributors, UNIX.
Windows and Linux only: Free bootable image creator UNetbootin automates the downloading, imaging, and installing of Linux distributions onto USB thumb drives, creating a persistent, boot-anywhere desktop. We've previously featured rather involved guides to putting Linux on a flash drive, but UNetbootin does it all for you, from downloading the right ISO to setting up a USB stick as a bootable Linux drive. It can also convert almost any bootable ISO, so if you've got an old, smaller thumb drive not seeing much use these days, you can use UNetbootin to install a partition editor, a file-recovering live CD, or the Windows password-cracking Ophcrack. UNetbootin is a free download for Windows XP and higher and Linux systems.
UNetbootin [via Tombuntu]

Edit binary files in Vi

Posted on August 10, 2008 by Jason Striegel.
Categories: Contributors, UNIX.

cafebabe_20080809.jpg

If you've ever wanted to examine or edit a binary file in your favorite text editor, there's an easy way to simulate a vi hex mode. To do this, you just filter the file's contents through the xxd hex dump utility, a trick that can be accomplished right within the vi/vim interface.

To convert a file to hex dump representation, just load your file in vi and type the following:

:%!xxd

This sends the entire contents of the opened document to xxd and loads in the result. At this point, you can view or edit any of the hex data. The ASCII representation is listed to the right, though editing this region will not affect the hex portion of the file.

When you are done, you'll want to convert things back into their binary format before saving. To do this, you run things through xxd again, but this time with the -r option:

:%!xxd -r

Your file should be returned to illegible gibberish, which you can save back out with :wq.

A funny thing I just noticed: OS X binaries all start with the same 4 bytes which, in hex, spell out the phrase "cafe babe". This is just a magic number used to identify the file as an OS X binary, but it's hard not to ascribe some deeper meaning. ;)

Top 10 Command Line Tools [Lifehacker Top 10]

Posted on July 30, 2008 by Kevin Purdy.
Categories: Contributors, UNIX, Windows.


When you need something done quickly, efficiently, and without any software overhead, the command line is where it's at. It was the first way humans told computers what to do, but as graphics became increasingly important, the command line, or terminal, became an insiders' secret weapon. But with the right commands and a little bit of know-how, anyone can get things done from a text-only interface. Let's take a look at 10 commands and tricks that make the terminal more accessible, and more powerful, on any system. Photo by blakepost.


Note: Mac OS X and Linux users have robust command line interfaces baked right into their systems. To get to them, head to Applications->Utilities->Terminal in Finder. It varies in Linux, depending on your distro and interface, but a "terminal" can usually be found in an "Accessories" or "Utilities" menu panel. Windows users are best served by installing and configuring Cygwin, a Unix emulator, which we've detailed in a three part series.


10. Customize your prompt

term_customized.jpgIf you're going to spend any time at the terminal, or want to start doing so, it should be a welcoming place. To go beyond green or white on black, check out this Ask Lifehacker response, in which Gina runs through a few simple ways to change the colors, and the greeting message, on your prompt for Windows, Mac, or Linux systems.


9. Force an action with sudo !! ("bang bang")

sudo_bang_bang.jpg You already know that prefixing a command with sudo makes your system execute it with superuser privileges. But when you forget to sudo, the !! or "bang bang" comes to the rescue. When you've perfectly crafted a long command that does exactly what you need, hit Enter, and d'oh—you don't have sufficient access privileges—you can sudo !! to repeat the last command with superuser privileges. It's the ultimate nerd triumph: "Oh, you didn't like that command? Well, then sudo !!"


8. Create whole directory trees with mkdir

When it comes to organizing music, pictures, documents, or other media, nested folders become a necessary annoyance—as in right-clicking, choosing "New Folder" and then naming and clicking through each of "The Beatles->White Album->Disc 1." It's far easier from the terminal, as the Codejacked blog points out:
mkdir The Beatles\White Album\Disc 1
Some terminal users have to add a \ before spaces, but you get the idea. If you're a Vista user who's just not down with Cygwin, you can still pull this off with the md tool in command line.


7. Filter huge lists with grep

Some terminal commands spit back a bit too much information, and that's where grep comes in. Need to manually kill a faltering Thunderbird? Punch in ps aux | grep bird, and you'll get back the specific number to kill. Need to know which files don't have your company name in them? grep -v DataCorp *.doc. Programmer Eric Wendelin explains grep more in-depth.


6. RTFM with man (and more)

man_cropped.pngLet's say a program, or web site, has just asked you to run a command to unlock or enable something, but you'd like to know just a little more before jumping in. Add man before the command (as in man ssh) and you'll get manual-style pages detailing how to use the command. Bit too much material to process? Try whatis for a brief description, --help after the command for basic usage, or any of these other command-line learning tools.


5. Manage processes with top

Most systems have a tool to view "tasks" or "running programs," but they usually hide the true guts of what your system's doing from you. The Hackszine blog points out that Mac and Linux users can harness the power of the built-in top command to track and kill runaway processes making your system unstable. There's also ps -aux for a single-screen, non-updating look at what's bugging your computer.

4. Master wget for powerful file-grabbing

wget_cropped.jpgThe wget command has been around since before there was all that much stuff to actually yank from the net, but this extensible, multi-purpose tool has lots of great uses these days. You can mirror entire web sites locally, resume huge downloads on the flakiest of connections, download the same file every hour to keep tabs on a project, and do much, much more with wget. It's one of those elegantly simple tools that's only as powerful as your creativity.


3. Get way beyond system searching with find

Once again, programmer Eric Wendelin offers real-world examples of how powerful a command line tool like find can be in, well, finding files and directories that match the smallest criteria you can imagine. Want a list of every HTML file that references the hexidecimal color #FF0000 (red)? find can totally do that for you. As Wendelin points out, find, by itself, is about as convenient and powerful as a total-system searcher like Google Desktop or Quicksilver, but piped into and out of other tools like grep, it's a powerhouse. For a more pared-down look at some of find's powers, check out this tutorial at Debian/Ubuntu Tips & Tricks.


2. Set up powerful backups with rsync

rsync_cropped.jpgYou can spend a lot of money and time hunting down a perfect backup app that works with all your systems just the way you want. Or you can spend a few minutes learning the basics of rsync, the flexible, powerful command that makes one folder (on your system) look like another (where you back up). To put it simply, rsync is a cross-platform, completely free Time Machine, if you use it right. Luckily, Gina's already shown us how to do that.


1. See your most-used commands with history, make aliases for them

awk_cropped.jpgOnce you're comfortable with the terminal and getting good use from it, you might notice some of the more useful commands require an astute memory and typo-free typing—unless you make them shorter and easier. Start off by copying and pasting this command (on one line):
history|awk '{print $2}'|awk 'BEGIN {FS="|"} {print $1}'|sort|uniq -c|sort -r
It will return a ranked list of your most commonly-entered commands using your command history—and you can start creating aliases to shorten them and make them easy to remember. Or you could search through your recently-used commands with as-you-type results for quick-fire repeats.


While these 10 commands are generic and applicable on all systems with a Unix-like terminal, Mac OS X offers a few Mac-specific tools. Here are useful command line tricks for Mac users.


We're love to have some CLI fun around here, and we know our savvier readers have tons of cool terminal hacks and tricks that are new to us. So, please—share the knowledge and spread the wealth in the comments.


Run Windows Apps in Linux with Wine 1.0 [Feature]

Posted on June 20, 2008 by Kevin Purdy.
Categories: Contributors, UNIX.
No matter how easy Linux distributions make it for newcomers to install and use a free, open-source operating system, nearly everyone has at least one program that only works in Windows. Wine, a free Windows compatibility tool for Linux (and other Intel-based systems), aims to make those programs run without too much cross-system trickery. If you can't get around needing to open true Microsoft Office files, Adobe Photoshop, or your addictive game of choice on your Linux desktop, Wine is for you. With Wine's stable 1.0 version just released, it's a good time to check out this quietly awesome app. Let's get a few Windows applications running in Linux.

Wait, before I try this, will X program run okay in Wine?

apps_cropped.pngGood question—luckily, there's probably an answer. The Wine AppDB lists all the programs that run and don't run under Wine, and to what degrees. You'll see rankings randing from "Platinum" (runs pretty much flawlessly) to "Bronze" (some functions may not work at all, but otherwise runs) to "Garbage" (don't bother). In general, any apps that rely on other Windows apps or functions, or interact with the Windows desktop, won't work as well, if at all. That means Adam's super-useful Texter app doesn't work in Wine, for example. The big wins for Wine are Microsoft Office viewers (and, in some cases, full applications) up through 2003 versions, Adobe Photoshop CS2, and many games, including World of Warcraft. You can even get iTunes playing and purchasing music, but no iPod syncing (yet). Assuming you've got something you want to try out, let's get started.

Install and configure Wine

Most Linux distributions have Wine available in their repositories, but usually a bit out of date. You can grab an easy-install package or repository instructions at Wine's download site. (Mac users with Intel processors should check out Darwine, which keeps up with the official Wine releases. Here's a guide to setting it up). Wine usually installs itself, creates a .wine folder in your home directory, and uses that as a pretend "C:/" drive to place your applications and needed files in. If not, enter winecfg into a terminal and it'll do the work and bring up its configuration screen. desktop_integration.pngHead first to the "Desktop Integration" tab. If you want your Wine/Windows apps to treat the "Desktop" or "My Documents" save locations the same as your Linux desktop or documents folders, change the values to point at the right locations. Head next to "Drives," where a click on "Autodetect" should set up a group of virtual drives for your Wine apps (your home folder becomes "H:" for example, and folders inside your .wine folder become other drives). You can click on "Sound" to see if Wine is picking up your Linux driver well enough. That should be good enough for now—let's install our first app. All three of Microsoft's major Office creator tools—Word, Excel, and PowerPoint—have free "viewers" that let anyone without a full Office suite open and copy data from Office documents. All three of the 2003 versions happen to run great in Wine, making them pretty helpful to anyone who simply needs to occasionally see or copy from a document or spreadsheet with tricky formatting. Grab a copy of the Word, Excel, or PowerPoint viewers, then open a terminal and change directories (cd to wherever you put the .exe installer file). pptview_install.pngNow enter wine whatever.exe (or, in certain systems, right-click on the .exe file and choose to launch with Wine) and you'll get a familiar-looking prompt to install, followed by a license agreement, then a quick installation and goodbye. Head to Wine->Programs in your system menu, or browse to the viewer in your pretend "Program Files" folder (manually or by choosing "Browse C:\ Drive" from the Wine menu). powerpoint_in_wine.pngYou should see your viewer program, and it will likely launch with no problems. If you wanted to go further into full Office apps, you can either take your chances with straight-up Wine—where you might see "Platinum" and "Garbage" reports for the same Office version on the same Linux system—or invest in a Crossover product for about $40, which gives near-guaranteed sucess with Office apps. foobar.pngYou can change which version of Windows Wine attempts to recreate in the "Applications" tab in configuration. Browse and select an app, choose a Windows version in the lower-right, then add any DLLs you might need or graphics settings that need tweaking in the "Libraries" and "Graphics" tabs. Programs like AutoStitch, Foobar2000, and even Windows automation tool AutoHotKey install just fine with no tweaking, but your mileage may vary. If you do run into errors regarding missing DLLs/libraries, try installing the winetricks script, which automatically seeks out commonly missing .dlls for installed programs. The big caveat of Wine is that there are so many Windows programs out there, and myriad ways they can go wrong on installation or launch. A catch-all installation and troubleshooting method doesn't exist; you're best off looking in the AppDB, Googling your troublesome app with "wine linux" after it, or just tinkering with your Wine settings until you find out what's causing the bug.

Taking Wine further

Once you've gotten started using your apps in Wine, it's time to make them a better fit with your desktop. Here's a few tips and suggestions on making Wine an almost invisible layer in Linux:
  • Keep Linux file associations: There's probably no need to install a Windows-based PDF reader just because another Wine app wants access to one, so you need to teach Wine to reach for what you've already got available. Check out this wiki entry for details on choosing which apps open which files in your pseudo-Windows environment.
  • wine_fix_cropped.jpgDe-uglify the interface: Wine takes an OS-neutral, Java-like approach to drawing buttons, tabs, and other implements on its windows, but wouldn't it be nice if they actually meshed with your Linux desktop? The Tombuntu blog shows you how, from a simple text file copy to more extensive (and memory-eating) tweaks (Original post).
  • Uninstall programs: Got a bit too much clutter in your Wine menu after a few try-outs? Simply type uninstaller into a terminal, and you'll get a simple click-and-choose interface that activates the familiar Windows uninstaller ("Are you sure you'd like to ...").
If you're looking for more help on customizing and running Wine apps, I'd recommend, in addition to Wine's own wiki, these two sites:
  • Frank's Corner: A one-man Wine guru, Frank offers up specific hints and tricks on wrangling Office, multimedia, gaming, and other Windows apps. Slightly behind-the-times, but his advice still holds.
  • Ubuntu's Wine wiki page: For users of the orange-tinted distro, a few handy how-tos and guidance on what can and can't be done with Wine.
Veteran Wine users, what favorite apps have you rescued from other-partition exile? Newcomers, what other resources can you point out for getting more Windows apps running ever-so-smoothly in Linux? Share and share alike in the comments. Kevin Purdy, associate editor at Lifehacker, waits with bated breath for iTunes to get iPod support in Wine. His weekly feature, Open Sourcery, appears Fridays on Lifehacker.

Automatically rename KONSOLE tab during telnet or ssh.

Posted on June 6, 2008 by ZDima.
Categories: Development, UNIX, UNIX-Shell.

I am using KDE konsole as my primary terminal interface.

To keep tab organized I am using wrapper script for telnet and ssh where I am calling dcop to change the tab name with a with a host name:

  1. #!/bin/sh
  2.  
  3. telnet_log=/tmp/telnet.log.$$
  4.  
  5. restore_title()
  6. {
  7.     if [ "${OLD_TITLE}x" != "x" ]
  8.     then
  9.         dcop "$KONSOLE_DCOP_SESSION" renameSession "$OLD_TITLE"
  10.         OLD_TITLE=
  11.     fi
  12. }
  13.  
  14. change_title()
  15. {
  16.     if [ ! -z "$KONSOLE_DCOP_SESSION" ]
  17.     then
  18.         OLD_TITLE=`dcop "$KONSOLE_DCOP_SESSION" sessionName`
  19.         dcop "$KONSOLE_DCOP_SESSION" renameSession "$NEW_TITLE"
  20.     fi
  21. }
  22.  
  23. handle_quit_intr()
  24. {
  25.     restore_title
  26. }
  27.  
  28. trap handle_quit_intr SIGINT INT QUIT
  29.  
  30. for arg in $@
  31. do
  32.     NEW_TITLE="$arg"
  33. done
  34.  
  35. OLD_TITLE=
  36. export OLD_TITLE
  37. export NEW_TITLE
  38.  
  39. change_title
  40. /usr/bin/telnet $* 2> $telnet_log
  41. rc=$?
  42. restore_title
  43. echo "telnet exit with code $rc"
  44.  
  45. if [ $rc -eq 0 ]
  46. then
  47.     [ -f $telnet_log ] && rm -f $telnet_log
  48.     exit 0
  49. fi
  50. exit $rc