Archive for the 'Linux' Category

Vim Scripts

For those of you that have already progressed beyond the basics in Vim, Linux.com has some great tips on using scripts within Vim. I particularly like the Multiple Search script, which allows you to do multiple searches and have them stay highlighted:

Vim Multiple Search Screenshot

For you emacs folks, there is even a script to enable Emacs Emulation.

Five scripts that make life easier with Vim [Linux.com]

Editors & Vim & Tips & Tricks & Command Line & UNIX & Linux & Scripts Jed Daniels 05 Jul 2007 No Comments

Learn to use Vi

gVim Editing an HTML Document
Lifehacker has a link this week to the UC San Diego’s Beginner’s Guide to the Vi Editor. I highly recommend that if you read it, the first thing you do is mentally replace all occurrences of Vi with Vim. Vim is Vi iMproved, and it is an awesome editor once you get comfortable with it. Spending a little time to learn Vim can have a significant gain on productivity and performance when you are doing any sort of text editing. I use Vim for just about everything, from note taking to web design (in my opinion there is no better IDE for HTML and CSS).

Once you get started, I also suggest you go here and print out the Vim cheat Sheet, which will help you remember things until you build the required muscle memory to really fly. They also have an excellent 7-step tutorial based on cheat sheets of slowly increasing complexity.

Vim Cheat Sheet

And another great beginner resource is the Vi Survival Guide. This is a good crash course in getting started with Vi, and it includes some advanced usage too.

Howto & Training & Editors & Vim & Tips & Tricks & Productivity & UNIX & Linux & Command Line & Mac Jed Daniels 03 Jul 2007 No Comments

More Shell Tips and Commands

471556 ammonietThese site is pretty new, but I hope it sticks around for a while, cause they’ve already got at least one great entry: 10 Linux Shell Tricks You Don’t Already Know. Really, we swear. And for the most part, they were right (I knew about backgrounding commands in a loop, using tar with -x, and the handy sed one-liners site). But this is an excellent resource and certainly has some useful tips. Technically these should probably be called “shell commands you don’t already know”, but I guess they seem like tricks until you learn the commands behind them. Great stuff, I look forward to more from VentureCake.

10 Linux Shell Tricks You Don’t Already Know. Really, we swear. [VentureCake]

Command Line & Tips & Tricks & BSD & Linux & UNIX & Scripts Jed Daniels 22 Jun 2007 No Comments

Excellent Shell Scripting Guide

471556 ammonietDo you want to brush up your shell scripting skills, but can never really find a decent resource that gives you good examples? Or maybe you’ve just never had the opportunity to learn any scripting at all. Well, I just found a fantastic site that so far seems to be a really awesome review/intro/guide to Bash Shell scripting (warning: I’ve only perused the first couple of sections so far–there is a ton of information here). I don’t know how I haven’t run across this page before, because it appears to have been around for a while. The Bash shell is a standard component of just about all Linux and UNIX systems these days, and Windows users can get it with a tool such as Cygwin to get the functionality available too (I’ll be writing a guide to using Cygwin on Windows soon, but until I do, take a look at Lifehacker’s excellent Introduction To Cygwin series).

Here is a snippet from the Intro of the Advanced Bash-Scripting Guide:

This tutorial assumes no previous knowledge of scripting or programming, but progresses rapidly toward an intermediate/advanced level of instruction . . . all the while sneaking in little snippets of UNIX® wisdom and lore. It serves as a textbook, a manual for self-study, and a reference and source of knowledge on shell scripting techniques. The exercises and heavily-commented examples invite active reader participation, under the premise that the only way to really learn scripting is to write scripts.

The doc reads easily, and progresses fast, but doesn’t assume you are already an expert (something many books and tutorials are guilty of). It covers many topics in detail that most other documents simply gloss over. This is a good one folks, I highly recommend it.

Advanced Bash-Scripting Guide [The Linux Documentation Project]

Tips & Tricks & FreeBSD & Howto & Training & Books & Command Line & UNIX & Linux & BSD & Scripts Jed Daniels 21 Jun 2007 No Comments

VMware Server Tip: Get Current Bridge/NAT/Hostonly Info on a Linux Host Without Running vmware-config.pl

vmware logoThe other day I was trying to help troubleshoot a networking problem with our Virtual Appliance on a VMware Linux Host. I could pretty easily surmise that the problem was somewhere in the configuration, but I was unable to tell what exactly the host’s networking configuration was because you must run vmware-config.pl to configure the network on a Linux VMware host (Windows has the very handy “Manage Virtual Networks” tool that you can use, but alas, no such analog exists on a Linux host, to the best of my knowledge). The problem with running vmware-config.pl is that it requires all virtual machines to be turned off before it will even show you any information, which is a total pain when I just want to see what is bridged to what. So I went searching for a way to extract the information I wanted form the system, and eventually I found it (I was unable to find it on a google search or by searching the VMTN Forums or VMware Knowledge Base, which is pretty rare, so I ended up digging through my own files to find it). Eventually I discovered that the information I was after was stored in /proc/vmnet, which has an entry for each vmnet that is configured on the system. By simply looking in the files, I was able to tell what was going on, hooray!

On my system, I only had a few bridged interfaces, but there were still a lot of files there:

root@my-server:/proc/vmnet# ls
bridge0 hub0.1 hub0.5 hub1.1 hub1.5 userif22 userif50 userif66
bridge1 hub0.2 hub0.6 hub1.2 hub2.0 userif23 userif51 userif73
bridge2 hub0.3 hub0.7 hub1.3 hub3.0 userif24 userif64 userif74
hub0.0 hub0.4 hub1.0 hub1.4 netif0 userif4 userif65 userif75

A little exploring and I was able to surmise that hubX mapped to what we commonly know as vmnetX, with X usually being 0,1, or 8 for a default VMware configuration (in Windows land these are usually called “VMware Network Adapter VMnetX”). I think the hubX.Y files actually show which interfaces of which running machines are connected to that hub, kind of like link lights on a real hub, but I didn’t spend enough time to really be sure. In any case, I was able to determine that since I only have bridges configured on this system, the files bridge0, bridge1, and bridge2 were the ones I was after:


root@my-server:/proc/vmnet# cat bridge0
connected hub0.0 mac 00:50:56:00:00:00 ladrf 00:00:00:00:00:00:00:00 flags IFF_RUNNING,IFF_UP,IFF_PROMISC dev eth0
root@my-server:/proc/vmnet# cat bridge1
connected hub2.0 mac 00:50:56:00:00:00 ladrf 00:00:00:00:00:00:00:00 flags IFF_RUNNING,IFF_UP,IFF_PROMISC dev eth1
root@my-server:/proc/vmnet# cat bridge2
connected hub3.0 mac 00:50:56:00:00:00 ladrf 00:00:00:00:00:00:00:00 flags IFF_RUNNING,IFF_UP,IFF_PROMISC dev vmnet1

It is pretty plain to see that bridge0 connects hub0 (aka vmnet0) to eth0, bridge1 connects hub2 (aka vmnet2) to eth1, and bridge2 connects hub3 (aka vmnet3) to vmnet1 (I’ll explain this funky mapping another time).

Hopefully someday VMware will implement a handy tool like the Windows “Manage Virtual Networks” tool on Linux hosts, but until then, this will be good enough for me to at least tell what is going on on an unknown system. If you’ve got any better ways to get this information, please post them in the comments or email tips@itsnotthenetwork.com.

Linux & VMware Jed Daniels 07 Jun 2007 No Comments

Basic Linux Commands

759479 rockhopper penguinThis week the Slashdot Poll is about least favorite cliches, and one of the missing poll options that we aren’t supposed to complain about is “This is the year of Linux desktop.” Even if it isn’t, there are certainly more reasons to start experimenting with Linux than ever, and there are more new people to Linux than there ever have been. While there are lots of resources out there for learning some of the basics and getting started, sometimes you just need a reminder while actually doing stuff about what is what. Codejacked has written yet another great article that lists a few commands that can help remind you. This is an article about commands that give you information about commands, and it is an excellent resource for newbies and experienced users alike.

Learning Linux Commands [Codejacked]

Tips & Tricks & Linux Jed Daniels 04 Jun 2007 No Comments

Next Page »