Software QA FYI - SQAFYI

Getting Started Guide to Unix Based Testing


First, let us see what UNIX is and what the various flavors of UNIX are?

What is Unix?
The history of UNIX starts back in 1969, when Ken Thompson, Dennis Ritchie and others started working at Bell Labs what was to become UNIX .Originally written in assembler, UNIX was re-written in C in 1973. Here are some features of UNIX:

* Unix is divided into two constituents:
o Kernel: Communicates with the hardware of a machine directly.
o Shell: Interprets the commands given by the user so that the kernel can read, understand and execute the command.

* Unix is comprised of number of small commands, which performs one simple job only. These commands can be grouped together to achieve a complex task.
* Unix provides a very strong pattern matching capability with the use of metacharacters.
* Unix is highly programmable since it was designed keeping a programmer in mind. Shell programming can achieve what many development languages like C++ are capable of doing.
* Unix is a Multi-Tasking, Multi-User Operating System.
* Unix provides vary high level of Security and Networking support.
* And most importantly, UNIX is an Open System.

All these features make UNIX a very powerful Operating System.

One more advantage in UNIX is that a job can be run in the background in the same shell whereas in windows this is not possible. So one can write a piece of shell-script and keep running the same in the background that would work just like a service on windows.

UNIX Flavors and Versions
UNIX has changed a lot since it was first developed in 1969. Many new features have been added to make it more efficient and robust. Many vendors and many flavors of Unix are available today. Linux, Solaris, AIX, HP-UX and Tru64 are some of the popular ones.

The major difference between these flavors is their vendor. IBM has its own hardware and they created AIX that would work well on their hardware. Similarly, HP invented HP-UX. Solaris works on SPARC based architecture. In all these flavors, the kernel is the same although the file system may vary. Above all, Linux itself comes from different vendors like RedHat, Mandrake, Novell (Suse) etc. There are few basic differences between these flavors like the default shell on Red Hat Linux is Bash whereas on Solaris it is Csh. They handle metachars differently.

The file format on Linux is ELF (Executable and Linking Format) while on AIX and Solaris it is COFF (Common Object File Format).

When we say UNIX Flavors, it means that these OS follow some rules in order to qualify as a UNIX OS. All that an OS needs to qualify, as a UNIX OS is that it should be a POSIX (Portable Operating System Interface) compliant. POSIX is a set of rules or policies defined just like ISO (International Organization of Standards) or CMM (Capability Maturity Model), so that these flavors have the basic, important and frequently required features available all the time.

Let us now see what all commands are useful in order to test applications on a UNIX machine.

Beginning with the Testing
The testing begins with connection to a remote UNIX box. This connection can be established via various methods like WRQ Reflection, Putty, Citrix, Telnet, etc. But there are some important and key things, which requires consideration when testing on Unix. One has to keep in mind the following things:
* The Shell
* Processes and Jobs
* File System
* File Permissions
* Filters
* Shell Programming

In this article, I will explain few basic commands very useful in UNIX environment and will be focusing on the topic: The Shell.

Logging with Local User v/s NIS User
We will first take a closer look on the login process and then proceed with the above-mentioned topics.

To establish a connection, a user can log in if he/she is a NIS (Network Information Service) user OR if the user is added in the /etc/passwd file on the UNIX box.

The /etc/passwd file contains the Name, Password, UserID, Home directory and default shell defined for the local user in a specified format.

Listing 1 The /etc/passwd file

$ cat /etc/passwd


dennis: qcz0IWuPIQxiM:504:10::/usr/dennis:/bin/bash

* This file is : delimited with each line beginning with the local user name dennis.

* x for user root denotes that the password has been encrypted and stored in the /etc/shadow file, while for dennis the qcz0IWuPIQxiM denotes that password is encrypted in the /etc/passwd file itself and not in /etc/shadow file.
* 504 is the User ID for dennis

* 10 is the principal group ID for dennis
* Next field is blank for dennis while it is Super-User for root. This is the general information about the user.
* /usr/dennis is the Home Directory of the user dennis and,
* /bin/bash is the default Shell defined for dennis.

When a NIS user logs in to the machine the environment is a bit different than that of a Local user:

* Default shell would be the default shell configured for that particular box, which may vary from machine to machine
* The home directory would be the home directory configured in the NIS database.
* If this specific directory that is configured in the NIS database is not mounted, the default directory after logging in would be the root directory.
Once the user is logged into the system, all thats needed is the use of commands to control the application.

Who is using my machine?
If the machine is used by more than one user at any given time, a good practice is use of the commands who (lists the users that are currently logged into the machine) and last (lists the users that were previously logged into the machine). These commands help to avoid unnecessary conflicts between simultaneous users. Listing 2 will explain the output of these commands.

Listing 2: who output

$ who
root tty01 May 15 15:30
dennis tty02 May 16 20:00
Here, 1st column displays the name of user logged in; 2nd display the device names of respective terminals; 3rd displays Date and Time of logging in.
$ last
dennis tty01 dennis-w2k-01 Sun May 16 20:00 still logged in
dennis pts/2 dennis-w2k-01 Thu May 12 22:46 - 00:46 (02:00)
1st column displays user name, 2nd the terminal name, 3rd is the remote machine through which these users were logged in, 4th is date of logging in, still logged on denotes the user is currently working on the machine while (02:00) denotes the duration for which the user was logged into the machine.
If a NIS user logs into the machine and the configured home directory is not mounted, the /tmp or /var directory can be used to store the data. These directories are supposed to be on every UNIX machine as per the file system of UNIX OS. The df k command lists the mounted directories as well as the free space on each mounted directory. To mount a remote directory, use the command mount and to unmount a directory use unmount. Make sure that one is logged in as a root or other user with Admin rights.
One good feature of UNIX is that to log in as a different user, one does not need to logout and then re-login as another user (as in Windows). To login as another user, simply type in the command su . This will open another shell and one can start working as if he were the new user. The su without any user name logs in as the root.
The command pwd is used frequently to display the present working directory. Since its difficult to view a graphical structure of the file system, this command is useful to understand which part of the file tree one is working currently.
E.g.: $ pwd

Full article...

Other Resource

... to read more articles, visit

Getting Started Guide to Unix Based Testing