Tech Blog

These are blog entries written by the UNIX Health Check development team. Our team has extensive technical experience on both AIX and Red Hat systems, and we like to share our knowledge with our visitors.

Topics: AIX, System Admin

Control-M

When exchanging text files between Windows and AIX systems, you often run into ^M (CTRL-M) characters at the end of each line in a text file. To remove these ugly characters:

tr -d '^M' < [inputfile] > [outputfile]
To type the ^M character on the command line: press CTRL, then type v and the m.

Another way: download this zip archive: controlm.zip (1KB).

This zip archive includes 2 files: unix2dos and dos2unix, which you can run on AIX:

To convert a Windows file to Unix file:
# dos2unix [filename]

Topics: AIX, System Admin

Centralized shell history

It's a good idea to centralize the shell history files for ease in tracking the actions done by the users:

Create a ${hist_dir}. Add the following lines to the /etc/profile file:

export HISTFILE=/${hist_dir}/${LOGNAME}_`date "+%Y%m%d_%H%M%S"`
export HISTSIZE=2000

Topics: AIX, System Admin

FTP umask

A way to change the default 027 umask of ftp is to change the entry in /etc/inetd.conf for ftpd:

ftp stream tcp6 nowait root /usr/sbin/ftpd -l -u 117
This will create files with umask 117 (mode 660). Using the -l option will make sure the FTP sessions are logged to the syslogd. If you want to see these FTP messages in the syslogd output, then you should add to /etc/syslog.conf:
daemon.info [filename]

Topics: AIX, System Admin

DLpar with DVD-ROM

Adding a DVD-ROM with DLpar is very easy. Removing however, can be somewhat more difficult, especially when you've run cfgmgr and devices have been configured. This is how to remove it. Remove all cdrom devices found with lsdev -Cc cdrom:

# rmdev -dl cd0
# rmdev -dl ide0
Then remove all devices found with:
# lsdev -C | grep pci
All PCI devices still in use, can't be removed. The one not in use, is the PCI device where the DVD-ROM drive on was configured. You have to remove it before you can do a DLPAR remove operation on it. Now do your DLPAR remove operation.

Topics: AIX, System Admin

Sending attachments from AIX

How do you send an attachment via e-mail from AIX to Windows? Uuencode is the answer:

# uuencode [source-file] [filename].b64 | mail -v -s "subject" [email-address]
For example:
# uuencode /etc/motd motd.b64 | mail -v -s "Message of the day" email@hostname.com
The .b64 extension gets recognized by Winzip. When you receive your email in Outlook, you will have an attachment, which can be opened by Winzip (or any other unzip tool).

You can combine this into a one-liner:
# ( echo "This is the body";uuencode /etc/motd motd.b64 ) | mail -s "This is the subject" email@hostname.com
If you want to attach tar of gzip images to an e-mail, you can also simply use those extensions to send through email, as these extensions are also properly recognized by Winzip:
# uuencode file.tar file.tar | mailx -s "subject" email@hostname.com
# uuencode file.tar.gz file.tar.gz | mailx -s "subject" 
email@hostname.com

Topics: AIX, System Admin

Defunct processes

Defunct processes are commonly known as "zombies". You can't "kill" a zombie as it is already dead. Zombies are created when a process (typically a child process) terminates either abnormally or normally and it's spawning process (typically a parent process) does not "wait" for it (or has yet to "wait" for it) to return an exit status.

It should be noted that zombies DO NOT consume any system resources (except a process slot in the process table). They are there to stay until the server is rebooted.

Zombies commonly occur on programs that were (incompletely) ported from old BSD systems to modern SysV systems, because the semantics of signals and/or waiting is different between these two OS families.

See: http://www.hyperdictionary.com/dictionary/zombie+process

Topics: AIX, System Admin

Montoring a system without logging in

Let's say you have a helpdesk, where they must be able to run a script under user-id root to check or monitor a system:

First, create a script, you wish your helpdesk to run.

Modify your /etc/inetd.conf file and add:

check stream tcp wait root /usr/local/bin/script.sh
Where script.sh is the script you've written.

Modify your /etc/services file and add:
check 4321/tcp
You may change the portnumber to anything you like, as long as it's not in use.

Now, you may run:
# telnet [system] 4321
And your script will be magically run and it's output displayed on your screen. If the output of the script isn't displayed on your screen very long, just put a sleep command at the end of your script.

Topics: AIX, System Admin

Finding files with no defined user or group

Use the following command to find any files that no longer have a valid user and/or group, which may happen when a group or user is deleted from a system:

# find / -fstype jfs \( -nouser -o -nogroup \) -ls

Topics: AIX, System Admin

Bootinfo

To find out if your machine has a 64 or 32 bit architecture:

# bootinfo -y
To find out which kernel the system is running:
# bootinfo -K
You can also check the link /unix:
# ls -ald /unix
unix_mp: 32 bits, unix_64: 64 bits

To find out from which disk your system last booted:
# bootinfo -b
To find out the size of real memory:
# bootinfo -r
To display the hardware platform type:
# bootinfo -T

Topics: AIX, System Admin

Cleaning file systems

It sometimes occurs that a file system runs full, while a process is active, e.g. when a process logs its output to a file. If you delete the log file of a process when it is still active, the file will be gone, but the disk space will usually not be freed. This is because the process keeps the inode of the file open as long as the process is active and still writes to the inode. After deleting the file, it's not available as file anymore, so you can't view the log file of the process anymore. The disk space will ONLY be freed once the process actually ends.

To overcome it, don't delete the log file, but copy /dev/null to it:

# cp /dev/null [logfile]
This will clear the file, free up the disk space and the process logging to the file will just continue logging as nothing ever happened.

Number of results found for topic System Admin: 249.
Displaying results: 231 - 240.