Wednesday, February 27, 2008

Dump Sybase Database to File

I had a reader ask me offline how to transfer a legacy database to another instance of a database management system (DBMS) on a separate server/workstation. The reader was trying to extract historical statistics via a test database (on a test server) without affecting the production database. I recommended dumping the entire database to a flat file and then writing (tar) the file to tape. I was uncertain if my response answered the reader's initial question but this is one way I dealt with a relatively small database (less than 50 megabytes) a few years ago. By the way, the sequence below assumes the receiving Sybase database was appropriately named and sized when it was created.

Login into production DBMS
1> use master
2> go
1> dump database yourdb to "/tmp/mydatabase.dat"
2> go
1> quit
2> go

Archive flat file to tape (assumes a tape drive is attached)
# cd /tmp
# tar cvfp /dev/rmt/0 mydatabase.dat

Move tape media to receiving server/workstation (assumes a tape drive is attached)
# cd /tmp
--This should extract mydatabase.dat to the /tmp directory
# tar xvfp /dev/rmt/0
# chmod 777 mydatabase.dat

Login into your test server DBMS
1> use master
2> go
1> load database yourdb from "/tmp/mydatabase.dat"
2> go
1> online database yourdb
2> go
1> quit
2> go

Other Sybase posts

Sunday, February 24, 2008

Troubleshooting the "su: No shell" error

The other day we had a problem with a system account. At first we did not notice the “su: No shell” error on the console (headless server) but after a few reboots it was fairly evident. The message gave us enough feedback to determine the substitute user or su command was having a problem with a particular account. To ascertain which system account, we invoked a sequential step-through of the startup scripts.

In the end, it appears that a third party application used to manage NIS+ had locked and changed the account’s shell to something unknown (by design) due to multiple login failures. The account was restored to its original shell.

# su - esofthub -c "myscript"
su: No shell

View locked account
# niscat passwd.org_dir | grep esofthub
esofthub:*LK*:1005:10:esofthub test:/home/esofthub:/bin/sh.locked:13933::::::

Modify with third party application
After the modification
# su - esofthub -c "myscript"
Visit Ucertify's challenge winners' blogs: Ax0N and armando

For Files Only

If you are using the files repository and no third party software to manage your user information, modify the /etc/passwd file.

View locked account
# less /etc/shadow | grep esofthub
esofthub:*LK*:13933::::::
# less /etc/passwd | grep esofthub
esofthub:x:1005:10:esofthub test:/home/esofthub:/bin/sh.locked

Modify the account manually or admintool
# vi /etc/passwd
...
esofthub:x:1005:10:esofthub test:/home/esofthub:/bin/sh
...
:wq!

Change shell to C shell or any other shell if so desired
# passwd -r files -e esofthub
Old shell: /bin/sh
New shell: /bin/csh

Or
# admintool &

After the modification
# su - esofthub -c "myscript"
Visit Ucertify's challenge winners' blogs: Ax0N and armando

Monday, February 18, 2008

Using Z Shell Brace Expansion to Create Test Files

Here is a convenient way of creating test files using the powerful Z Shell. I have been using this shell for a short while, and I am quickly becoming a fan of it. I used it to support transfer speed tests. To support these tests, I created a specified number of files that varied in size (1MB, 5MB, 10MB, 50MB, 100MB, 500MB, etc). Here is a straightforward one-liner mkfile example of creating 50 x 12MB files and a few others using zsh’s brace expansion.

# zsh
# mkfile 12m {1..50}.tst
# ls -l
total 122960
-rw------T 1 root other 12582912 Feb 18 20:04 1.tst
-rw------T 1 root other 12582912 Feb 18 20:04 2.tst
-rw------T 1 root other 12582912 Feb 18 20:04 3.tst
-rw------T 1 root other 12582912 Feb 18 20:04 4.tst
-rw------T 1 root other 12582912 Feb 18 20:04 5.tst
...

Other examples...

# touch {1..5}.testfile
# ls -l
total 0
-rw-r--r-- 1 root other 0 Feb 18 20:07 1.testfile
-rw-r--r-- 1 root other 0 Feb 18 20:07 2.testfile
-rw-r--r-- 1 root other 0 Feb 18 20:07 3.testfile
-rw-r--r-- 1 root other 0 Feb 18 20:07 4.testfile
-rw-r--r-- 1 root other 0 Feb 18 20:07 5.testfile

# touch {6..10}.data
# ls -l
total 0
-rw-r--r-- 1 root other 0 Feb 18 20:30 1.data
-rw-r--r-- 1 root other 0 Feb 18 20:30 10.data
-rw-r--r-- 1 root other 0 Feb 18 20:30 2.data
-rw-r--r-- 1 root other 0 Feb 18 20:30 3.data
-rw-r--r-- 1 root other 0 Feb 18 20:30 4.data
-rw-r--r-- 1 root other 0 Feb 18 20:30 5.data
-rw-r--r-- 1 root other 0 Feb 18 20:30 6.data
-rw-r--r-- 1 root other 0 Feb 18 20:30 7.data
-rw-r--r-- 1 root other 0 Feb 18 20:30 8.data
-rw-r--r-- 1 root other 0 Feb 18 20:30 9.data

# ls -l {1..5}.data
-rw-r--r-- 1 root other 0 Feb 18 20:26 1.data
-rw-r--r-- 1 root other 0 Feb 18 20:26 2.data
-rw-r--r-- 1 root other 0 Feb 18 20:26 3.data
-rw-r--r-- 1 root other 0 Feb 18 20:26 4.data
-rw-r--r-- 1 root other 0 Feb 18 20:26 5.data

Wednesday, February 13, 2008

Permanently Remove Data on UNIX Hard Drives

It is fairly common for companies to dispose of their obsolete hard drives. However, most of them want to ensure all data is shredded from the hard drives. Finding a Windows-based wipe program was fairly easy, but finding a UNIX-based program took a little more searching. BCWipe is a program that will wipe a UNIX-based hard drive clean. The BCWipe website claims their multi-platform UNIX version is intended to give you a confidence that your deleted files cannot be recovered by an intruder. BCWipe repeatedly overwrites special patterns to the files to be destroyed.

Note: Most likely you will have to compile the source code for your particular platform architecture.

BCWipe for UNIX offers the following wiping schemes per their site.

1. US DoD 5220.22-M standard (7 passes with verification)
2. User-defined number of passes
3. Peter Gutmann's 35 pass scheme

BCWipe for UNIX is designed as a multi-platform solution. Here is their supported list of various UNIX flavors.

Linux 2.0-2.6
FreeBSD 3.0-4.6
OpenBSD 2.8
Solaris 8-10
Digital UNIX 4
SGI Irix 6.5 (wiping block devices was not tested)
IBM AIX 5
HP-UX 10, 11

Here is the download link for 30 day evaluation.
BCWipe Download

Saturday, February 09, 2008

Automounting a User’s Home Directory

A couple colleagues of mine were trying to execute a program on the server that required a special initialization environment, which was called from the /home/loginuser path. The login, loginuser, was not part of the server’s name service domain. It was a local account on a remote workstation. After a little discussion, they added this syntax to the /etc/auto_home file. Here is a run to illustrate the aforementioned.

# vi /etc/auto_home
# Home directory map for automounter
#
loginuser esoft:/export/home/USERS/&
#
* server:/export/home/USERS/&
#
+auto_home
:wq!

# automount -v
automount: /net mounted
automount: /home mounted
automount: /xfn mounted
automount: /export/opt mounted
automount: no unmounts

# cd /home/loginuser
# ls -a
. .. .cshrc myblog esoftfile topblog

Tuesday, February 05, 2008

Troubleshoot POP3 Mail Server with Telnet

I am finally getting an opportunity to write a post. I have been so busy with upgrades lately and had to put off writing for awhile.

The other day I had a number of users complaining about not being able to fetch mail to their mail client, MS Outlook. As usual, I attempted to duplicate the error. The error message was reporting unable to connect to the mail server. At that point, I decided to telnet the Post Office Protocol or POP3 port, 110, via the command line interface. Sure enough, I had a problem.

Note: The “before and after” command line examples are only for illustration purposes.

# telnet server 110
Trying 192.1xx.xx.xxx...
telnet: Unable to connect to remote host: Connection refused

I started thinking there was a problem with the inetd.conf file. After reviewing the file, I noticed the pop3 service was commented out. The appropriate change was made and inetd was restarted. Problem resolved.

# telnet server 110
Trying 192.1xx.xx.xxx...
Connected to server.
Escape character is '^]'.
+OK connected to pop3 on 3429

By the way, you can check out other popular port services, too.
# telnet server 6667
# telnet server 25