Home » Posts filed under AIX
Showing posts with label AIX. Show all posts
Showing posts with label AIX. Show all posts
3 September 2013
How to redirect a commands output to a seperate file in AIX Operating System
The output of a process can be redirected to a file by typing the command followed by the output redirection operator and file name.
For example, to redirect the results of the who command to a file named users, type the following:
who > users
Note: If the users file already exists, it is deleted and replaced, unless the noclobber option of the set built-in ksh (Korn shell) or csh (C shell) command is specified.
To see the contents of the users file, type the following:
cat users
A list similar to the following is displayed:
denise lft/0 May 13 08:05
marta pts/1 May 13 08:10
endrica pts/2 May 13 09:33
When the notation >> filename is added to the end of a command, the output of the command is appended to the specified file name, rather than writing over any existing data. The >> symbol is known as the append redirection operator.
For example, to append file2 to file1, type the following:
cat file2 >> file1
Note: If the file1 file does not exist, it is created, unless the noclobber option of the set built-in ksh (Korn shell) or csh (C shell) command is specified.
The tee command, used with a pipe, reads standard input, then writes the output of a program to standard output and simultaneously copies it into the specified file or files. Use the tee command to view your output immediately and at the same time, store it for future use.
For example, type the following:
ps -ef | tee program.ps
This displays the standard output of the ps -ef command on the display device, and at the same time, saves a copy of it in the program.ps file. If the program.ps file already exists, it is deleted and replaced unless the noclobber option of the set built-in command is specified.
For example, to view and save the output from a command to an existing file:
ls -l | tee -a program.ls
This displays the standard output of ls -l at the display device and at the same time appends a copy of it to the end of the program.ls file.
The system displays information similar to the following, and the program.ls file contains the same information:
-rw-rw-rw- 1 jones staff 2301 Sep 19 08:53 161414
-rw-rw-rw- 1 jones staff 6317 Aug 31 13:17 def.rpt
-rw-rw-rw- 1 jones staff 5550 Sep 10 14:13 try.doc
Use the capture command, which emulates a VT100 terminal, to copy everything printed on your terminal to a file that you specify. Use the script command to copy everything printed on your terminal to a file that you specify, without emulating a VT100 terminal.
Both commands are useful for printing records of terminal dialogs. For example, to capture the screen of a terminal while emulating a VT100, at the prompt, type the following:
capture screen.01
The system displays information similar to the following:
Capture command is started. The file is screen.01.
Use ^P to dump screen to file screen.01.
You are now emulating a vt100 terminal.
Press Any Key to continue.
After entering data and dumping the screen contents, stop the capture command by pressing Ctrl-D or typing exit and pressing Enter. The system displays information similar to the following:
Capture command is complete. The file is screen.01.
You are NO LONGER emulating a vt100 terminal.
Use the cat command to display the contents of your file.
For example, to capture the screen of a terminal, at the prompt, type the following:
script
The system displays information similar to the following:
Script command is started. The file is typescript.
Everything displayed on the screen is now copied to the typescript file.
To stop the script command, press Ctrl-D or type exit and press Enter. The system displays information similar to the following:
Script command is complete. The file is typescript.
Use the cat command to display the contents of your file.
In addition to the standard input and standard output, commands often produce other types of output, such as error or status messages known as diagnostic output. Like standard output, standard error output is written to the screen unless it is redirected.
To redirect standard error or other output, use a file descriptor. A file descriptor is a number associated with each of the I/O files that a command ordinarily uses. File descriptors can also be specified to redirect standard input and standard output, but are already the default values. The following numbers are associated with standard input, output, and error:
0 Standard input (keyboard)
1 Standard output (display)
2 Standard error (display)
To redirect standard error output, type the file descriptor number 2 in front of the output or append redirection symbols (> or > >) and a file name after the symbol. For example, the following command takes the standard error output from the cc command where it is used to compile the testfile.c file and appends it to the end of the ERRORS file:
cc testfile.c 2 >> ERRORS
Other types of output can also be redirected using the file descriptors from 0 through 9. For example, if the cmd command writes output to file descriptor 9, you can redirect that output to the savedata file with the following command:
cmd 9> savedata
If a command writes to more than one output, you can independently redirect each one. Suppose that a command directs its standard output to file descriptor 1, directs its standard error output to file descriptor 2, and builds a data file on file descriptor 9. The following command line redirects each of these outputs to a different file:
command > standard 2> error 9> data
How to find the Access Control List (ACL) settings information for a file in AIX
aclget command displays the access control list settings information of any file in AIX.
Access Control Lists (ACL)
Access Control Lists form the core of protection of file system objects. Each file system object is uniquely associated with one piece of data, called ACL, that defines the access rights to the object. ACL could consist of multiple Access Control Entries (ACEs), each defining one particular set of access rights for a user. Typically ACE consists of information such as identification (to whom this ACE applies) and access rights (allow-read, deny-write). Note that ACE might also capture information such as inheritance flags and alarm and audit flags. The format and enforcement of ACL data is entirely dependent on the ACL type in which they are defined. AIX provides for the existence of multiple ACL types on the operating systems. The list of ACLs supported by a file system instance is dependent on the physical file system implementation for that file system instance.
Description
The aclget command writes the access control information of the file specified by the FileObject parameter to standard output or to the file specified by the OutAclFile parameter.
The information that you view depends on the ACL type and typically includes the Access Control Entries (ACEs) depicting the access rights of the users in the system, including the owner of the file object.
Syntax
aclget [ -o OutAclFile ] [ -v ]FileObject
Flags
-o OutAclFile Specifies that the access control information be written to the file specified by the OutFile parameter.
-v Displays the ACL information in Verbose mode. Comment lines will be added to explain more details about the ACL associated with the FS object. These comment lines are generated when the command is executed and do not reside anywhere persistently.
Examples
- To display the access control information for the status file, enter:
aclget status
An access control list appears, similar to the example in Access Control Lists. - To copy the access control information of the plans file to the status file, enter:
aclget plans | aclput status
This copies the access control information. In most cases, the ACL type associated with plans will be the ACL type of ACL associated with the target status. However, it is possible that the target file system does not support the ACL type associated with file system object plans. In this case, the operation will fail and an error message is displayed. The target will retain its original associated ACL. - To save the access control information of the plans file in the acl1 file to edit and use later, enter:aclget -o acl1 plans
How to change permissions and ownership of files and directories in AIX
CHOWN command - used to change the ownership of any files and directories.
CHMOD command - used to change the permissions of any files and directories.
These commands can also be used to change sub-directories ownership & permissions with single command.
Chown
Syntax
chown [ -f ] [ -h ] [ -R ] Owner [ :Group ] { File ... | Directory ... }
chown -R [ -f ] [ -H | -L | -P ] Owner [ :Group ] { File ... | Directory ... }
Description
The chown command changes the owner of the file or directory specified by the File or Directory parameter to the user specified by the Owner parameter. The value of the Owner parameter can be a user name from the user database or a numeric user ID. Optionally, a group can also be specified. The value of the Group parameter can be a group name from the group database or a numeric group ID.
Only the root user can change the owner of a file. You can change the group of a file only if you are a root user or if you own the file. If you own the file but are not a root user, you can change the group only to a group of which you are a member.
Examples
- To change the owner of the directory softwares to TOM:
chown TOM softwares
- To change the owner and group of all files in the directory /tmp/tsm to owner TOM and group build:
chown -R TOM:tsmgroup /tmp/tsm
ChmodDescription
The chmod command modifies the mode bits and the extended access control lists (ACLs) of the specified files or directories. The mode can be defined symbolically or numerically (absolute mode).
When a symbolic link is encountered and you have not specified the -h flag, the chmod command changes the mode of the file or directory pointed to by the link and not the mode of the link itself. If you specify the -h flag, the chmod command prevents this mode change.
If you specify both the -h flag and the -R flag, the chmod command descends the specified directories recursively, and when a symbolic link is encountered, the mode of the file or directory pointed to by the link is not changed.
Syntax |
To Change File Modes Symbolically
chmod [ -R ] [ -h ] [ -f ] [ [ u ] [ g ] [ o ] | [ a ] ] { { - | + | = } [ r ] [ w ] [ x ] [ X ] [ s ] [ t ] } { File ... | Directory ... }
To Change File Modes Numerically
chmod [ -R ] [ -h ] [ -f ] PermissionCode { File ... | Directory ... }
27 August 2013
Most important and frequently used IBM AIX commands
Below are the Important & Frequently used commands used by most of the AIX Administrators
ls Lists files in current directorycd change directory
mkdir to make a directory
rmdir to remove directory
cp to copy a file
rm to remove a a file
mv to rename a file
more to check the file page wise
tail to check the bottom lines of a file
head to check the top lines of a file
grep to find particular format of words or format
chmod to change the file permissions
kill to kill a process and to stop the process
who to check who are logged in currently
finger to show who all are logged in
history to show you the commmands run previously
df -gt to list the disk free space in Gigs
exit to logout frm the aix or Unix machine
topas to check the utilisation of CPU,process which is using most resources and also the I\O onDisk
ifconfig -a to show you all the ipaddressess of htat server
errpt to check the errorlog of AIX for both software and hardware
nslookup to find out server name frm ip address and vice versa
cfgmgr To check n update the database and list the hardware
lsdev -cc tape To check all the tapes drives
lslpp -L all List all the softwares that are installed
lslpp -L <software name> To Check if the software installed
lslpp -f Lists all the file sets and packages
lslpp -ha To list the history of files that have been installed
hostname to get the hostname of the host you hav logged in
ifconfig -device name to list the network card setting for that particular card
ifconfig devicename UP/DOWN To change the status of the Nic card v r refering
ifconfig devicename DETACH To remove the Nic frm the list of Nic interfaces
route -ADD/DELETE -NET/HOST Destination Gateway to add a route between the source and Destination.
lsattr -EHI inet0 displays the route listed in odm database
odmget -q "name=inet0" xyz Gives u the list of the details in the ODM database about the ROUTE which is in ODM Database
uname -a to show the flavour of unix,version and serial number of themachine
lsattr -EHI inet0 displays the route listed in odm database
lscfg -vl rmtname how to find the serial number of a drive
lscfg -vl fcs0 or 1 or 2 to get the wwpn name of the FC
lscfg to list all the devices
lscfg -v verbose for all the devices
rmdev -l devicename -d to delete it
lsattr -l devicename -E how to get the WWN number of a drive
mkdev -l devicename to change the defined device to available
prtconf to show all the info abt the hardware of the system
bootinfo -b will tel u frm where the server has botted up
bootinfo -r tell you the real memory
bootinfo -T tell you the machine type
ping to check the remote machine is alive or not
2 May 2013
Basic Networking and Performance Monitoring Commands used in AIX Operating System
AIX Networking Commands
1) How can I display or set values for network parameters?
The
no
command sets or displays current or next boot values for network tuning parameters.
2) How do I get the IP address of my machine?
Type one of the following:
ifconfig -a
host Fully_Qualified_Host_Name
|
For example, type host cyclop.austin.ibm.com.
3) How do I identify the network interfaces on my server?
Either of the following two commands will display the network interfaces:
lsdev -Cc if
|
ifconfig -a
|
To get information about one specific network interface, for example, tr0, run the command:
ifconfig tr0
|
4) How do I activate a network interface?
To activate the network interface tr0, run the command:
ifconfig tr0 up
|
5) How do I deactivate a network interface?
For example, to deactivate the network interface tr0, run the command:
ifconfig tr0 down
|
6) How do I display routing table, interface, and protocol information?
To display routing table information for an Internet interface, type:
netstat -r -f inet
|
To display interface information for an Internet interface, type:
netstat -i -f inet
|
To display statistics for each protocol, type:
netstat -s -f inet
|
7) How do I record packets received or transmitted?
To record packets coming in and going out to any host on every interface, enter:
iptrace /tmp/nettrace
|
The trace information is placed into the /tmp/nettrace file.
To record packets received on an interface en0 from a remote host airmail over the telnet port, enter:
iptrace -i en0 -p telnet -s airmail /tmp/telnet.trace
|
The trace information is placed into the /tmp/telnet.trace file.
AIX Workload partitions commands
1) How do I create a workload partition?
To create a workload partition named temp with the IP Address xxx.yyy.zzz.nnn, type:
mkwpar -n temp -N address= xxx.yyy.zzz.nnn
|
To create a workload partition with the specification file wpar1.spec, type:
mkwpar -f /tmp/wpar1.spec
|
2) How do I create a new specification file for an existing workload partition
wpar1?
To create a specification file wpar2.spec for an existing workload partition wpar1,
type:
mkwpar -e wpar1 -o /tmp/wpar2.spec -w
|
3) How do I start a workload partition?
To start the workload partition called temp, type:
startwpar temp
|
4) How do I stop a workload partition?
To stop the workload partition called temp, type:
stopwpar temp
|
5) How do I view the characteristics of workload partitions?
To view the characteristics of all workload partitions, type:
lswpar
Name State Type Hostname Directory
---------------------------------------------------------------------------------
bar A S bar.austin.ibm.com /wpars/bar
foo D S foo.austin.ibm.com /wpars/foo
trigger A A trigger /
|
6) How do I log in to a workload partition?
To log in to the workload partition named wpar1 as user foo, type:
clogin wpar1 -l foo
|
7) How do I run a command in a workload partition?
To run the /usr/bin/ps command as user root in a workload partition named howdy,
type:
clogin howdy -l root /usr/bin/ps
|
8) How do I remove a workload partition?
To remove the workload partition called temp, type:
rmwpar temp
|
To stop and remove the workload partition called temp preserving data on its file
system, type:
rmwpar -p -s temp
|
Note:
Workload Partitions (WPARs), a set of completely new software-based system virtualization
features, were introduced in IBM AIX Version 6.1.
AIX Performance monitoring tools
1) How do I display virtual memory statistics?
To display a summary of the virtual memory statistics since boot, type:
vmstat
|
To display five summaries at 2-second intervals, type:
vmstat 2 5
|
To display a summary of the statistics for all of the workload partitions after boot,
type:
vmstat -@ ALL
|
To display all of the virtual memory statistics available for all of the workload
partitions, type:
vmstat -vs -@ ALL
|
2) How do I display statistics for all TTY, CPU, and Disks?
To display a single set of statistics for all TTY, CPU, and Disks since boot, type:
iostat
|
To display a continuous disk report at 2-second intervals for the disk with the logical
name disk1, type:
iostat -d disk1 2
|
To display 6 reports at 2-second intervals for the disk with the logical name disk1,
type:
iostat disk1 2 6
|
To display 6 reports at 2-second intervals for all disks, type:
iostat -d 2 6
|
To display only file system statistics for all workload partitions, type:
iostat -F -@ ALL
|
To display system throughput of all workload partitions along with the system, type:
iostat -s -@ ALL
|
3) How do I display detailed local and remote system statistics?
Type the following command:
topas
|
To go directly to the process display, enter:
topas -P
|
To go directly to the logical partition display, enter:
topas -L
|
To go directly to the disk metric display, enter:
topas -D
|
To go directly to the file system display, enter:
topas -F
|
4) How do I report system unit activity?
Type the following command:
sar
|
To report processor activity for the first two processors, enter:
sar -u -P 0,1
|
This produces output similar to the following:
cpu %usr %sys %wio %idle
0 45 45 5 5
1 27 65 3 5
|