Posts in the “linux-unix” category

Linux mail - a Linux shell script to send mail

Here's a n example Linux shell script (Bourne shell to be specific) that I use to send a list of directories to one of our invoicers. She uses this list as part of a cross-checking process to make sure she bills each one of our customers who have a directory allocated to them. The list is sent to her automatically from a Linux crontab entry I created for her.

Without any further ado, here is the Linux shell script that sends the email. (Note that although I keep writing "Linux mail", this should also work on other Unix systems.)

Linux tee command - redirect output to two directions at once

Today I ran into a need for my old friend the Linux tee command. With the tee command you can read input from an input stream, and split the output stream in two directions, so it is both displayed on screen (stdout) and also re-direct it to a file. I needed to do this today when I wanted to monitor something that was running slow, and also keep an output log of the long-running process.

My Linux/Cygwin command prompt

As each day passes I use Cygwin more and more. One of the things I like to do on Unix platforms is to control what my command prompt looks like. On Cygwin, I edited my .bash_profile to include a multi-line entry like this:

PS1='
$PWD
yo: '

This may look bizarre, but I like the results. It makes my command line prompt look like this:

Software requirements - a UI checklist

The checklist provided below isn't ready for prime time, but I wanted to make sure I put a copy of this information somewhere. Basically, I have started to create a checklist of detailed items I need for user interface screens when creating a detailed design specification. So, what I've started to do is list all possible user interface field types, and what features of each interface element that can vary.

Frankly I'm not sure if this is a good idea or not, but if you're into heavyweight processes, this information is certainly needed by someone at some point.

tar gzip example - how to extract a tar archive that has been gzip'd

tar gzip FAQ: Can you show how to extract (un-tar) a tar archive that has been created with tar and gzip?

Say you have a file (archive) named myfile.tar.gz, and you want to unzip it and unpack (un-tar) it in one command. This "tar extract" command should do the trick for you:

tar xzf myfile.tar.gz

That tar command can be read as "use tar and gzip (the 'z' option) to extract the contents of the file (archive) named myfile.tar.gz.

vi commands - the most common vi navigational commands

There are a lot of commands for navigating through a file with the vi editor (or, more recently, the vim editor), but the reality is that I've used various forms of Unix (Ultrix, AIX, CLIX, SCO Unix, etc.), Linux, and more recently Mac OS X, and there are only a few vi commands that I use for moving around in a file.

So I thought I'd list those here, the most common vi commands.

Cygwin and crontab - How to get crontab started running when using Cygwin

Cygwin crontab FAQ: How do I get the crontab system started when using Cygwin?

I can't remember where I found it, but using this series of commands from the Cygwin prompt got the Cygwin crontab system enabled for me. First this command:

cygrunsrv -I cron -p /usr/sbin/cron -a -D

followed by:

net start cron

I haven't used this cygwin feature before, so it feels weird knowing that crontab is running on my Windows system under cygwin.

vi search replace - how to repeat vi commands across multiple files

Another cool feature of the vi and vim editors is that you can easily re-use some search and replace commands across files. For example, I was just editing several HTML files and needed to do the exact same thing to each file: find a certain line, and then delete that line and the line right after it. Fortunately this is very easy to do in vi.

To edit multiple files in vi I first issue this command from the Linux command prompt:

vi and vim editor cheat sheet

It’s raining in downtown Alaska today, so I went ahead and created a vi editor “cheat sheet” for vi and vim users. I tried to focus on the basic vi/vim commands I use most often.

Here’s a direct link to my vi/vim editor cheat sheet (in PDF format).

 

Linux tutorial, part 1

I thought I'd take a little time and write a tutorial on how to get started with the Linux, Unix, and Mac OS X operating systems. As I write this I'm trying to keep in mind a friend of mine who works strictly on Windows, so I'm writing this from that perspective.

Here then is my "Getting Started with Linux and Unix" tutorial.

Linux tutorial, part 2

Quick Start: A typical login session

In my previous post I talked about the history of the Unix and Linux operating systems to give you a little background for the rest of this lesson.

Next, I'd like to dig in and show you what a typical Unix login session looks like, and then I'll get into more details after that.

Linux tutorial, part 3 (ssh, cd, ls, cp, mv)

Logging in to a remote system

To login to that system I'll use a command named ssh, which stands for "secure shell". It's basically an encrypted login session to a remote system. To login to that remote system I'll type this command in my terminal window:

ssh al@foo.bar.com

(Of course everything after the ssh command there is made up. I don't have a login account on any systems named anything like that.)