Wednesday, March 31, 2010

AIX commands that everyone needs

Kernel Command:

How to know if you are running a 32-bit kernel or 64-bit kernel?

To display the info at the unix prompt type:

$ bootinfo -K


Hardware Commands:

How much real memory does a unix server have?

$ bootinfo -r

$ lsattr -El sys0 -a realmem

The above commands display memory info in KB.

How to list attributes of various devices on your system?

To list current values of the attributes for tape device, rmt0 type:

$ lsattr -l rmt0 -E

To list default values of the attributes for tape device, rmt0 type:

$ lsattr -l rmt0 -D

To display system level attributes type:

$ lsattr -E -l sys0

To display processors info on a unix system type:

$ lscfg | grep proc

To display hard disks information and how many of them are in use type:

$ lspv

To list information about a specific physical volume ex: hdisk1 type:

$ lspv hdisk1

To get a detail configuration of a unix system type:

$ lscfg

The following options provide specific information:

-p: Displays platform-specific device information. The flag is applicable to AIX 4.2.1 or later.
-v: Displays the VPD (Vital Product Database) found in the customized VPD object class.

For example, to display details about the tape drive, rmt0, type:

$ lscfg -vl rmt0

You can obtain similar information using prtconf command.


To find out about chip type, system name, node name, model number and etc use uname command with various options to get details about unix system. Some example are listed below:

uname -p : Displays the chip type of the system. For example, PowerPC.
uname -r : Displays the release number of the operating system.
uname -s : Displays the system name. For example, AIX.
uname -n : Displays the name of the node.
uname -a : Displays the system name, nodename, version, machine ID.
uname -M : Displays the system model name. For example, IBM, 9114-275.
uname -v : Displays the operating system version.
uname -m : Displays the machine ID number of the hardware running the system.
uname -u : Displays the system ID number.

Some commands related to AIX:

To display version, release and maintenance level of AIX running on your system type:

$ oslevel -r
(or)
$ lslpp -h bos.rte

To see information about what service pack is installed on your system type:

$ oslevel -s

To create a file system:
The below command will create, within volume group testvg, a jfs filesystem of 10MB with mount point /fs1:

$ crfs -v jfs -g testvg -a size=10M -m /fs1

The below command will create, within volume group testvg, a jfs2 filesystem of 10MB with mount point /fs2 having read only permissions:

$ crfs -v jfs2 -g testvg -a size=10M -p ro -m /fs2 Note: In AIX 5.3 this jfs2 file system can be shrunk as well.

To change the size of a file system: Ex: To increase /usr file system by 1000000 512-byte blocks type:

$ chfs -a size=+1000000 /usr

To mount a CD:

$ mount -V cdrfs -o ro /dev/cd0 /cdrom

To mount a file system:

$ mount /dev/fslv02 /test

To mount all default file systems (all standard file systems in the /etc/filesystems file marked by the mount=true attribute):

$ mount {-a|all}

To unmount a file system: Ex: To unmount /test file system

$ unmount /test

To display mounted file systems:

$ mount

To remove a file system: Ex: To remove /test file system

$ rmfs /test

To defrag a file system:

$ defragfs /home

To get installed filesets information:

$ lslpp -l

To determince of all required maintenance level file systems are installed:

$ instfix -i | grep ML

To determince if a particular fix is installed on a file system:

$ instfix -ik IY24043

To determince if filesets have required pre-requisites and are completely installed:

$ lppchk -v

To determince amount of paging space allocated and in use:

$ lsps -a

Volume groups and logical volumes:

To create a volume group:

$ mkvg -y name_of_volume_group -s partition_size list_of_hard_disks

To change characteristics of a volume group

$ chvg

To create a logical volume:

$ mklv -y name_of_logical_volume name_of_volume_group number_of_partition

To increase the size of a logical volume:

$ extendlv lv05 3

To display all logical volumes that are part of a volume group: Ex: rootvg

$ lsvg -l rootvg

To list information about a logical volume:

$ lslv lv1

To remove a logical volume:

$ rmlv lv7

To show volume groups in the system, type:

$ lsvg

To show all the characteristics of rootvg, type:

$ lsvg rootvg

To show disks used by rootvg, type:

$ lsvg -p rootvg

Network Commands:

To get the IP address of a system:

$ ifconfig -a

To identify the network interfaces of a system:

$ lsdev -Cc if
(or)
$ ifconfig -a

To get information about a specific network interface ex: tr0:

$ ifconfig tr0

To activate network interface in a system: Ex: tr0

$ ifconfig tr0 up

To deactivate network interface in a system: Ex: tr0

$ ifconfig tr0 down

Process Commands:

To get information on what OS processes are running type:

$ ps -ef | grep

To get information about particular OS level processes type for example about all oracle processes:

$ ps -ef | grep ora

File System commands:

To get information about your current working directory:

$ pwd

To create a file in your current directory for example test type:

$ touch test

To change permissions on a file chmod is the command to be used:

$ chmod 777 test

The above command gives read, write and execute permissions to all users in the system.

To get more on chmod permission codes based on need check:
http://mistupid.com/internet/chmod.htm

To rename a file without creating a duplicate copy of file test:

$ mv test test.sh
The above command renames "test" file to "test.sh"

To rename a file and make a duplicate copy of the original file test:

$ cp test test.sh
The above command renames "test" file to "test.sh" as a duplicate copy to original file "test"

To compress a file:

$ compress test

To copy and compress a file at the same time:

$ gzip < /path/to/file1 > /path/to/file1.gz

To copy and uncompress a file at the same time:

$ gunzip < /path/to/file1.gz > /path/to/file1

To copy and compress a folder at the same time:

$ tar cf - | gzip -c - > /.tar.gz

To uncompress a folder: cd to the directory you want the files extracted in and run:

$ gunzip -c /.tar.gz | tar xf -

No comments: