Thursday, March 3, 2011

List of Imp unix commands


I am trying to list all the important administrative commands here from system point of view :

= Show working directory of the process
pwdx PROCESS_ID

= display the current open file of process
pfiles PROCESS_ID

= Display inter process communication status
ipcs
output :

bash-3.00$ ipcs
IPC status from as of Thu Mar 3 23:56:08 EST 2011
T ID KEY MODE OWNER GROUP
Message Queues:
Shared Memory:
Semaphores:

= List all the processes sorted by CPU usages
top
Explanation : The command shows all the processes sorted by CPU utilization level. Also displays load average, number of processes in different states ( sleeping, zombie, stopped, running 1 ). It updates screen after fix delay ( i think its 1 second ). Also displays level of cpu and memory utilization. i.e. real, free, swap in use.

bash-3.00$ top
load averages: 0.09, 0.11, 0.13 23:59:57
238 processes: 231 sleeping, 6 stopped, 1 on cpu
CPU states: % idle, % user, % kernel, % iowait, % swap
Memory: 2048M real, 922M free, 807M swap in use, 32G swap free

PID USERNAME THR PRI NICE SIZE RES STATE TIME CPU COMMAND
6431 www 3 39 5 8912K 4192K sleep 0:00 0.30% httpd
511 odyssey 18 43 5 0K 0K sleep 0:35 0.26% java
5114 k35patel 1 40 0 3144K 2496K sleep 0:00 0.21% bash
6523 k35patel 1 40 0 1920K 1296K cpu/0 0:00 0.14% top
5919 www 3 33 5 8920K 4280K sleep 0:00 0.07% httpd
5871 www 3 29 5 8960K 4280K sleep 0:00 0.07% httpd
5604 www 3 33 5 9016K 5192K sleep 0:00 0.06% httpd
15650 ikotsire 1 48 0 3648K 3216K sleep 0:00 0.06% tcsh
5082 k35patel 1 58 0 7944K 2696K sleep 0:00 0.06% sshd
6348 www 3 33 5 8944K 4232K sleep 0:00 0.05% httpd
5918 www 3 43 5 8944K 4464K sleep 0:00 0.05% httpd
6427 www 3 29 5 8936K 4216K sleep 0:00 0.05% httpd
5576 www 3 29 5 9040K 5384K sleep 0:00 0.04% httpd
5917 www 3 41 5 8976K 4544K sleep 0:00 0.04% httpd
5916 www 3 40 5 8968K 4504K sleep 0:00 0.03% httpd
6347 www 3 33 5 8944K 4224K sleep 0:00 0.03% httpd
68 root 7 42 0 3744K 2424K sleep 290:43 0.02% picld

Alternative of top command would be "prstat -a"

= How to check what is the page size of the memory?
pagesize

= display the network statistic using simple command.
netstat -a or netstat
So protocol, local to remote address connection is shown. State is also seen.

output would look like :
C:\Windows\system32>netstat

Active Connections

Proto Local Address Foreign Address State
TCP 127.0.0.1:895 kush-PC:6751 ESTABLISHED
TCP 127.0.0.1:1036 kush-PC:27015 ESTABLISHED
TCP 127.0.0.1:4488 kush-PC:4489 ESTABLISHED
TCP 127.0.0.1:4489 kush-PC:4488 ESTABLISHED
TCP 127.0.0.1:4721 kush-PC:4722 ESTABLISHED
TCP 127.0.0.1:4722 kush-PC:4721 ESTABLISHED
TCP 127.0.0.1:4999 kush-PC:5001 ESTABLISHED
TCP 127.0.0.1:5001 kush-PC:4999 ESTABLISHED
TCP 127.0.0.1:5208 kush-PC:5209 ESTABLISHED
TCP 127.0.0.1:5209 kush-PC:5208 ESTABLISHED
TCP 127.0.0.1:6751 kush-PC:895 ESTABLISHED
TCP 127.0.0.1:27015 kush-PC:1036 ESTABLISHED
TCP 192.168.2.5:2869 192.168.2.1:33040 TIME_WAIT
TCP 192.168.2.5:7227 cs:ssh ESTABLISHED
TCP 192.168.2.5:7312 blogger:http ESTABLISHED
TCP 192.168.2.5:7410 clients1:https ESTABLISHED
TCP 192.168.2.5:7411 clients1:http ESTABLISHED
TCP 192.168.2.5:7428 googleads:http ESTABLISHED
TCP 192.168.2.5:7429 googleads:http ESTABLISHED
TCP 192.168.2.5:7430 googleads:http ESTABLISHED
TCP 192.168.2.5:7432 googleads:http ESTABLISHED
TCP 192.168.2.5:7433 googleads:http ESTABLISHED
TCP 192.168.2.5:7434 googleads:http ESTABLISHED
TCP 192.168.2.5:7436 cr:http ESTABLISHED
TCP 192.168.2.5:7438 toolbarqueries:http ESTABLISHED

= print the process tree or which process is connected to which process ?
ptree

output is the formatted tree showing parent and child spawning of process at different levels. A more precise implication is "ptree PROCESS_ID".

= to show show directory size in kilobytes
du -k

= same as prstat what would you use to show io stats
iostat

simple but the output is difficult to analyse. The reads / sec, w / sec, kilo reads / sec, kilo writes / sec, more data to use show page faults, page in / out etc.



A good reference to look at would be Global Guide Line

No comments:

Post a Comment