Posts Tagged ‘Linux’

Extract Windows resources with icotool

Sunday, November 11th, 2007

I was playing around with Wine the other day. It’s pretty cool that I can run Dreamweaver and Fireworks on Ubuntu with very few issues now.

One of the problems I did encounter was that the setup program for Dreamweaver wouldn’t run under wine, and the program files had to be copied across to my Linux system from an existing Windows installation.

Once done, it ran with no problems - but I now had to create the icon in the Applications menu.

Creating the menu entry was straightforward enough - I just copied the Fireworks link and edited it to work with Dreamweaver. The problem was that I really wanted the icon to sit nicely.

After scouring a few forums, it turned out that Ubuntu already had a set of programs available in the repositories called icoutils.

After working out what binaries were installed:
dpkg -L icoutils

I played around with some of the tools. I can’t remember exactly what I did, so I’ll just say play with the tools. You can extract ICOs easily from DLLs and executables, and save them as ICO files or other formats.

Once done, I had a pretty Dreamweaver icon that looked better than the Fireworks one that Wine extracted!

What’s even funnier is that to get a tool in Windows to do this kind of thing inevitably lead to using shareware.

Secure Remote Access with Ubuntu

Thursday, November 8th, 2007

I needed to set up some remote access today, and although it was straightforward, it was difficult finding the information I needed.

Set up the server (that’s your computer)

  1. Click System > Preferences > Remote Desktop
  2. Tick the boxes as shown, and set up a password. If you don’t want to force a popup window when a connection is made, don’t tick the Ask for your confirmation box
    Remote Desktop Preferences
  3. Click close
  4. Install the ssh server:
    sudo apt-get install ssh
    This will allow access to your computer to be encrypted and secure (vnc is relatively insecure otherwise)

If you’re going to connect over the internet, you need to set up port 22 to forward to your computer. It’s a little convoluted, so I wont go into that here. If you’re just doing it on a home network, then it is not a problem.

Right, now you’re ready to connect. On another Linux PC (guest):

  1. In the terminal, run
    ssh -L 5900:localhost:5900 user@yourpc
  2. Now run (not in the terminal) vncviewer localhost:0

user@youpc is a valid computer user and hostname or IP address (ie. john@homepc.com).

What this does is create an ssh tunnel from one computer to another, and tells the guest computer to use this connection when using VNC (which is why we use localhost, rather than the computer’s IP address or name).

It works a charm, and is much more secure than opening the ports to the outside world.

FreeWins - Live Windows Rotation in Compiz!

Saturday, October 27th, 2007

Well, it’s very exciting that a new plugin has been developed that allows live manipulation of desktop windows. Over on SmSpillaz’s blog, he’s got some links to YouTube as well as a nice screenshot of the desktop.

The plugin is only in alpha and requires compilation on the system that you are using… But the promise is incredible.

If a plugin like this can work, and more importantly, work well, then I think we can expect to see some excellent plugins to take advantage of this.

Some ideas could be:

  • A plugin that shifts windows to the side of the screen rather than minimizing, like a book
  • A feature that allows you to scale windows larger or smaller without actually resizing it.

Of course, that’s just my limited imagination there.

Searching for the contents of many files in Linux

Tuesday, October 16th, 2007

One thing that I find remarkable in Linux is the vast array of clever tools that allow you to do ‘clever stuff’.

The problem exists where these obscure tools are difficult to work out how to use effectively, and moreover, use right.

One task I aim to do occasionally is search a disk for files containing particular text. This is always difficult. Even in Windows XP - the search indexing service actually prevents Windows from searching for specific text within a file. I’ve searched for files that I know have certain strings in them, only for Windows to tell me that it cannot find them.

As my love of Linux and Ubuntu grows, I found myself needing to perform this task again. Recently, I’ve scraped by using the rather useful find tool:

find . -type f -name foobar

What this little snippet does is seach the current directory and all subdirectories for any files containing the word foobar in the name. So it could return names such as ./foobar.doc, ./test/foobar.doc, or ./this is a foobar file name.txt. Pretty useful.

Tonight I needed to search for a specific phrase in a Word document on a disk. This is where the Linux command line really becomes powerful:

find . -type f -name *.doc -print0 | xargs -0 grep -i 'foo bar'

This will join the power of two commands: grep and find to create a groovy search.

First of all, the find command is searching for all files (-type f) that end in .doc (-name *.doc) in all folders starting from the folder I am in.

Once find finds a match, we use the pipe (the |) to pass that file name over to grep, which will search the file for the string foo bar.

We have to use the -print0 and -0 options to make sure that find and grep share the file names correctly between them in case we find any unusual ones (files with spaces would be counted as unusual).

Finally, the -i tells grep that the search is case-insensitive. This means that any .doc file with foo bar, Foo Bar, fOO bAR or any other case variation will be caught. Without it, only the exact string will be matched.

Now go forth and search!

Using dd and dd_rescue

Tuesday, September 11th, 2007

Following up on a post about recovering bad disks and reiser file systems, here is a list of ddrescue commands to help make life that little bit easier:

Backup MBR (boot code + partition table):
dd if=/dev/hda of=mbr count=1 bs=512
Restore boot code + partition table:
dd if=mbr of=/dev/hda
Restore, not including partition table:
dd of=/dev/hda if=mbr bs=448 count=1

Saving partition sizes to text file:
fdisk -l /dev/hda >partition-info.txt

Backing up to gzipped file:
dd if=/dev/hda | gzip >hda.gz
Restoring:
gunzip -c hda.gz | dd of=/dev/hda

Backing up to archive split into 1GB chunks:
dd if=/dev/hda | split -b 1024m -d - hda.
Restoring:
cat hda.* | dd of=/dev/hda

Backing up over ssh tunnel to remote machine (blowfish = faster):
dd if=/dev/hda | ssh -c blowfish user@machine "dd of=hda"

copying files over ssh tunnel:
tar cv /source | ssh -c blowfish user@machine "cd /destination ; tar x"

Thanks to colinm over at Digg for putting these so succinctly

Selecting a sound device in Ubuntu

Sunday, July 29th, 2007

I’ve found that using the ALSA sound system in Ubuntu is pretty slick, but becomes a pain when the sound tool in Ubuntu doesn’t correctly switch devices using the graphical user interface.

In a nutshell, here are a few useful commands to list and select the sound devices that are on your computer:

asoundconf list - list available sound cards
asoundconf set-default-card # - set the default sound card. Replace # with the device name from the previous command
alsamixer # - adjust volume settings for your specific sound card. Once again, replace # with the device.

Running through these 3 commands will probably save any user a great deal of grief in the long run.