System Activity Information: sar
To use sar, sadc (system activity data collector) needs to be running. Check its status or start it with rcsysstat {start|status}.
sar can generate extensive reports on almost all important system activities, among them CPU, memory, IRQ usage, IO, or networking. With its many options, it is too complex to explain further here. Refer to the man page for extensive documentation with examples.
Memory Usage: free
The utility free examines RAM usage. Details of both free and used memory and swap areas are shown:
poison:~ # free
total used free shared buffers cached
Mem: 450128 398428 51700 0 10280 141204
-/+ buffers/cache: 246944 203184
Swap: 514040 182656 331384
The options -b,-k,-m,-g show output in bytes, KB, MB, or GB, respectively
User Accessing Files: fuser
It can be useful to determine what processes or users are currently accessing certain files. Suppose, for example, you want to unmount a file system mounted at /mnt. umount returns “device is busy.” The command fuser can then be used to determine what processes are accessing the device:
poison:~ # fuser -v /home/nikesh/
USER PID ACCESS COMMAND
/home/nikesh/: nikesh 5476 ..c.. su
Kernel Ring Buffer: dmesg
poison:~ # dmesg | more
Linux version 2.6.18.2-34-default (geeko@buildhost) (gcc version 4.1.2 20061115 (prerelease) (SUSE Linux)) #1 SMP Mon Nov 27
11:46:27 UTC 2006
BIOS-provided physical RAM map:
BIOS-e820: 0000000000000000 - 000000000009f400 (usable)
BIOS-e820: 000000000009f400 - 00000000000a0000 (reserved)
BIOS-e820: 00000000000f0000 - 0000000000100000 (reserved)
BIOS-e820: 0000000000100000 - 000000001bef0000 (usable)
BIOS-e820: 000000001bef0000 - 000000001bef3000 (ACPI NVS)
BIOS-e820: 000000001bef3000 - 000000001bf00000 (ACPI data)
BIOS-e820: 00000000e0000000 - 00000000f0000000 (reserved)
BIOS-e820: 00000000fec00000 - 0000000100000000 (reserved)
0MB HIGHMEM available.
446MB LOWMEM available.
found SMP MP-table at 000f5e30
On node 0 totalpages: 114416
DMA zone: 4096 pages, LIFO batch:0
Normal zone: 110320 pages, LIFO batch:31
DMI 2.3 present
…………………
List of Open Files: lsof.
To view a list of all the files open for the process with process ID PID, use -p. For example, to view all the files used by the current shell, enter:
poison:~ # lsof -p $$
COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME
bash 4700 root cwd DIR 3,6 4096 1811521 /root
bash 4700 root rtd DIR 3,6 4096 2 /
bash 4700 root txt REG 3,6 557704 913931 /bin/bash
bash 4700 root mem REG 3,6 131115 2139537 /lib/ld-2.5.so
bash 4700 root mem REG 0,0 0 [heap] (stat: No such file or directory)
bash 4700 root mem REG 3,6 42546 2137956 /lib/libnss_files-2.5.so
bash 4700 root mem REG 3,6 238464 344723 /usr/lib/locale/en_US.utf8/LC_CTYPE
bash 4700 root mem REG 3,6 1494633 2140298 /lib/libc-2.5.so
bash 4700 root mem REG 3,6 16082 2140299 /lib/libdl-2.5.so
bash 4700 root mem REG 3,6 294652 2140313 /lib/libncurses.so.5.5
bash 4700 root mem REG 3,6 28088 2140319 /lib/libhistory.so.5.1
bash 4700 root mem REG 3,6 192840 2140316 /lib/libreadline.so.5.1
bash 4700 root mem REG 3,6 42325 2137960 /lib/libnss_nis-2.5.so
bash 4700 root mem REG 3,6 95913 2140304 /lib/libnsl-2.5.so
bash 4700 root mem REG 3,6 32135 2137952 /lib/libnss_compat-2.5.so
bash 4700 root mem REG 3,6 25460 329733 /usr/lib/gconv/gconv-modules.cache
bash 4700 root 0u CHR 136,4 6 /dev/pts/4
bash 4700 root 1u CHR 136,4 6 /dev/pts/4
bash 4700 root 2u CHR 136,4 6 /dev/pts/4
bash 4700 root 255u CHR 136,4 6 /dev/pts/4
Interprocess Communication: ipcs
The command ipcs produces a list of the IPC resources currently in use:
poison:~ # ipcs
—— Shared Memory Segments ——–
key shmid owner perms bytes nattch status
0×00000000 98304 root 600 33554432 7 dest
0×00000000 32769 root 666 66136 2 dest
0×00000000 524290 root 600 393216 2 dest
0×00000000 557059 root 600 393216 2 dest
0×00000000 589828 root 600 393216 2 dest
0×00000000 622597 root 600 393216 2 dest
0×00000000 786438 root 666 131040 1 dest
—— Semaphore Arrays ——–
key semid owner perms nsems
0×00000000 65536 wwwrun 600 1
0×00000000 98305 wwwrun 600 1
—— Message Queues ——–
key msqid owner perms used-bytes messages
Process Tree: pstree
The command pstree produces a list of processes in the form of a tree:
Processes: top
The command top, which stands for “table of processes,” displays a list of processes that is refreshed every two seconds. To terminate the program, press Q. The parameter -n 1 terminates the program after a single display of the process list. The following is an example output of the command top -n 1:
Who Is Doing What: w
With the command w, find out who is logged onto the system and what each user is doing. For example:
poison:~ # w
00:32:58 up 33 min, 8 users, load average: 1.71, 1.35, 0.82
USER TTY LOGIN@ IDLE JCPU PCPU WHAT
root :0 00:00 ?xdm? 2:06 0.21s /bin/sh /usr/bin/kde
root pts/0 00:00 32:03 0.00s 1.17s kded –new-startup
root pts/1 00:01 31:48 0.14s 0.13s wvdial
root pts/2 00:01 31:18 0.08s 0.04s tail -f access.log
root pts/3 00:01 20:04 2.55s 0.03s /bin/bash
root pts/4 00:01 1.00s 0.07s 0.00s w
root pts/5 00:01 8:36 0.08s 0.06s -bash
root pts/6 00:01 31:33 0.03s 0.03s /bin/bash
source:http://linuxpoison.blogspot.com/2008/01/13578175809862.html