GNU/Linux


Yesterday morning I had a bit of a strange question (so I thought), although it turned out to be a good one. “Is there any way to pipe or redirect output from the console to the clipboard?” I asked my good pal jdong if there was indeed a way to do this. He quickly turned me onto this Debian page where I discovered a neat little application called xclip.

You can read the nuts and bolts of its usage on the Debian page, but it’s quite easy. I’ll use an example based on what I originally wanted it for (being able to paste file listings of various directories into a pastebin or document):

ls -al /media/storage2/Comedy/* | xclip

You can retrieve what went into the “clipboard” by running xclip -o, which will paste back into the terminal whatever you copied using the example above.

Unfortunately what it did not do was save the output to the regular “X” clipboard (where items normally go when you highlight and do a Ctrl+v or Ctrl+x in the GUI or Ctrl+Shift+c/x in the console), which is what I was expecting, but this is easily remedied. In order to do that, we must run the following:

ls -al /media/storage2/Comedy/* | xclip -selection c.
(To paste from the X clipboard it’s simply a matter of running xclip -selection o, but you can also just use Ctrl+Shift+v)

xclip supports a lot of extended features such as split clipboards (which I’m still not quite sure what those are), but I mainly wanted to use it for grabbing file listings. So all I did was make an alias by running:

alias xclip='xclip -selection c'

Now when I pipe output to xclip I can quickly switch to my web browser or document, hit Ctrl+v and my console output appears in a pastebin or whatever else i’m working on. It’s quite handy for both writing technical documents and for troubleshooting. Pastebin is the darling of IRC idlers, and this just made it easier.

I didn’t bother with aliasing “xclip -selection o” simply because I can just use Ctrl+Shift+v and paste back into the console from the X clipboard as mentioned above.

Hopefully that wasn’t too confusing. Use it a few times and it becomes a lot more intuitive. I certainly like it, especially for large outputs that would exceed the scrollback buffer (I use the Awn Terminal Applet constantly, which has a small buffer).

While Ubuntu does a very good job providing graphical alternatives to traditional console applications and utilities, I remain a staunch proponent of the console, as those who know me can attest. I could even go as far as saying that I’m a “zealous proponent” of the console, but I do use plenty of graphical applications, whether for aesthetics or for ease of use or for functionality. I don’t particularly favor one or the other.

However, in many cases, the console is much, much faster if you know what you’re doing. A friend of mine said to me just tonight, “you have a tendency to insist CLI is better just because you’ve spent the time learning how to use it.” He’s exactly right. I’ve spent countless hours reading man pages, howtos, tutorials and change logs because I realized early on in my UNIX-like OS “career,” that the console could open up some very powerful opportunities for me if I only took the time to learn how to use it effectively.

Older hardware can also benefit immensely from a console-heavy environment, although it need not be entirely text-based. But when you have a 300MHz Pentium II with 128MB RAM you probably don’t want to run a full GNOME desktop, Azureus and Amarok. But with command line utilities and a bit of know-how you can still use that machine very effectively (I even had good success selling PII 300MHz with 128MB RAM and Windows XP as “web/email laptops” in 2004, so imagine what you can do with a bit of Linux console magic!) .

Some of my favorite console applications, both old and new, include irssi, the IRC client I absolutely cannot live without, rtorrent, mplayer, screen (which is incredibly powerful and useful when combined with other CLI apps), finch and, of course, ssh. We’ll explore these and others in a series of article I intended to write and I’ll do my best to provide links to the wealth of other sites that provide much better articles than I ever could. I hope to learn a lot more myself during the process, so you won’t  be going it alone!

I am not a console expert. I’ve only been using Ubuntu for just over 16 months, although I did mess around with several versions of Red Hat in the late 1990s, when Linux did not support internal modems much at all, and I didn’t own an external serial modem. Somewhat ironically, I became reintroduced to the console courtesy of Mac OS X which I began using in 2005 and by the time I began using Linux again in earnest I was hooked. Now I know enough to get around in the console of most Linux distribution, BSD and Solaris. But I have much, much more to learn.

So stay tuned for several updates per week in which I investigate new console applications and utilities. You’ll be a “console snob” in no time! 😛

I haven’t written anything on any blog in far too long.  But a lot of things are happening in our world today, especially at the point where technology unfortunately meets with politics and in the FOSS community. It’s time I started writing again.

I’ve been using Ubuntu GNU/Linux as my primary OS for just over a year now and I don’t miss Windows a bit. It still blows my mind that 18 months ago I was a fairly  die-hard Mac user and thought I had really hit the big time because I wasn’t using Windows and occasionally typed some commands into OS X’s terminal. My G4 iBook traveled to Europe and on to Russia with me and served me well there, although it was difficult and (comparatively) expensive to obtain Mac software in Moscow from the huge number of “resellers” in the Gorbushka electronics market (that place must be seen to be believed). My iBook’s Main Logic Board died 10 days before I left Moscow in late June 2006. How amazing it is now where I rarely give a second thought to serial numbers and software licensing issues.

Last October I got a wild hair to try Linux again. I first used Linux in 1998 on a series of old Pentiums and later on my personal AMD K6-2 machine. Unfortunately, hardware support was pretty abysmal for internal ISA modems and I gave up after a lot of frustration (I had a brief but wonderful time with BeOS and remain saddened by the demise of Be, Inc). I’m happy I decided to give Linux another try.

I’ve learned so much in the last year that it’s actually opened up a new career path for me. I’m on track to take the CompTIA Linux+ exam in a few days (and intend to pursue LPI certification) and I’m currently trying to set myself up to find work installing, maintaining and administering servers, preferably in a *nix environment. I wouldn’t have thought I’d come back to IT a year ago.

We have a great community surrounding Ubuntu and I’m glad I’m part of it.  Free software is probably more important than ever, and I’m proud to be a member of the Free Software Foundation. But the struggle is far from over and new challenges are presented daily; unfortunately, most of these challenges seem to be in the courts and houses of government.

Tom Baker, a self-described “hardcore Windows fan” and, presumably, the Fourth Doctor in the BBC’s long-running (since 1963) science fiction series “Doctor Who“, began using a LiveCD of Ubuntu GNU/Linux 7.04 “Feisty Fawn” and, of course, he liked it. The author’s ignorance of UNIX-like operating systems does show through in places but I don’t mean that as a disparaging remark at all — he made the effort. The author begins by telling us how great Windows is:

Say what you want about Microsoft, it powers the world. I can use any hardware, play any game and use nearly any software ever written. I can do it securely, and with little frustration.

I certainly disagree with this because even Vista, with its many security improvements (I’m not being facetious), retains gaping holes through which intruders can exploit your system and the prying eyes of our friends at Langley and Fort Meade can take a peek. Every piece of hardware is far from running flawlessly on Vista. Significant amounts of hardware, including printers, simply do not work with Vista. Other times, the drivers merely negatively impact the performance (in the case of video cards).

Nearly any software ever written? Not by far, lad. A quick visit to SourceForge showed that there are 152,864 projects registered, most of which are not written to run on Windows platforms. And not all of our software, whether free or “open source,” is registered as a SourceForge project. And while using Vista may not be frustrating for him, it is for me. Bugs, crashes, quirks (such as XP shares not showing up in Vista, but Vista shares working properly in XP) and all manner of “Redmondism” plague Vista, not least of which is a barely functional command line shell. Sorry, Bill, not all of us need a cute little picture and a cursor to get the job done.

Patently untrue or not, his opening comments do set the stage for his final report. He had some trouble getting onto his wireless network (secured with WEP) and had some issues with codecs and getting the proper screen resolution. I couldn’t help but thinking “why not just do a dpkg-reconfigure -pmedium xserver-xorg?” The experience of a free, UNIX-like OS certainly does rub off on you once you get comfortable running in terminal, which is where I tend to spend most of my time these days (whether downloading with hellanzb or rtorrent or ussing irssi for IRC chat).

After he decides to install the OS, he has the following to say:

I’m writing this on my newly installed version of Ubuntu. I can honestly say it was a piece of cake getting it up and running. I had to do a few things first, like create some partition space on my hard drive to install Ubuntu on. Lucky for me, Windows Vista has a handy new “Shrink” command to shrink the size of your partition. Thanks to that, I was able to free up about 9 Gigs to devote to Ubuntu.

I can’t help but get a kick out of him extolling the virtues of Vista’s “handy new ‘Shrink’ command.” Many of us have been using gparted, whether from a GNU/Linux install or from a LiveCD, for a long, long time (or qtparted for you KDE types). He concludes by saying that he thinks it is unlikely that Ubuntu will ever replace Vista for him, but admits that he “just likes Vista, warts and all.” To each his own, as they say.

Bottom line, I was pretty heartened to see a self-described Windows zealot describe his initial (positive) reaction to Ubuntu 7.04 which, he says, “lives up to the hype.” Even though I maintain my position that UNIX-like operating systems, free though they may be, are not suitable for many end-users, I think power users and “admin-types” such as this fellow have a definite place in our community. It’s important to remember, however, that the important part of our community is not the fact that we use GNU/Linux – it’s the fact the we use free software.

You can find the full text on his blog.