Mindlessly easy ways try out Linux or Solaris

If you’ve ever been curious about trying a non-Windows OS, but mostly were afraid of messing with your computer, fear not! It is mindlessly easy to give it a try and find out what a productive, fun environment it could be when you can do anything you want.

Why you want to try it

You might be tempted to think that using Linux is completely different from Windows. In some ways, this is obviously true. But the beginner will really be surprised about how easy it is to use, even my wife thinks it’s nice and easy. It can be frickin’ beautiful too, as Lifehacker shows us.

Linux and Solaris have long been known to be more reliable, more secure, faster, and free. Until now they have been difficult for the average user to install and configure, but that time has ended. They provide an environment that can make you much more productive because you can configure things however you want, and the communities are huge and insanely helpful. If you want more reasons, check them out here.

Horribly Easy: Live CD

A “Live CD” is a CD that you can pop in your computer and run a different environment without changing anything on your computer. Here is all you need to do:

  1. (may not be necessary) Download Ubuntu, or to get really cool tools like DTrace and ZFS then OpenSolaris - Don’t worry, you’re getting the right one!
  2. Request, Borrow or burn the CD - You can burn the .iso file straight to a CD (OK, you got me… that might cost you 10 cents). If you don’t have a CD burner, you can request a free one at the sites above.
  3. Boot up your computer with the CD inside.
  4. Play around!

Extremely Easy: Wubi

From the website:

Wubi is an officially supported Ubuntu installer for Windows [...] Wubi allows you to install and uninstall Ubuntu as any other Windows application

You read that right, you just download it and install it in Windows like so:

  1. Download and run Wubi
  2. Tell Wubi your root password and how much space it can have.
  3. Grab some lunch
  4. Come back to see you have an extra boot option, Ubuntu 8.04!

If you don’t like it, just uninstall Wubi like a normal Windows program. This was my gateway drug by the way, so be careful ;)

Also Easy: Virtualization

If you have at least 1.5 Gigs of RAM, you can run another OS on top of your main one. This is much easier than it sounds, all you need to do is:

  1. Install virtualization software (my favorite right now is VirtualBox, but VMware is also available)
  2. Download the Ubuntu or OpenSolaris CD image.
  3. Startup your virtualization software and setup a new virtual machine profile
  4. Go through the steps under "Live CD" to install your chosen OS!

That’s all! If you want a picture for every step along the way for this, there is a good tutorial on Installing Ubuntu inside Windows XP using VirtualBox.

Whenever I wanted to configure my OS and had trouble, I found some great help at the Ubuntu Forums. If you went with OpenSolaris, you’ll definitely want to bookmark the OpenSolaris Forums. The forum users really had an answer to everything I needed.

Upcoming Technologies

It looks like there is a new kid in town promising a bunch of different OSes to try out in your browser: WorkSpot. Not sure what the time table for this is though, folks. Stay tuned.

It’d be great if you guys that are savvy about this would share tips about trying out not-Windows. What was your gateway?

If you try this out, share your thoughts and ask questions if you like.

If you liked this post, please help me share it
  • Reddit
  • StumbleUpon
  • description
  • del.icio.us
  • Digg
  • co.mments
  • Google
  • Slashdot
  • Technorati
  • TwitThis
  • E-mail this story to a friend!
  • Furl

Get sed savvy - part 2

Now that you know a bit about the Stream EDitor from the last sed tutorial, we are going to expand our knowledge of substitution and line printing with an interesting scenario.

Suppose we want to let someone else know what kinds of functions are in a given Javascript file. Think of it as a simple sort of Javadoc for CSS or Javascript. The way we are going to do this is look at all of the files modified in the last day and then extract the comments out of them and put them somewhere (on a wiki perhaps?). Doing this kind of automation will increase team communication and productivity immensely if done correctly.

Tutorial

Download and install Cygwin if you’re on Windows to follow along.

# Single-line comments - grep is better but we can use sed
sed -n '/\/\/p' blah.js > /tmp/comments.out

# Multi-line comments
sed -n '/\/\*/,/\*\//p' blah.js >> /tmp/comments.out

Now, the sed commands above are tricky so here is how you can understand them: The -n option tells sed not to print anything unless you tell it specifically what to print. The comma [,] in between the two patterns tells sed to match everything between the two patterns, in this case everything between multi-line comments /* and */ and then the p-command prints whole lines that match the pattern space.

We can combine these two commands to streamline a killer process.

# sed script file
/\/\//p
/\/\*/,/\*\//p

# Use the sed script to print all comments
sed -n -f sedscr blah.js > /tmp/comments.out

Now we have a nice little summary of our Javascript files we can post to a wiki or diff with another version to see what was added. Note that the sed print command prints the whole line, so if you have comments at the end of a line you will get the beginning of that line also. Not a perfect solution, but something quick and easy!

Other Examples

# Print lines longer than 80 characters
sed -n '/^.\{81\}/p' myfile

# Delete blank lines
sed '/^$/d' myfile

# Substitution optimized for speed
sed '/Yahoo/ s//Not Microhoo/g' myfile

Conclusion

You should now be getting pretty proficient with sed. Use it along with find and grep and you will find yourself feeling much more comfortable on the command-line.

I encourage you to experiment a bit and use this even in circumstances where you know it’s not necessary, just to get the hang of it. In the long run you’ll end up increasing your productivity by using these most powerful tools.

If you liked this post, please help me share it
  • Reddit
  • StumbleUpon
  • description
  • del.icio.us
  • Digg
  • co.mments
  • Google
  • Slashdot
  • Technorati
  • TwitThis
  • E-mail this story to a friend!
  • Furl

Get sed savvy - part 1

Today I’ll continue the series on command-line tools for productivity, with sed. Stream EDitor is the most complicated tool so far, an entire language in its own right. It is much too big to cover completely in one post, so I’m going to have a few posts covering the major parts of sed.

The bread and butter of sed is its search-and-replace functionality. Let’s start with that and then throw in some other fun commands.

Tutorial

As with the previous posts, if you are on Windows you’ll want to install Cygwin or one of the various other tools suggested in the previous comments. sed also uses regular expressions so you’ll want to keep your regex reference handy. From Wikipedia:

[sed] reads input files line by line (sequentially), applying the operation which has been specified via the command line (or a sed script), and then outputs the line.

sed 's/#FF0000/#0000FF/g' main.css

We can read this like so: search [s/] for red [#FF0000/] and replace it with blue [#0000FF], globally [/g] in main.css. Two notes here: 1) This does not actually modify the file, but outputs what the file would look like if it did the replace and 2) If we left off the "g" at the end it would only replace the first occurrence. So let’s modify the file this time.

sed -i -r 's/#(FF0000|F00)\b/#0F0/g' main.css

This is an example from the find tutorial that replaces all instances of red with green in our CSS file. The -r option here gives us extra regex functionality. As Sheila mentioned in the find post, -i does not work on Solaris and she suggests something like perl -e s/foo/bar/g -i instead.

Suppose we want to change a whole color scheme though, the best way is to use a sed script file like so:

# sedscript - one command per line
s/#00CC00/#9900CC/g
s/#990099/#000000/g
s/#0000FF/#00FF00/g
...

# use sedscript with -f
sed -i -f sedscript *.css

sedscript is obviously a new file we have created. Note that we don’t quote the commands in the file. Now we have successfully changed our color scheme in our CSS files.

Other Examples

# Trim whitespace from beginning and end of line
# You *might* have to type a tab instead of \t here depending on your version of sed
sed -r 's/^[ \t]*//;s/[ \t]*$//g'

# Delete all occurances of foo
sed 's/foo//g'

Conclusion

You should start seeing how you can make a lot of changes with simple one-liners with sed. Using it effectively can really increase your efficiency with some tasks.

Here are some good references you should bookmark (including this page of course ;)

I’d say that 90% of the time I use sed for search-and-replace, so you’ve got a good start here. As I mentioned earlier, there is a LOT more to sed. Later, I’ll show you how to make deletions, add line numbers to files, print specific lines by line number, and much more. Stay Tuned, and share your favorite one-liners in the comments!

If you liked this post, please help me share it
  • Reddit
  • StumbleUpon
  • description
  • del.icio.us
  • Digg
  • co.mments
  • Google
  • Slashdot
  • Technorati
  • TwitThis
  • E-mail this story to a friend!
  • Furl