Monday, 16 May 2011

AIX Basics- Prerequisite




AIX short for Advanced Interactive eXecutive was first entered into the market by IBM in February 1990. AIX is an implementation of Unix derived from both AT&T Unix System V and 4.3 BSD. AIX offers the Korn (ksh) shell, Bourne (sh) and C (csh) shells however defaults to the Korn shell. AIX primarily designed for medium to large scale servers and mainframes. However, it can also be used in workstations. It supports standard peripherals like Supports standard peripherals: PCI Slots, SCSI, PS/2 keyboard and mouse, Ethernet.

Levels Of AIX
The AIX system is functionally organized at three levels:
- The kernel, which schedules tasks and manages storage;
- The shell, which connects and interprets users' commands, calls programs from memory, and executes them; and
- The tools and applications that offer additional functionality to the operating system.

The Kernel
The heart of the operating system, the kernel controls the hardware and turns part of the system on and off at the programmer’s command. If you ask the computer to list (ls) all the files in a directory, the kernel tells the computer to read all the files in that directory from the disk and display them on your screen. The kernel itself does not interact directly with the user, but rather interacts with the shell and other programs as well as with the hardware devices on the system, including the processor (also called the central processing unit or CPU), memory and disk drives. The kernel is the first part of the operating system to load into memory during booting (i.e., system startup), and it remains there for the entire duration of the computer session because its services are required continuously. Thus it is important for it to be as small as possible while still providing all the essential services needed by the other parts of the operating system and by the various application programs.
When a computer crashes, it actually means the kernel has crashed. If only a single program has crashed but the rest of the system remains in operation, then the kernel itself has not crashed. The kernel provides basic services for all other parts of the operating system, typically including memory management, process management, file management and I/O (input/output) management (i.e., accessing the peripheral devices). These services are requested by other parts of the operating system or by application programs through a specified set of program interfaces referred to as system calls.

Logical Volume Manager (LVM)
LVM is a disk management mechanism that is significantly different from traditional UNIX partitioning schemes. The LVM maps data between logical and physical storage, allowing data to be discontiguous, span multiple disks, flexible and dynamically expanded. One advantage is the ability to allocate additional space to a file system without the need to rebuild the disk. The LVM controls physical disk resources by providing a simplified logical view of the available storage space.

Volume Group, Filesystems and Logical Volumes
The logical storage structure that is the most common is called the volume group (VG). In AIX, storage allocation is performed at the volume group level. Data cannot span volume groups. When the AIX operating system is first installed, a volume group called rootvg is created. The rootvg contains the base operating system files for AIX.
Each individual disk drive is logically represented by a physical volume (PV). Each physical volume consists of a number of partitions called physical partitions (PP). The physical partitions are grouped into something called a logical volume that contains logical partitions. The logical volume, in turn, belongs to a volume group. Logical volumes contain the file systems (like the Journaling File System or JFS).
All of the logical volumes use JFS to store data. This file system uses database journaling techniques to maintain its structural consistency. This prevents damage to the file system when the system is halted abnormally. Other file systems that you might encounter on AIX may include JFS2, NFS (Network File System), and AFS (Andrew File System). The term file system is also used to describe the hierarchical structure (file tree) of files and directories.

The Shell
The shell is a command interpreter that allows an end user to type in commands to communicate to the AIX system. By default, when a user logins, a shell process is started. The default AIX shell is /usr/bin/ksh, which is the Korn Shell, unless and until specified while creating a user. Other available shells are:
- /bin/bsh the Bourne shell
- /bin/csh the C-shell
- /bin/sh the Standard shell

Using the System
Logging in and out
After bootup, the RS/6000 displays a login prompt on what looks like a character-based terminal, where you can enter your username and password to get into the system. Logging in to the RS/6000 follows the typical UNIX login process: The getty process provides the login screen. If a user enters an id at this getty login prompt, getty starts the login process to validate the user. AIX's login program checks not only /etc/passwd, which contains user names, but also a shadow password file, /etc/security/passwd, which contains the encrypted passwords of each of the users. login then starts a login shell as defined in /etc/passwd for the user, which by default is the KornShell (ksh). ksh then reads the user's .profile.
If you are in an X Window session, stopping it by choosing End Session on the Root Menu will usually log you out. However, if your system displays an ASCII screen with a command line prompt (usually a "$" prompt) after you stop X, then you have to take the additional step of closing the shell by typing either the exit command or the logout commands.

The date, cal, who and finger commands
The ‘date’ command displays or set the date or time for a particular system. If the command is run without any flag, it displays the current date and time to standard output.
The ‘cal’ command displays a calendar of the specified year or month.
The ‘who’ command displays information about all users currently on the local system. The information displayed when running the command is login name, tty, date and time of login. Typing who am i or who am I displays your login name, tty, date and time you logged in. If the user is logged in from a remote machine, then the host name of that machine is displayed as well.
The ‘finger’ command displays information about the users currently logged in to a host.

Sending and receiving mail
You can use the ‘mail’ program to create, send, reply, and forward messages to other users or to send ASCII files to other users. An ASCII file may, for example, be a document you have written using a preferred editor or a source file for a program. The mail program provides a line-oriented editor for creating messages. This editor enables you to enter each line of the message, press the Enter key to get a new line, and enter more text. When you create mail with the mail editor, the date: and from: fields are automatically completed by the system. You have the option to complete the subject: and cc: fields. These fields are similar to the body of a standard business letter. Other editors can only be used by using the editor subcommands. You can send messages and files to a user on your local system, on your network, or to a user on another connected network. The recipient does not need to be logged onto the system when you send the information. Mail is sent to a user's address. The address, containing the login name and system name, directs the delivery of the mail message.

The write and wall commands
The ‘write’ command opens a line of communication to send messages to other users on the system in real time.
The ‘wall’ command writes a message to all users that are logged in.

Talk with another user
The ‘talk’ command is used to converse with another user. It allows two users on the same host or on different hosts to have an interactive conversation.

The clear, echo and banner commands
The ‘clear’ command clears the terminal screen.
The ‘echo’ command writes character strings to standard output.
The ‘banner’ command writes ASCII character strings in large letters to standard output.

The wc command
The ‘wc’ command counts the number of lines, words, bytes, or characters in a file.

Files and directories
What is a File?
A file is a collection of letters, numbers and special characters: it may be a program, a database, a dissertation, a reading list, a simple letter etc. Sometimes you may import a file from elsewhere, for example from another computer. If you want to enter your own text or data, you will start by creating a file.
Inodes
In AIX, each file system contains a superblock, inodes, and data blocks. Each file has an inode containing information such as file size and time of last modification. The inodes of small files also contain the addresses of all disk blocks that comprise the file data. A large file can use too many data blocks for an inode to directly address. In such a case, the inode points instead to one or more levels of indirect blocks that are deep enough to hold all of the data block addresses.
File system structure
A file system is a hierarchical structure (file tree) of files and directories. This type of structure resembles an inverted tree with the roots at the top and the branches at the bottom. This file tree uses directories to organize data and programs into groups, allowing the management of many directories and files at one time. The basic type of file system is called the Journaled File System (JFS). This file system uses database journaling techniques to maintain its structural consistency. This prevents damage to the file system when the system is halted abnormally.
Where am I?
In order to know which directory you are currently located in, you can run the command ‘pwd’ and it will display the full path where you are residing. The ‘pwd’ is the acronym for Present Working Directory.
Changing your current directory
The command used to change a directory from the existing one is ‘cd’. It sets the current working directory of a process.
Creating and removing directories
The directories can be created using the command ‘mkdir’ and can be removed using the command ‘rmdir’.
Listing directories
The command ‘ls -ld’ is used for listing the directories.
Long listing of files
The ‘ls -l’ command will give the long listing of the files.
The touch command
The ‘touch’ command updates the access and modification times of each file specified by the file parameter of each directory. If you specify a file that does not exist, the touch command creates the file.
File Permissions
Overview
The file permissions determine who can read and modify the information stored in your files. They are your primary method for protecting the data that you store on your system.
Changing Permissions using the Symbolic notation
To specify a mode in symbolic form, you must specify three sets of flags. The first set of flags specifies who is granted or denied the specified permissions, as: ‘u’ for File Owner, ‘g’ for Group pertaining to the file’s group and ‘o’ for All Others.
The second set of flags specifies whether the permissions are to be removed, applied, or set: ‘-‘ Removes specified permissions, ‘+’ Applies specified permissions, ‘=’ Clears the selected permission field and sets it to the permission specified.
The third set of flags specifies the permissions that are to be removed, applied, or set: ‘r’ for Read Permission, ‘w’ for Write Permission, ‘x’ for Execute Permission.
Changing Permissions using the Octal notation
The chmod command also permits you to use octal notation for the mode. The numeric mode is the sum of one or more of the following values:
4000: Sets user ID on execution, 2000: Sets group ID on execution, 1000: Sets the link permission to directories or sets the save-text attribute for files, 0400: Permits read by owner, 0200: Permits write by owner, 0100: Permits execute or search by owner, 0040: Permits read by group, 0020: Permits write by group, 0010: Permits execute or search by group, 0004: Permits read by others, 0002: Permits write by others and finally 0001: Permits execute or search by others.

The vi Editior
Starting the vi Editor
The Visual Editor (vi) is a screen editor that comes with the AIX operating system. The vi program is used to create and edit text files. When you edit a file, vi makes a copy of the file to a memory buffer. This way, if any unwanted changes are made, the original file is not destroyed. When your work is completeed, you must remeber to save the buffer which contains your changes. The visual editor has two modes of operation: text input mode and command mode. The vi editor can be executed by issuing the command vi <filename>. When editing a file, vi places a tilde (~) as the first character of lines past the end of your file. These lines are not part of your file, and are for display purposes only.
Adding text
The text can be added into a file by opening the file and pressing the ‘i’ key on the keyboard for inserting the text. You can use the ‘x’ key to delete an alphabet and ‘dd’ to remove a line. After adding the text, press the ‘Esc’ key and save the file.
Exiting the Editor
You can exit the editor either by saving the text or without saving the text. After pressing the ‘Esc’ key, you need to press ‘:’ followed by ‘wq!’ to save and exit or just ‘q!’ to exit without save.
Cursor Movement
There are over forty commands that can be used to move the cursor throughout the file. The basic keys used are ‘up’, ‘down’, ‘right’ and ‘left’ arrow keys on the keyboard to move the cursor to the required place.
Deleting text
In order to delete text, you need to take the cursor to the alphabet or word you want to delete and hit the ‘x’ key till the text is deleted. If you would like to delete the whole line, you can move to cursor to that line and press the key ‘d’ twice as ‘dd’. This will delete the whole line.
Searching for text pattern
To search a pattern in the vi screen, you open the file and click on the ‘/’ key. The ‘/’ is entered at the bottom of your screen, where you can add the word to search and hit enter. You can hit the ‘n’ key to search for the same word elsewhere is the file.
Shell Basics
The Shell
The shell is a command interpreter that allows an end user to type in commands to communicate to the AIX system. By default, when a user logins, a shell process is started. The default AIX shell is /usr/bin/ksh.
Metacharacters and Wildcards
Wildcard characters provide a convenient way to specify multiple file names or directory names. The wildcard characters are asterisk (*) and question mark (?).Use the * to match any sequence or string of characters. The ‘*’ means any characters, including no characters. For example, if you have the following files in your directory:
1test 2test afile1 afile2 bfile1 file file1 file10 file2 file3
and you want to refer to only to the files that begin with file, you would use:
file*
The files selected would be: file file1 file10 file2 file3
Use the ? to match any one character. The ? means any single character.
To refer to only the files that starts with file and end with a single character, use:
file?
The files selected would be: file1 file2 file3
The metacharacters are open and close square brackets ([ ]), hyphen (-), and exclamation mark (!). To refer to only the files that end in 1 or 2, use:
*file[12]
The files selected would be: afile1 afile2 file1 file2
To refer only to the files that start with any number, use:
[0123456789]* or [0-9]*
The files selected would be: 1test 2test
To refer only to the files that don't begin with an a, use:
[!a]*
The files selected would be: 1test 2test bfile1 file file1 file10 file2 file3
Character Substitution in file names
The shell performs file name substitution by scanning each command word specified by the Word variable for certain characters. If a command word includes the *), ? or [ characters, and the -f flag has not been set, the shell regards the word as a pattern. The shell replaces the word with file names, sorted according to the collating sequence in effect in the current locale, that match that pattern. If the shell does not find a file name to match the pattern, it does not change the word.
Input and Output Redirection
The AIX operating system allows you to manipulate the input and output (I/O) of data to and from your system by using specific I/O commands and symbols. You can control input by specifying the location from which to gather data. For example, you can specify to read input while data is entered on the keyboard (standard input) or to read input from a file. You can control output by specifying where to display or store data. You can specify to write output data to the screen (standard output) or to write it to a file. Because AIX is a multitasking operating system, it is designed to handle processes in combination with each other. There are different ways this can be performed. Few of them are listed below.
a. Standard input, standard output, and standard error files
b. Standard output redirection
c. Redirecting output to a file
d. Redirecting output to append to a file
e. Standard input redirection
f. Discarding output with the /dev/null file
g. Standard error and other output redirection
Creating file with cat
Type the command
# cat > name_of_file
Then, type in the required text and press enter to start a new line. When finished typing, enter Ctrl-d. This stops the cat command and returns you to the system prompt.
Pipes and Filters
You can connect two or more commands so that the standard output of one command is used as the standard input of another command. A set of commands connected this way is known as a pipeline. The connection that joins the commands is known as a pipe. Pipes are useful because they let you tie many single-purpose commands into one powerful command. You can direct the output from one command to become the input for another command using a pipeline. The commands are connected by a pipe (|) symbol.
When a command takes its input from another command, modifies it, and sends its results to standard output, it is known as a filter. Filters can be used alone, but they are especially useful in pipelines. The most common filters are sort, more and pg.

Processes
What is a process?
The process is the entity that the operating system uses to control the use of system resources. AIX introduces the use of threads to control processor-time consumption, but most of the system management tools still require the administrator to refer to the process in which a thread is running, rather than to the thread itself.
Some processes run from system boot to shutdown, but most processes come and go rapidly, as tasks start and complete. At times, a process can die a premature, say, due to a crash of a system or application or a particular task.
Parent and Child Processes
Each new process is the spawn of an existing process. Further, each new process, called a “child" process, is a clone of its "parent" process, at least for an instant, until the child continues execution independently.
Monitoring and Terminating Processes
A process can be monitored using the command ‘ps’. It gives the output with the ID associated to the process along with the time stamp and date when the process was started.
When a process terminates, by calling the exit subroutine either explicitly or implicitly, all threads within the process are terminated. Neither the cleanup handlers nor the thread-specific data destructors are called. The reason for this behavior is that there is no state to leave clean and no thread-specific storage to reclaim, because the whole process terminates, including all the threads, and all the process storage is reclaimed, including all thread-specific storage.
Daemons
A daemon  is  defined  to  be  a  process  that  is intended  to  run  “in  the  background” without  a  controlling  terminal. That  is,  the life  span  of  the  daemon  process  does not  depend  on  the  life  span  of  a  terminal session,  the  daemon  life  span  does  not depend  on  any  control  key  sequences generated  from  a  terminal  session,  and  a daemon  does  not  interact  with  users through  a  terminal. A  daemon  can  be  started by  the  init  process,  the System  Resource  Controller,  the  inetd  process,  or  a  shell.

AIX Utilities
System Management Interface Tool
The AIX System Management Interface Tool (SMIT) provides an alternative to the typical method of using complex command syntax, valid parameter values, and custom shell path names for managing and maintaining your operating system configuration. SMIT offers the following features:
a. Two modes of operation
b. An interactive, menu-driven user interface
c. User assistance
d. System management activity logging
e. Fast paths to system management tasks
f. User-added SMIT screens

The find command
The find command recursively searches the directory tree for each specified Path parameter, seeking files that match a Boolean expression written using the terms given in the following text. When the find command is recursively descending directory structures, it will not descend into directories that are symbolically linked into the current hierarchy. The output from the find command depends on the terms specified by the Expression parameter.
The grep command
The grep command search for the pattern specified by the Pattern parameter and then writes each matching line to standard output. The grep command uses a compact non-deterministic algorithm. The grep command displays the name of the file containing the matched line if you specify more than one name in the File parameter. Characters with special meaning to the shell ($, *, [, |, ^, (, ), \ ) must be in quotation marks when they appear in the Pattern parameter. When the Pattern parameter is not a simple string, you usually must enclose the entire pattern in single quotation marks. In an expression such as [a-z], the - (minus sign) cml specifies a range, according to the current collating sequence. A collating sequence may define equivalence classes for use in character ranges.

The sort command
The sort command sorts lines in the files specified by the File parameter and writes the result to standard output. If the File parameter specifies more than one file, the sort

command concatenates the files and sorts them as one file. A - (minus sign) in place of a file name specifies standard input. If you do not specify any file names, the command sorts standard input. An output file can be specified with the -o flag. If no flags are specified, the sort command sorts entire lines of the input file based upon the collation order of the current locale.

The xargs command
The xargs command constructs parameter lists and runs commands. The xargs command limits the command line length.

The which and whereis commands
The which command takes a list of program names and looks for the files that run when these names are given as commands. The which command expands each argument, if it is aliased, and searches for it along the user's path.
The whereis command locates the source, binary, and manuals sections for specified files.
The file command
The file command reads the files specified by the File parameter or the FileList variable, performs a series of tests on each file, and attempts to classify them by type. The command then writes the file types to standard output. The file can be regular file, directory, FIFO(named pipe), block special, character special, symbolic link or sockets type.
Comparing files using diff and cmp
The diff command compares text files. It can compare single files or the contents of directories. The diff command only works with input files that are text files. If the Directory1 and Directory2 parameters are specified, the diff command compares the text files that have the same name in both directories. Binary files that differ, common subdirectories, and files that appear in only one directory are listed. When the diff command is run on regular files, and when comparing text files that differ during directory comparison, the diff command tells what lines must be changed in the files to make them agree. If neither the File1 nor File2 parameter is a directory, then either may be given as - (minus sign), in which case the standard input is used. If the File1 parameter is a directory, then a file in that directory whose file name is the same as the File2 parameter is used.
The cmp command compares files designated by the File1 and File2 parameters and writes the results to standard output. If you specify a - (minus sign) for either the File1
or File2 parameter, the cmp command reads standard input for that file. Only one file can be read from standard input. Under default conditions, the cmp command displays nothing if the files are the same. If they differ, the cmp command displays the byte and line number at which the first difference occurs.



AIX Documentation
The man command
The man command provides reference information on topics, such as commands, subroutines, and files. The man command provides one-line descriptions of commands specified by name. The man command also provides information on all commands whose descriptions contain a set of user-specified keywords. The man command formats a specified set of manual pages. If you specify a section for the Section parameter, the man command searches in that section of the manual pages for the title specified by the Title parameter. The value of the Section parameter can be either an Arabic number from 1 through 8 or a letter.
AIX Web-based documentation
You can go to www.ibm.com site and browse for different options there. Below are few important sites where we can get help.
http://publib16.boulder.ibm.com/cgi-bin/ds_rslt#1  à Documentation Library
http://www.redbooks.ibm.com/ à for various Red Books
http://www14.software.ibm.com/webapp/set2/sas/f/genunix3/aixfixes.html à to download fixes.
http://www14.software.ibm.com/webapp/set2/srchBroker/views/srchBroker.jsp?rs=111 à Technical Help Database.



Appendix A: General Commands used on daily basis.
This section gives an over of some general AIX commands that are used on a daily basis by an AIX System Administrator.
General Commands
AIX
Unique host ID
hostid                                hostname                           uname -a
Administrator
smit
Performance monitor
top
monitor
System activity reporter
sar
Virtual Memory statistics
vmstat
I/O statistics
iostat
Error logs
alog -o -t boot
errpt
Display swap size
lsps -a
Activate Swap
swapon -a

Appendix B: Printer Commands
Printers
AIX
Printer Queues
/etc/qconfig
Stop LP
stopsrc -s lpd
Start LP
startsrc -s lpd
Submit print jobs
enq
lp
lpr
qprt
LP statistics
enq -A
lpq
lpstat
qchk
Remove print jobs
cancel
lprm
qcan
enq -x
Add printer queue
smit mkpq
Remove Printer queue
smit rmpq
Make default printer
export LPDEST="pq"

Appendix C: Network Commands
Network
AIX
Network IP configuration
lsattr -E -l inet0
Hosts IP addresses
/etc/hosts
Name service switch
/etc/netsvc.conf
Network parameters
no -a
Appendix D: LVM Commands
LVM
AIX
Filesystem table
/etc/filesystems
Free disk blocks
df -k
Device listing
lsdev -C
Disk information
bootinfo -s hdisk#
Disk Label
lspv -l hdisk#
Display volume group
lsvg -l rootvg
Modify physical volume
chpv
Prepare physical disk
mkdev -c disk -l hdisk#
List physical volume
lspv
Remove disk from volume group
reducevg
Move logical volumes to another physical volumes
migratepv
Create volume group
mkvg
Remove volume group
Volume group availability
chvg
varyonvg
varyoffvg
Restore volume group
Exports volume group
exportvg
Imports volume group
importvg
Volume group listing
lsvg
Change logical volume characteristics
chlv
List logical volume
lslv
Make logical volume
mklv
Extend logical volume
extendlv
Remove logical volume
rmlv
Prepare boot volumes
bootlist -m normal
Operating System Backup
mksysb -i /dev/rmt0
Backup
savevg -i rootvg
Restore
restvg
Kernel Parameters
lsattr -E -l sys0
Physical RAM
bootinfo -r
Kernel Bits
bootinfo -K
Crash utility
crash
Machine model
uname -m
bootinfo -m
OS Level
oslevel
Run Level
who -r
Core dump files
/var/adm/ras
NTP Daemon
/etc/ntp.conf
startsrc -s xntpd


Appendix E: Software related commands
Software
AIX
Install Software
installp -a
Uninstall software
installp -u
List installed software
lslpp -L all
Verify installed software
lppchk -v
List all files
lslpp -f fileset
List installed patches
instfix -i
Package owner
lslpp -w path
SW Directory
/usr/lpp


Appendix F: Devices Commands
Devices
AIX
Install devices for attached peripherals
cfgmgr -v
Remove device
rmdev -l
Device drivers
lscfg
CPU
lsdev -Cc processor
List Terminal
lsdev -Cc tty
Diagnostics
diag



Incoming Search Terms:
AIX basics
AIX prerequisite
AIX basic commands
AIX basic system administration
AIX fundamentals

No comments:

Post a Comment