jump to navigation

Using “tee” to write to files and the terminal May 17, 2007

Posted by Carthik in administration, commands, snippets, ubuntu.

The utility “tee” is very useful for plumbing on the command line. Curiously enough, it gets its name from the T-splitter used in plumbing, shown below:
T-splitter used in Plumbing

Say you want to run a command, and be able to see the output and errors on the screen, and be able to save them to a file. That’s where tee comes in, so you could do a:
$sudo apt-get upgrade 2>&1 | tee ~/apt-get.log
…to run apt-get upgrade and save the output and errors to the file apt-get.log in your home directory.

Purists please excuse the following explanation 🙂 The “2” refers to the “tap” from which the errors pour out (called stderr). The “1” refers to the tap from which the output pours out. The 2>&1 makes the errors to also pour out of the output tap. So then stderr goes to stdout. The pipe “|” redirects the output to tee. Now tee splits the output of the previous command two ways, and puts it both in ~/apt-get.log and in the standard output, which happens to be your screen/terminal.

tee is also handy when you have a small permissions problem. Say you want to write some text to a file “filename.txt” owned by the “root” user – you would just use something like:
$sudo vim filename.txt
and then change the file, right?

Now suppose you want to echo what you write, and write the file, all in one command, you then can use tee thusly:
$echo "localhost" | sudo tee filename.txt > /dev/null

This would write the text “localhost” to the file filename.txt which is not owned by you. The output of tee itself will go to /dev/null (nothingness) instead of the standard output, which is your terminal.

Don’t lose sleep over this, but someday it will come handy, and when you can figure out why the “sudo” does not apply after the “>” in your command, remember tee and come back here.

For all your command line redirecting needs, and to learn to wield pipes and tees like nunchakus read this excellent page.

Installing Ubuntu in a Library May 11, 2007

Posted by Carthik in Friends Etc., ubuntu.

I installed no software, except for the Operating System, and look – it works!

Jessamyn is a librarian with 3 donated PCs and no legitimate OS. She installs Ubuntu and shows us why she loves it.

I woke and saw this. Today will be a good great day!

I hope she posts a follow-up of how people in her library use it.

Dell to Offer Ubuntu to Consumers May 1, 2007

Posted by Carthik in commentary, interviews, news, ubuntu.

So Dell did not get caught in the storm of it’s making – it swept the storm off its feet! This is the day the scales started tipping.

Dell will start offering consumers PCs with Ubuntu 7.04 (aka Feisty Fawn) on its PCs for interested customers. The Dell Ideas in Action Blog announced as much earlier today, stating very clearly that Ubuntu was their distribution of choice, and that they have worked out the specifics of the deal with Canonical, the entity that support Ubuntu’s development. Read Canonical’s brief announcement here. According to Canonical’s Jane Silber, the timing couldn’t be better:

“The market is ready,” Silber said. “We think the combination of the timing, the technology and the partner are aligned to make it happen.”

There is a video interview with Mark Shuttleworth over at the Direct2Dell blog in which he talks about how the deal came about, and how this will make wide Linux adoption a much easier goal to achieve. He’s right when he says that this will increase Linux’s visibility across the board, and draw out closet Linux technologists who will now see some commercial benefit to advertising the Linux expertise they had, but never really talked about before.

I think this is a big step forward – hell, I look forward to answering, “what’s that Ubuntu-thing on your laptop?” with “Haven’t you heard, it comes pre-installed on some Dell PCs?”

Kudos to Dell for following up on their promise to listen to customers. My voted counted, for once. Depending on how many Ubuntu laptops get sold, Dell might just be the trailblazer in making and selling computers – once again. The interesting thing is, I wonder if Dell sees the future, can the others be far behind. Also, going by the example Mark states in the interview about how Linux adoption on servers led to hardware manufacturers ensuring that their stuff was up to snuff on servers, this can only mean better support for Ubuntu from the hardware component and peripheral manufacturers.

Congratulations Ubuntu – stand up and be recognized now!

Free Ubuntu Magazine: Full Circle April 28, 2007

Posted by Carthik in books, ubuntu, Ubuntu Sites.

The zeroth issue of the Ubuntu Full Circle Magazine has been out for a while now. You can download it in your chosen language here. If it is not available in your chosen language, then maybe you can help translate it the next time for others like you.

full circle logo
The magazine is a community effort – I think it was kickstarted on this Ubuntu forum post by the forum user ronniet. “Development” of issues revolves around the wiki. The Ubuntu Magazine page lists what you can do to contribute articles and columns.

Maybe I should contribute an article or a regular column in the magazine – after all it is a volunteer effort and the magazine is provided free-of-cost.

The Ubuntu Community Interviews Mark Shuttleworth April 25, 2007

Posted by Carthik in interviews, ubuntu.

As part of the Ubuntu Open Week, everyone interested had a chance to ask Mark Shuttleworth, the SABDFL, their questions.

Thanks to the volunteer efforts of the wiki gardeners, you can read the entire interview online. I was intending to post the entire interview here, after formatting it, but since the interview at the wiki is formatted, and ready, I will just share the salient points.

  1. Regarding requesting ISVs to port their applications to Linux, Mark says that unless Linux users decide to pay for software like AutoCAD and Photoshop on Linux, the ISVs won’t migrate their apps so easily – since there are two things that drive ISVs to explore new oppurtunities – the raw size of the users in a market, and their willingness to pay for software – Mark says Linux is doing well on the number-of-users front, but the second factor is critical. I think one of the ISVs have to take the plunge, and try selling software to Linux users, and serve as a case study for the others to follow.
  2. Regarding the $3 MS OS initiative, Mark says this guy gets it. Basically, there are lots of reasons why, despite the MS OS being only $3, Linux makes a better choice. Interesting.
  3. The inevitable question of why Launchpad is not open-sourced yet was raised. This time, I think I understand the reasons behind it being closed, thanks to Mark’s answer. Basically, launchpad might remain closed till launchpad.net is established as the pivot of bug-tracking and as a general software development support system. Releasing the source now might mean that there will be many “launchpads” like the many bugzillas, thus compounding the problem launchpad is trying to address – that of not having a central issue tracking system that tracks the same unique issue across multiple bug trackers.
  4. Canonical will not go public anytime in the near future, and will also not accept funding from venture capital firms. Mark’s reasoning is that accepting any sort of external financial support will shift Canonical’s focus to a short-term profit/finance driven strategy. Canonical wants to take the long-term view and focus on building a better Linux desktop, among other things.
  5. Here’s the most inspiring part of the interview – Mark says the goals with Ubuntu are to be the best desktop linux distribution and to create a self-sustaining platform for Ubuntu, one that does not rely on license fees. He admits it has never been done before, but believes it can be done.

There is a lot more where these points came from. Read it. The interview seems to suggest there will be another Q&A session with Mark on Firday, April 27th, but the the Open Week Schedule does not have such a session listed. So I am not too sure if there will be another of these sessions. If there is one, I hope I can find it possible to be there for it, live.

Gutsy Gibbon Archives Open April 22, 2007

Posted by Carthik in releases, ubuntu.

Sure as clockwork, work on the next version of Ubuntu has started.

I was wondering what the collective noun used for the testing releases would be. We’ve had an “Array” of Hedgehogs, a “Herd” of Fawns, a “Knot” of Efts, a “Sounder” of Warthogs, a “Colony” of Badgers, a “Flight” of Drakes. I was hoping they would choose a “Machination” of Gibbons (“a machination of monkeys” exists), but no, we have the simpler, more functional “tribe”. So the testing releases will be called Tribe 1, Tribe 2 etc…

^txt2regex$: Regular Expression Tool To Create Regex from Description April 21, 2007

Posted by Carthik in applications, commands, packages, ubuntu.

^txt2regex$ is a lifesaver. It helps you create regular expression strings in a step by step process, by describing what your regex pattern should do in English (or your own language). The tool can create RegExes for use with 23 different programs, including sed, vim, mysql, and procmail. When you start the program, it will ask you a series of questions like “1. do you want to start matching at the beginning of lines? or 2. search anywhere?” and “this is followed by…. 1. A specific character…” etc… download it and run it and you will see.

Anyone who has worked with regular expressions for searching and optionally replacing stuff in files knows what a godsend then can be if you get the regex down pat – but they would also know what a time sink they can be if you can’t whip up exactly what you want. In the past, when faced with this kind of a situation, I would read man pages, books, experiment, fail and then, finally, succeed after a good half hour or so. txt2regex is a tool that eliminates the confusion. Totally.

You can install txt2regex on Ubuntu by doing a:
$sudo apt-get install txt2regex

Among its features include the ability to print a list of characteristics of the regular expression syntax for various tools, a history tool which keeps track of you past regexes, and some pre-built regexes that are often used – for dates, times and numbers.

For example,
$txt2regex --all --make number3
will create the regex for all supported tools. The regex will match a number of the form “34,412,069.90”

Here’s the output:

carthik@milan:~$ txt2regex --all --make number3

### number LEVEL 3: level 2 plus optional commas, like: 34,412,069.90

 RegEx awk       : [+-]?[0-9]!!(,[0-9]!!)*(\.[0-9]!!)?
 RegEx ed        : [+-]\?[0-9]\{1,3\}\(,[0-9]\{3\}\)*\(\.[0-9]\{2\}\)\?
 RegEx egrep     : [+-]?[0-9]{1,3}(,[0-9]{3})*(\.[0-9]{2})?
 RegEx emacs     : [+-]?[0-9]!!\(,[0-9]!!\)*\(\.[0-9]!!\)?
 RegEx expect    : [+-]?[0-9]!!(,[0-9]!!)*(\.[0-9]!!)?
 RegEx find      : [+-]?[0-9]!!\(,[0-9]!!\)*\(\.[0-9]!!\)?
 RegEx gawk      : [+-]?[0-9]{1,3}(,[0-9]{3})*(\.[0-9]{2})?
 RegEx grep      : [+-]\?[0-9]\{1,3\}\(,[0-9]\{3\}\)*\(\.[0-9]\{2\}\)\?
 RegEx javascript: [+-]?[0-9]{1,3}(,[0-9]{3})*(\.[0-9]{2})?
 RegEx lex       : [+-]?[0-9]{1,3}(,[0-9]{3})*(\.[0-9]{2})?
 RegEx lisp      : [+-]?[0-9]!!\\(,[0-9]!!\\)*\\(\\.[0-9]!!\\)?
 RegEx mawk      : [+-]?[0-9]!!(,[0-9]!!)*(\.[0-9]!!)?
 RegEx mysql     : [+-]?[0-9]{1,3}(,[0-9]{3})*(\\.[0-9]{2})?
 RegEx ooo       : [+-]?[0-9]{1,3}(,[0-9]{3})*(\.[0-9]{2})?
 RegEx perl      : [+-]?[0-9]{1,3}(,[0-9]{3})*(\.[0-9]{2})?
 RegEx php       : [+-]?[0-9]{1,3}(,[0-9]{3})*(\.[0-9]{2})?
 RegEx postgres  : [+-]?[0-9]{1,3}(,[0-9]{3})*(\\.[0-9]{2})?
 RegEx procmail  : [+-]?[0-9]!!(,[0-9]!!)*(\.[0-9]!!)?
 RegEx python    : [+-]?[0-9]{1,3}(,[0-9]{3})*(\.[0-9]{2})?
 RegEx sed       : [+-]\?[0-9]\{1,3\}\(,[0-9]\{3\}\)*\(\.[0-9]\{2\}\)\?
 RegEx tcl       : [+-]?[0-9]!!(,[0-9]!!)*(\.[0-9]!!)?
 RegEx vbscript  : [+-]?[0-9]{1,3}(,[0-9]{3})*(\.[0-9]{2})?
 RegEx vi        : [+-]\{0,1\}[0-9]\{1,3\}\(,[0-9]\{3\}\)*\(\.[0-9]\{2\}\)\{0,1\}
 RegEx vim       : [+-]\=[0-9]\{1,3}\(,[0-9]\{3}\)*\(\.[0-9]\{2}\)\=

$txt2regex --help
prints out a short help message


man txt2regex
gives some more info.

What would be handy is if txt2regex had an extension that allowed one to deconstruct a regex – give it a regex and it tells you what it does in plain English. Also, I cannot seem to create regexes for the mod_rewrite module in apache. I suspect that since mod_rewrite supports POSIX regexes, I could just run with one or the other of the regexes created by txt2regex. Since I haven’t tried it, I can’t say which one of the 23, just yet.

Ubuntu Open Week: Get Your Questions Answered April 20, 2007

Posted by Carthik in news, ubuntu.

…by, among others, Mark Shuttleworth.

The Ubuntu Open Week is a week of sessions on the IRC chat channel #ubuntu-classroom where you can learn more about Ubuntu. You have sessions about getting involved with translating, patching, packaging, bug fixing, getting involved with communities, the desktop team and much, much more. The open week runs from Monday 23rd April through Saturday, 28th April.

Melissa has an additional request — that you help spread the word! 🙂

Behind MOTU: Meet the Masters of the Universe April 20, 2007

Posted by Carthik in interviews, ubuntu, Ubuntu Sites.

You might already know about Behind Ubuntu, a website that features profiles of the people behind Ubuntu – the ones who contribute their time and effort to making Ubuntu what it is.

Behind MOTU is a similar effort to bring to the fore members of the MOTU. The MOTU are an elite squad of mostly volunteer developers who keep the 10,000+ packages in the Universe component of the Ubuntu repository in shape. Yes, that is a whole lot of packages to keep track of, and without the MOTU, the task would be impossible. The MOTU team on launchpad currently has 65 members. #ubuntu-motu is their online hangout.

I wish Behind MOTU posts had pictures of the Masters. It helps me greatly to put a human face to the awesome people I am thankful to. Also, it would be nice if they had a “Page” with links to the profiles of each MOTU. So far, Michael Bienia, Scott Kitterman, and Barry deFreese have been profiled. I look forward to more interviews in the future.

Download or Upgrade to Feisty Fawn (7.04) April 19, 2007

Posted by Carthik in news, ubuntu.

Feisty Fawn is here! Here’s the Press Release.

The Release Notes contain things you should watch out for when installing or upgrading, including the most common installer bugs and other issues. Read it before you install or upgrade.

The 7.04 tour guides you through what’s new. Phil Bull’s 41-item list of what’s new in Feisty is an awesome collection of the new bling.

You can download Feisty by bittorrent, or you can download the cd images. Using bittorrent would be right thing to do.


If you are upgrading from Edgy, read the upgrade notes. Please note that the graphical method using the Update Manager is recommended over the command line method using APT. For 22x faster upgrades, read my earlier post 🙂

Thank you, Ubuntu developers, MOTUs, Documenters, Bug Fixers, Forum members, IRC chatters, and Ubuntu users. Let us not take predictable, regular, ultra-cool releases for granted. My heart is so big right now, it might just explode. Thank you for this release, and for the release from the mundane, the bloated, the untrustworthy, and the unstable!