Please note that not all articles will appear in this archive page. You may prefer to search for specific articles via the search function on the main page...


ptree (Solaris/Linux/AIX)

Ptree is really useful when digging around trying to sort out process issues on Solaris. Turns out that Linux uses pstree.

I ran into some issues on AIX and I really wanted the equivalent command. Do you know it already exists (but is not referenced anywhere that I could find)?

Check out:


proctree Command
 
Purpose
Prints the process tree containing the specified process IDs or users.
Syntax
proctree [ -a ] [ { ProcessID | User } ]
Description
The /proc filesystem provides a mechanism to control processes. It also
gives access to information about the current state of processes and
threads, but in binary form. The proctools commands provide ascii
reports based on some of the available information.
Most of the commands take a list of process IDs or /proc/ProcessID
strings as input. The shell expansion /proc/* can therefore be used to
specify all processes in the system.
Each of the proctools commands gathers information from /proc for the
specified processes and displays it to the user. The proctools commands
like procrun and procstop start and stop a process using the /proc
interface.

Posted by Ozguru at 07:00 AM

Need to run as root?

Every now and then, I find myself in a locked down account on a restricted access box where I need to run something as root.

Say, for example, you were running BigBrother (why?) on AIX (why?) and you need to run bootinfo -r. In this case the AIX partition is a NIM - so no sudo available....

What you need is a little C program:

main()
{
setuid(0);
seteuid(0);
setgid(0);
seteuid(0);
system("/usr/sbin/bootinfo -r");
}

Note the full pathname used in the system call and the lack of externally passed variables - we don't want to make too big a hole here...

Compile this (obviously not on the NIM because there is no installed compiler). Install it somewhere safe - so that root and bigbrother are the only users that can access it and then:

chown 0:0 filename
chmod a+rx filename
chmod ug+s filename

Of course, if you are more security concious, you should have checked the userid in the C program as well....

Posted by Ozguru at 07:00 AM

Yesterday / Tomorrow (in C for AIX)

Why does AIX have to be so different?

Oh well, this will do it:

#include <stdio.h>
#include <stdlib.h>
int main(int argc, char** argv)
{
while (--argc)
{
int *i = (int *)atoi(argv[argc]) ;
(void) printf("%s %s", argv[argc], ctime(&i)) ;
}
}

You run this by giving it the epoch times as arguments. This can then be used with date +%s in some of the other articles in this series.

Example:

./ctime `date +%s`
1172183288 Fri Feb 23 09:28:08 2007

Posted by Ozguru at 06:00 AM | Comments (1)

Yesterday / Tomorrow (in shell)

This is the most elegant shell solution I have come across:

#!/bin/sh
let today=`date '+%s'`
let yesterday=$today-86400
let tomorrow=$today+86400
echo "He is the same yesterday (" `date -r $yesterday` "),"
echo "  today (" `date -r $today` ") and"
echo "  tomorrow (" `date -r $tomorrow` ")."

Of course, this doesn't work on AIX....

Posted by Ozguru at 07:00 AM

Yesterday / Tomorrow (in perl)

#!/usr/bin/perl
$one_day = 60*60*24 ;
$today = localtime(time) ;
print "today: $today\n" ;
$tomorrow = localtime(time+$one_day) ;
print "tomorrow: $tomorrow\n" ;
$yesterday = localtime(time-$one_day) ;
print "yesterday: $yesterday\n" ;

Gnu date makes this easy:
date -d "tomorrow"

Posted by Ozguru at 06:00 AM | Comments (2)

Got the "untitled folder" blues?

If you have, then MacWorld has the answer: Change the default new folder name:

With just a bit of mucking about in the Finder’s internals, you can set the default name for new folders to anything you like. In the Finder, navigate to /System -> Library -> CoreServices. In the CoreServices folder, Control-click on Finder and choose Show Package Contents from the pop-up menu. In the new window that opens, navigate into Contents -> Resources -> English.lproj. The file we’re going to modify is named Localizable.strings, and the first thing we’re going to do is make a backup copy of the file. Do that by dragging Localizable.strings to the Desktop; since you don’t have rights to modify the English.lproj folder, the Finder will automatically copy, and not move, the file.

The rest of the article explains who to change the N2 variable to some other string.

I like this because it annoys me to have a new folder vanish to the end of the directory (it starts with 'u') ....

Posted by Ozguru at 06:00 AM

Opening files from inside vi

Like most vi-fanatics, I have always known about :split but someone asked me if it was possible to open a file when the name of the file was in the file you were editing.

Confused?

Imagine you are editing the file "foo" and it contains something like:
The really useful data is in the file bar, not in the file foo...

If you place the cursor over the word bar and type gf then vi will open the file bar in the current buffer. Pretty neat hey!

Of course, if you want to keep the current file open and also open the new file, use :split first.

Posted by Ozguru at 06:00 AM | Comments (1)

ImageCaster

I happen to use an excellent piece of software called ImageCaster. It means that the kids (at home during the holidays) can see what Dad is doing at work.

The camera in my work-based iMac, takes a picture at regular intervals and then uploads this to a gallery page. There is a tutorial on how to do this but it overlooks one small problem....

Chances are, when you first play around with this, you will use the default settings (or perhaps fiddle with the naming convention). If so, following the steps in the tutorial will not work perfectly. In fact, I had been using 'wrap' for the file naming and my final gallery page had no images at all.

A quick dig with 'View Source' suggested that the webpage created by the tool was looking for the wrap-based filename (which is the wrong format).

To solve this, make sure that you set the file saving options to shift *before* you chose gallery, then everything else works properly.

[The moral of the story is - use the source, Luke....]

Posted by Ozguru at 06:00 AM | Comments (0)

AIX: Where is the system log?

Q: I found syslog.conf so I went looking for the syslog file but I can't find it...

A: The first problem is that syslog.conf exists but the important entries are commented out. The second problem is that uncommenting them will not create the log file (you have to do that by hand). The third problem is that the default log file is in /tmp instead of somewhere useful (like /var/log or /var/adm).

The relevant part of my syslog file looks like:


kern.info /dev/console
*.info;mail.none;authpriv.none /var/log/messages rotate size 50k files 5
authpriv.info /var/log/secure rotate size 50k files 3
mail.info /var/log/maillog rotate size 50k files 3
*.crit *
*.crit @log-server

If you want to use this, make sure you create the log files:


mkdir -p /var/log
touch /var/log/messages
touch /var/log/secure
touch /var/log/maillog

Posted by Ozguru at 06:00 AM | Comments (3)

AIX: How much memory?

Q1: How much memory is there in my AIX box?

A1: Try:

# bootinfo -r
12713984

Q2: I get some error about file access permissions....

A2: That is because you are not root:

$ bootinfo -r
-bash: /usr/sbin/bootinfo: The file access permissions do not allow the specified action.
$ lsattr -E -l sys0 -a realmem
realmem 12713984 Amount of usable physical memory in Kbytes False

AIX likes to complain about file access permissions even when it really means you don't have the credentials to do something. Most other Unixes would advise you that you need to be root instead....

Posted by Ozguru at 06:00 AM

AIX: Timezones

AIX$ date
Thu Jul 6 06:00:00 EET 2006

EET? Where the heck is EET?

Ahhhh. EET = Eastern European Time.

Good-oh. Some nong set the timezone wrong. Let me go fix it in smit.

Done.

AIX$ date
Thu Jul 6 06:01:00 EET 2006

EET again? Doesn't IBM know anything about timezones? I mean every other vendor manages to get this right and use EST. Oh well, hack the /etc/environment file and add:

TZ=EST-10EDT,M10.5.0,M3.5.0

No worries.

Posted by Ozguru at 06:00 AM | Comments (1)

AIX: Attributes and Configuration

Struggling to understand AIX? There is probably a good reason for that...

Take a deep breath.

Want to check the attributes of a device? Use lscfg (LiSt ConFiGuration).

Want to check the config of a device? Use lsattr (LiSt ATTRibute).

No worries.

Posted by Ozguru at 06:00 AM | Comments (2)

AIX: Move root's home

This tip is from Makus:

The home directory for the root user is per default the root directory of the system. If you move root's home to /home/root (or /usr/root) you'll get the following advantages:

  1. The logs generated by root (smit.*) don't fill up the root directory of the machine. A full root directory can create all sorts of strange problems. The smit logs will get large over time !

  2. You can create a bin directory for root to store some scripts / commands for the root user.

  3. Your root directory (/) does not get cluttered with all the root users files.

Warning: Choose a directory as home directory for root that is local to the machine. It is very awkward to debug networking problems with a home directory on the network !

Posted by Ozguru at 06:00 AM

Good Friday

Posted by Ozguru at 06:00 AM

Latest Mac Development

Story and image were found at The Unofficial Apple Weblog:

Blue Screen of Death on an iMac
Well, that didn't take long. It seems that Windows' crash-tastic tendencies aren't limited to PCs. Check out this post by Deal Catcher forum user dbaxter. He writes that after installing Boot Camp, things were going swimmingly...for thirty minutes. While browsing USB devices, Windows did what Windows does best. Nothing.
Since this is the first we've seen the BSOD as generated by Windows on an Mactel following a Boot Camp install, it would seem that dbaxter has produced the 1st "official" BSOD on an Mac. What an honor.

Posted by Ozguru at 06:00 AM

Shipping News

Back in 2001, Microsoft announced that Longhorn would ship in 2003. Combined that with yesterday's announcement of yet more slippage and the history goes something like this:

  • 2001 - Longhorn will ship in 2003 - greatest thing since sliced bread

  • 2003 - Longhorn will ship in 2005 - will look cooler that whatever Apple ship

  • 2005 - Longhorn Vista will ship in 2006 - cross my heart and hope to die

  • 2006 - Vista will not ship until 2007 - it is hard making operating systems

Of course, they did ship XP near the beginning of that time frame but this is still an awful long time for Microflop suckers consumers to wait. To be fair, it is hard to see how anyone could write a new OS from scratch and get it shipped - I mean it even took Apple a couple of years* to do it :-)

Compare the innovation for a moment (between 2001 and 2007):

  • Microflop:
    • 2001 - Released Windblows XP

    • 2007 - Windows Vista - maybe

  • Apple:
    • 2001 - Cheetah (10.0)

    • 2001 - Puma (10.1)

    • 2002 - Jaguar (10.2)

    • 2003 - Panther (10.3)

    • 2005 - Tiger (10.4)

    • 2007 - Leopard (10.5)

Now that MacOS X runs on Intel chips, maybe Microflop should throw in the towel and license MacOS X as a Windblows replacement. Then they could concentrate on making incompatible versions of Oriface instead :-)

[* OS X beta was 1999, shipped as MacOS X 10.0 on March 24 2001]

Posted by Ozguru at 06:00 AM

What a contrast

Two apparently unrelated articles from two different sources happened to appear adjacent to each other in my news reader:

From Slashdot:

For the second year in a row, Microsoft has waited for Novell's annual BrainShare show to start before claiming a huge customer migration win off NetWare and onto Windows. According to this article Microsoft says that there were more than 1.8 million successful commercial sector migrations in 2005 alone, and a total of 3.3 million customers migrated over the past two years. It has also launched a new program to lure customers in the education and state and local government sectors off NetWare and onto Windows.

From The Register:

Novell will support Netware, the veteran, nay ancient, network operating system, until at least 2015. By which time, presumably everyone who ever used the system will be retired or dead.

Speaking yesterday at the company's annual Brainshare conference in Salt Lake City, Utah, Novell CEO Jack Messman said the firm would support users of the latest (6.5) version of the network operating system software "as long as customers want to run it."

Netware users are not as plentiful as they once were, but they still represent an income stream of sorts for Novell. Which is just as well, as sales for its new flagship software, the SUSE Linux distro are not cutting much mustard, especially when compared with mighty Red Hat.

Given the reliability of Netware and the incredible support offered by Novell, I would guess there are going to be 3.3 million disappointed customers out there.

Posted by Ozguru at 06:00 AM

E450 Disk Mirrors

Q: What is the best (most efficient) way to lay out the disks on a Sun E450 (with all disk trays installed)?

A. A fully expanded E450 has 6 scsi controllers which are spread over three dual channel SCSI buses. Ideally these three should be on separate PCI channels (there are also three of these). Given that the on-board SCSI is effectively on channel A, you should put one SCSI card in a channel B slot and one in a channel C slot. Use the "Owners Guide" if you are having trouble working out which slot is in which PCI channel.

Now the six controllers should be:

  • Onboard SCSI controllers (c0 = disk, c1 = media tray)

  • Channel B controllers (c2 = disk, c3 = disk)

  • Channel C controllers (c4 = disk, c5 = disk)

The two tricks to making sure that you have optimal disk performance is simple:

  • Make sure your mirrors ARE NOT on the same SCSI controller or PCI channel.

  • Make sure any RAID strips ARE on the same SCSI controller or PCI channel.

I used to do something like this (for mirrors):

  • c0t0/c0t1 -> c3t0/c3t1

  • c0t2/c0t3 -> c5t2/c5t3

  • c2* -> c4*

  • c3t2/c3t3 -> c5t0/c5t1

Posted by Ozguru at 06:00 AM

Happy St. Patrick's Day!

2006-03-17--StPatrick.png

Don't forget that an anagram of 'Saint Patrick's Day' is 'Adapt risky antics'....

Posted by Ozguru at 06:00 AM

Changing the Login Window Background

[Found at Mac Geekery - Changing the Login Window Background Without Renaming Files...]

It used to be that if you changed the file at /Library/Desktop Pictures/Aqua Blue.jpg then loginwindow would display that picture as the background instead. In fact, while it's still the case, you can also set a key to explicitly define which file should be used as the desktop picture. My personal preference is to alter a setting over moving around system files (no matter how inert).
In this example, I'm going to change the background to use the Nature/Stones.jpg file instead of Aqua Blue.jpg.
$ sudo defaults write /Library/Preferences/com.apple.loginwindow DesktopPicture -string "/Library/Desktop Pictures/Nature/Stones.jpg"
Now you can logout to get the login window to show up and your change should be noted. If not, either reboot or kill loginwindow.

Posted by Ozguru at 06:00 AM

Modifing CrashReporter

Intel Mac vs Network Performance

How to Hide a User Account in Mac OS X

Jobs I Couldn't Keep (III)

Use tables in Stickies

Install Front Row (with Bonjour) on any Mac

XPenguins on MacOS X

Origami

Playing House

Intel iMac Performance

Internet plug-in not installed

Gender Specific Vocaulary

VirtualPC on Intel

MacIntel Compatibility Issues

Fink for IntelMac

Scrollable Stickies

More scripting with oascript

Samba mount fails (Linux)

Intel iMac vs Safari

Here Scripts

Intel iMac Keyboard Problems

Mac Browser Problems

Powerbook Screens

Daylight Saving Changes (AU/Mac)

Unix Job Ads

MS Office and HTML Documents (MacOS)

Apple switching to 'Windblows'

IMac Bundled Software

CPAN Archives

Intel iMac Unix Software

Intel iMac Performance

Loaded Hearse vs Transit Lanes

Concatenated Articles in MT

Daylight Saving Changes (AU/Solaris)

Universal Apps vs Old Apps

Europa Universalis Cheat

Converting Yojimbo bookmarks

King George?

Deep Sleep (Safe Sleep)

Use Google Maps with People widget

Burn Folder Size

Agenda font problems

Firewall Stealth Mode

Virtual PC vs IntelMac?

Perfect Spider Score

The more things change...

The Singing Mac

Hidden Stickies

Wear Your Headphones...

Are you buying a MacBook Pro?

Cisco VPN

TechTip: Battle for Wesnoth (Cheat)

Finder labels

osascript vs posix paths

Forking

Something is wrong with SMC

JNI Fibre Drivers

IDPROM Invalid Contents (280R)

Does Solaris have SMIT or SMITTY

Blojsom Install

StorEdge D1000 (Again)

StorEdge D1000

Unix Error Messages

Hex Converter

AP and boot disks

Watchdog Reset

The Day SunOS Died

SunOS vs Solaris

T3 Disk Replacement

SCSI IDs for Disk Cards

Adding a Hot Spare in SVM

TurboGX Video Card

UNIX is a drug

PROM Commands

Unix Users

Recreate /dev/null

Unexpected disconnect (SCSI)

Bad blocks (mirrored disk)

Creating Disk Layouts

Ethernet Settings

V240 ALOM Warning lights

Automount /home (Solaris 10)

T3 Serial Cables

Kernel Changes Missing

Unix Expertise

T3 Disk Lights

Solaris vs Serial Terminals

iTunes 6

Combining Solaris Patch Directories

AP and Solaris

TechTip: iTunes 5 installation

Solaris 9, STMS and A5000

Ethernet Devices (Solaris)

OpenSSH 4.2p1

SVM / SDS numbering

Who or what was the KOTF?

Rounding with strfmon on Solaris

Replacing an A1000 battery

Building an E4500/5500/6500

Copying Disk Layouts (Solaris)