Linux

Linux Tip - Route Standard Output Into to the Clipboard

A friendly online stranger just taught me how to do something that has been plaguing me for some time. Ever since I learned how to use pipes in the unix commandline, I have wanted to know how to pipe the output of a command into the system clipboard.

For example, the echo command simply repeats whatever you tell it to. So if I run

echo hello

the computer will give me the output

hello

By using a pipe (this symbol: |) I can route the output of one command into the input of another.

For example, if I run

echo hello | helloprogram

the helloprogram will receive the value of 'hello' as an input, and will do something with it. This allows stringing together small commands into long ones, which sometimes is incredibly handy.

Anyway, if you want to route standard output into the system clipboard, you will need to install an application called xclip. Once that is installed, a command such as

echo hello | xclip -i -selection clipboard

will put the word hello into the clipboard. Ctrl + V will then paste that value into whatever application desired.

Thanks to aaron at http://www.cyberciti.biz/faq/linux-copying-with-middle-mouse-button/#comment-38676 for help with this question.

Ubuntu Disk Usage Analyzer

One of my favorite utilities lately is the Disk Usage Analyzer that comes installed on Ubuntu. It can be run either locally or remotely.

It's pretty awesome. I have been playing with my backups lately, and this utility allows me not only to see which directories are large, but also where my files are taking up the most space. For example, the picture at right depicts my home directory. By mousing over the slices of the pie, you can see what's in them, and how big they are. By clicking on a slice, it becomes the center of the pie, and you can see which directories are within it (and how big they are).

In terms of UI, I have to say this one works very well for me. I have yet to see another app for this purpose anywhere else, though admittedly I have not been looking that hard.

My Linux Story

I thought I would post a quick entry today about how I came to be a Linux user and enthusiast. I guess it's a combination of a couple things.

Historically, what happened was that I was using XP and looking at thumbnails of some pictures in their file navigator. I was looking at about 300 pictures, and I didn't want to open them all up individually (this was before useful apps like Picasa came around). I just wanted to look at the thumbnails. Except those were too small, so I wanted to make them bigger. I spent about two hours searching online to try to figure out how to make such an adjustment. Eventually, I discovered a Windows "Powertool" that you could install. It seemed like overkill, but it did the job. What bugged me though about it was that obviously it didn't require a Powertool to adjust image size. It just required a tweak of some bit of code somewhere in the system. That was my tipping point. I decided I couldn't take the viruses, the expense and the closed product anymore, and promptly decided it was time for a new OS.

So that's what brought me to Linux. What kept me here is the openness and the philosophy. Sure, at times it's a bit trickier to get certain things done, but I love the philosophy that if I want a change, I can either make it myself if I am a programmer, or I can file a feature request with the developers. Somebody will read that request, and maybe it will get integrated, if it's a good enough idea.

I also love the fact that I can download, install and run an excellent email server, and a top-notch web server. For free. Also, no viruses. Ever. Nor any anti-virus software to pay for. And did I mention the whole thing is free?

As for the day to day stuff, I really don't notice much difference. At work, I use XP, which involves using Firefox, Word, Excel and Outlook (the latter three of which my work paid good money for). At home it's Firefox, Open Office and Evolution, all of which are very similar to the Microsoft package, only with better compatibility with other programs.

The other thing I really like about my Linux system is the ability to set things up like in the previous tutorial. I did an Internet search for "Linux wake on USB", and knew exactly how to adjust the system in a matter of moments. That kind of customization is a power you just don't have in Windows.

Wake Your Computer by USB

I recently began using my laptop at my desk with a USB keyboard and mouse, and I thought I would explain how to set up Ubuntu so that USB peripherals will wake up your computer from sleep mode. This is convenient if you have your laptop set up such that the lid is closed and inaccessible.

In Ubuntu, the way to set this up is to edit the file located at /proc/acpi/wakeup. To see the current contents of this file do this:

% cat /proc/acpi/wakeup
Device S-state Status Sysfs node
P0P2 S4 disabled
P0P1 S4 disabled pci:0000:00:1e.0
MC97 S4 disabled
HDAC S4 disabled pci:0000:00:1b.0
P0P4 S4 disabled pci:0000:00:1c.0
P0P5 S4 disabled pci:0000:00:1c.1
P0P7 S4 disabled
P0P8 S4 disabled
P0P9 S4 disabled
USB0 S3 disabled pci:0000:00:1d.0
USB1 S3 disabled pci:0000:00:1d.1
USB2 S3 disabled pci:0000:00:1d.2
USB3 S3 disabled pci:0000:00:1d.3

EUSB S3 disabled pci:0000:00:1d.7
P0P6 S4 disabled pci:0000:00:1c.2
SLPB S4 *enabled

This shows you a number of devices, most of which I don't claim to understand. The ones to notice are the USB ones, which you will see are disabled by default.

Once these are toggled on, your computer will wake up from sleep when USB peripherals are used. To toggle one of these on, as root, run:

echo "USB0" > /proc/acpi/wakeup

This will toggle USB0 from disabled to enabled. To check this, run cat /proc/acpi/wakeup again. You should see that it's enabled, and you should be able to test this by suspending your computer.

This will set up your computer to wake up from USB...for now. To make it work after your computer has been restarted, you will need to write a short init script named wake.sh with the following contents:

#!/bin/bash
echo "USB0" > /proc/acpi/wakeup

Save this file to /etc/init.d, and make it executable by running:

chmod +x wake.sh

Finally, once this file is in /etc/init.d, and is executable, as root run:

update-rc.d wake.sh defaults

That will make init know about the file, and run it at startup. Happy awakenings!

source: http://ubuntuforums.org/showthread.php?t=711747

Install Citrix In Ubuntu Hardy Heron

For a while there, I was struggling to get the Citrix client installed on my computer. It was frustrating, and I put hours into debugging it, and trying to get it to work. In the end, I took a circuitous route, installing VirtualBox in Ubuntu, Windows in VirtualBox, Firefox in Windows, and finally Citrix in Firefox.

Last week, I took another stab at getting this done, and for some reason it went very smoothly. To install Citrix in Ubuntu Hardy Heron:

  • Begin by downloading the Citrix client as a .tar.gz.
  • Next, unpack the install file using the terminal by running:
    sudo tar xvfz en.linuxx86.tar.gz

  • Change into the Citrix directory, and run
    sudo ./setupwfc

    This will begin the install script. As it proceeds, simply allow the default settings, and you should be good.

  • The final step is to install the root certificates. To do this, attempt to start a Citrix program, and it may fail, reporting an error message. In the message, it will tell you what certificates it needs installed. Go to this website, and download the certificates the error message informed you that you need by right clicking their download links, and selecting "Save as..." Once those are downloaded, rename their extension so they are .crt files, and move them to
    /usr/lib/ICAClient/keystore/cacerts

  • Restart Firefox, and you should be good.

Thanks to Skarh for this how to.

Drag a Screenshot Using ImageMagick

I learned an interesting trick while working on the Fuji water article. We all know that if you want to take a screenshot in Linux, all you usually have to do is press the "printscreen" button. That, however, takes a screenshot of the entire screen, which you then have to trim down into a useful bit of picture.

The trick I learned to make this easy is to simply type:

import screenshot.png

That will turn your cursor into a little crosshair, which you can drag across a section of the screen.

If you want to do that after a delay, the trick is to use the sleep command like so:

sleep 10; import screenshot.png

I found this tip along with a lot of others on this blog. There are some other interesting techniques there as well.

Remap Caps Lock as Backspace in Windows and Linux

A while back my wrist started hurting from reaching for the cursed backspace key. I was making too many mistakes. My solution was to remap the caps lock key on all the computers I use to act as an additional backspace key. How did I do it? Well, I'm glad you asked. I'll tell you.

In Windows
EDIT: I noticed that the picture doesn't have all the detail you need. The easier way to do this, is to download the registry key attached to this post, and to right click it, selecting merge. After that, restart the computer, and you should be all set.

To remap the caps lock to function as a backspace key in Windows, one must edit the registry keys. To do that, go to Start > Run..., and type in regedit. In the editor that opens up, navigate to the key shown in the picture below, and create a new key named Scancode Map of the type REG_BINARY. Give it the value shown in the picture, restart, and you're set. If things get wacky, delete the key and try again.

In Linux
I have tested the following in Ubuntu 7.04, 7.10 and 8.04. Start by opening a terminal, and running the xev program. Once that is running, press the caps lock key, and it will tell you the numerical value of that key. For example, my output from that command looks like this:

mlissner@opal2% xev
KeyPress event, serial 28, synthetic NO, window 0x4800001,
    root 0x59, subw 0x0, time 2775892, (373,636), root:(376,685),
    state 0x0, keycode 66 (keysym 0xff08, Caps_Lock), same_screen YES,
    XKeysymToKeycode returns keycode: 22
    XLookupString gives 1 bytes: (08) "
    XmbLookupString gives 1 bytes: (08) "
    XFilterEvent returns: False

In there, you will see the keycode for the capslock key, in my case, number 66. Using that, create a file in your home directory called .Xmodmap, and put the following in it:

!
! Make the caps lock button a backspace button
!
remove Lock = Caps_Lock
keycode 66 = BackSpace

Once that is done, the next time you log in, your caps lock will function as a backspace. The only remaining problem is that it still does not have the auto-repeat function that backspace should have. To fix that, run:

xset r 66

That will make things work properly, but you need to run that every time you log in, or else it won't work properly. To fix that run:

sudo gedit /etc/X11/Xsession.d/50x11-common_determine-startup

And add xset r 66 to the bottom.

That should do it.

Source: http://ubuntuforums.org/showthread.php?t=369402

Install Garmin Topo! in Linux

I'm planning a quick trip out to Yosemite for next weekend, and I wanted to print out a couple of maps from Garmin Topo! beforehand. The last time I used Topo! was about four years ago, when I had Windows XP installed. I don't remember how I installed it then, but that probably means it wasn't too challenging.

This time, however, I don't have a computer running Windows except for as a virtual client within Ubuntu, so I figured that would be the best place to begin. I booted up Windows XP, popped in the CD, mounted it within the virtual client, and tried to install. No dice: some error message. I played with it for a while, and I eventually decided that for some reason, it just wasn't going to work.

My next idea was to try installing Topo! within Ubuntu via Wine (Wine Is Not an Emulator). Wine is an application that attempts (and often fails, sometimes works) to allow Windows applications a method of working within Linux. I closed down Windows, opened the install CD within Ubuntu, and double-clicked the Setup.exe file. Amazingly, the Windows Install Shield business popped up, and the installation proceeded with no problems whatsoever.

Once that was done, the only remaining step was to make myself a nice link/alias/launcher. Once it's installed, the Topo! executable is located at ~/.wine/drive_c/TOPO!/TOPO.EXE, so it's just a matter of making a link to that, and you're all done.

Personal Music Collections

I was curious which artists of mine had the most songs, so I ran:

du Music/ | sort -nr | head -11

Now we know that my top ten artists are:

08:05:48::mlissner@opal::~ (2 files, 115k total)
% du Music/ | sort -nr | head -11
17582796 Music/
490928 Music/Radiohead
378148 Music/Daft Punk
315856 Music/Red Hot Chili Peppers
313032 Music/Massive Attack
306228 Music/Kanye West
305796 Music/Outkast
289288 Music/Nirvana
276416 Music/Beck
258544 Music/Nine Inch Nails
248608 Music/Beatles, The

Volunteering At Last!

For the last couple of years I've kinda, sorta been hunting on and off for a place where I could volunteer some of my free time. I started at the nearby university, thinking that I might be able to convince some kind professor to teach me some things. When that failed, I tried searching google for nonprofits that looked interesting. Failing that, I went on a limb, and asked a professor of mine if he had any ideas (he did, but they fell through).

Finally, after all this time, one fell in my lap. Last week, I was looking for a place where I could donate my old computer hardware, and I discovered the Alameda County Computer Recycling Center. It looks pretty darned cool. I will spend my time putting together old computers into useful devices, and then installing Ubuntu or Suse. In exchange, they will give computers (for free) to needy parties.

It's not helping the homeless, but it should be educational for me and, ultimately for them. Plus, it will help to keep e-waste out of landfills.