Posts Tagged unix
Create *.db files for sendmail
Posted by Lincoln Zuljewic Silva in General Unix on January 20, 2011
You can use the following command to create a *.db file to be used, for example, in sendmail:
makemap btree /etc/userdb.db < /etc/userdb
It will create a userdb.db based in the userdb file
Recovery files from a IGNITE HP-UX backup
Posted by Lincoln Zuljewic Silva in HP-UX on November 18, 2010
If you have a backup made using the ignite tool on a HP-UX, you can use the following commands to recovery just a part of it.
For PA-RISC:
-Rewind the tape
mt -t /dev/rmt/0mn rew
-Forward to the sector after the boot
mt -t /dev/rmt/0mn fsf 1
-Use tar to extract the file
tar xvf /dev/rmt/0mn etc/hosts
For Itanium2:
-Rewind the tape
mt -t /dev/rmt/0mn rew
-Forward to the sector after the boot
mt -t /dev/rmt/0mn fsf 22
-Use tar to extract the file
tar xvf /dev/rmt/0mn etc/hosts
NOTE: change “/dev/rmt/0mn” to your tape device. If you don’t know what it is, run the command “ioscan -fnC tape” do find it out.
Convert a text to/from UPPER to/from lower
Posted by Lincoln Zuljewic Silva in General Unix on November 5, 2010
You can use the following command do convert a file content from upper case do lower case:
cat /tmp/upper_file.txt |tr '[:upper:]' '[:lower:]' > /tmp/lower_file.txt
Or the following command to convert from lower to upper case:
cat /tmp/lower_file.txt |tr '[:lower:]' '[:upper:]' > /tmp/upper_file.txt
How to check HBA card settings in HP-UX
Posted by Lincoln Zuljewic Silva in HP-UX on September 23, 2010
First of all, you need if the device exists:
myserver@root:/root # ioscan -fnC fc
Class I H/W Path Driver S/W State H/W Type Description
===================================================================
fc 1 0/0/4/1/0 fcd CLAIMED INTERFACE HP AB378-60101 4Gb Single Port PCI/PCI-X Fibre Channel Adapter (FC Port 1)
/dev/fcd1
fc 2 0/0/10/1/0 fcd CLAIMED INTERFACE HP AB378-60101 4Gb Single Port PCI/PCI-X Fibre Channel Adapter (FC Port 1)
/dev/fcd2
fc 3 0/0/12/1/0 fcd CLAIMED INTERFACE HP AB378-60101 4Gb Single Port PCI/PCI-X Fibre Channel Adapter (FC Port 1)
/dev/fcd3
fc 0 0/0/13/1/0 fcd CLAIMED INTERFACE HP AB378-60101 4Gb Single Port PCI/PCI-X Fibre Channel Adapter (FC Port 1)
/dev/fcd0
Now, you can check the settings:
myserver@root:/root # fcmsutil /dev/fcd1
Vendor ID is = 0x001077
Device ID is = 0x002422
PCI Sub-system Vendor ID is = 0x00103c
PCI Sub-system ID is = 0x0012d6
PCI Mode = PCI-X 133 MHz
ISP Code version = 4.0.22
ISP Chip version = 3
Topology = PTTOPT_FABRIC
Link Speed = 4Gb
Local N_Port_id is = 0x020300
Previous N_Port_id is = None
N_Port Node World Wide Name = 0x5001438002fdf7c3
N_Port Port World Wide Name = 0x5001438002fdf7c2
Switch Port World Wide Name = 0x200300051e365dca
Switch Node World Wide Name = 0x100000051e365dca
Driver state = ONLINE
Hardware Path is = 0/0/4/1/0
Maximum Frame Size = 2048
Driver-Firmware Dump Available = NO
Driver-Firmware Dump Timestamp = N/A
Driver Version = @(#) libfcd.a HP Fibre Channel ISP 23xx & 24xx Driver B.11.23.06 /ux/core/isu/FCD/kern/src/common/wsio/fcd_init.c:Jun 23 2006,14:06:46
How to remove/move/copy/rename file that has a non-printable name
Posted by Lincoln Zuljewic Silva in General Unix on September 23, 2010
How to remove/move/copy/rename file that has a non-printable name, for example:
backup@root:/home/userhome/test # ls -la
total 2
-rw-rw-rw- 1 root sys 0 Sep 23 15:48
drwxrwxrwx 2 root sys 96 Sep 23 15:50 .
drwxr-xr-x 5 userhome adm 1024 Sep 23 16:20 ..
-rw-rw-rw- 1 root sys 0 Sep 23 15:47 -test
The easiest one is the file named "-test", you can do a "mv -- -test xx" to rename it to test, getting rid of the "-".
The most annoying is the other file, which apparently has the name "blank", but not quite.
There are two ways to find the real file name.,"ls -lq" e "ls -lb":
backup@root:/home/userhome/test # ls -lq
total 0
-rw-rw-rw- 1 root sys 0 Sep 23 15:48 ?
-rw-rw-rw- 1 root sys 0 Sep 23 15:47 xx
backup@root:/home/userhome/test # ls -lb
total 0
-rw-rw-rw- 1 root sys 0 Sep 23 15:48 \002
-rw-rw-rw- 1 root sys 0 Sep 23 15:47 xx
backup@root:/home/userhome/test # ls -li
total 0
17334 -rw-rw-rw- 1 root sys 0 Sep 23 15:48
17332 -rw-rw-rw- 1 root sys 0 Sep 23 15:47 xx
The "ls -lb" shows the non-printable characters with "\ XXX" where XXX is the ASCII representation of the non-printable character.
The "ls -lq" shows the non-printable characters with "???" (quantity of ? is defined by the amount of non-printable caracters).
The "ls -li" shows the file inode.
To handle this file, the best option is to use the "find".
- Using the find based on the inode:
find . -inum 17334 -exec mv {} asd \;
- Using find with "wildcards" (based on the ls-lq returned):
find . -type f -name "?" -exec mv {} asd \;
Be careful when using the find with "meta character"! If a file whose name has only one character, it will enter the result.
When Glance stop working
Posted by Lincoln Zuljewic Silva in HP-UX on December 6, 2009
Sometimes glance (performance monitor for HP-UX) can crash (before crash, it will return 0% of CPU, Disk and networking) working with the following error:
GlancePlus fatal error.
== Fatal Nums Error == C.04.50.57 02/10/07 ==
User: root/6pts/6(/dev/pts/6) Date: Sun Dec 6 15:52:12
File: /crm/numsVob/hp/11.0/nums.C Line: 485 Product id: Glance
System: server B.11.11 9000/800
Errno: 0 (Error 0)
Connection to midaemon lost -- check midaemon process and status.mi == End of Error Msg
=============================
To solve it, you should:
Stop MWA:
# mwa stop
Remove all files (including the hidden ones) from /var/opt/perf/datafiles:
# rm -rf /var/opt/perf/datafiles/* rm -rf /var/opt/perf/datafiles/.*
Check if midaemon and ttd are stopped:
# mwa status
If midaemon and ttd didn’t stop, force stops them with the command kill (the PID was returned by the command ‘mwa status’).
Now, start MWA again:
# mwa start
Creating an user on AIX
Posted by Lincoln Zuljewic Silva in Aix on December 1, 2009
Creating an user on AIX
On AIX, you can use the following commands to create an user
# mkuser pgrp='primary group' groups='other groups' home='home directory' shell='/usr/bin/ksh' gecos='GECOS' USERNAME