Sunday, 29 July 2012

Unix / Linux Some important CLI / Infos








Dialect of UNIX RAM display command

DEC-UNIX uerf -r 300 | grep -i mem 
Solaris prtconf |grep -i mem 
AIX lsdev -C|grep mem 
Linux free 
HP/UX swapinfo -tm 

Command to find the no. of cpu:-

Linux :-
cat /proc/cpuinfo | grep processor 

Solaris :-

psrinfo



Aix Commands

lsps 
Report statistics about paging space.

Example: lsps -a

iostat 
Report statistics for ttys, disks and cpu

Examples What it does 
iostat -d hdisk0 hdisk1 5 
Will monitor disk activity only for physical volumes hdisk0 1 
iostat -t 5 
Will monitor terminal activity only and display tty statistics every 5 seconds 

ipcs 

Status of interprocess communication facilities. This is a kernel attribute that cannot be modified.

lsattr 
Lists attributes associated with a device.

NOTE: maxmbuf sets the limit of the memory governed by the IPC and network buffering capability.

Examples What it does 
lsattr -l sys0 -E 
Entries marked 'True' are attributes that can be configured 
lsattr -l sys0 -a maxpout=9 -a minpout=6 
Changes the HIGH/LOW water marks for pending write I/Os per file. 

nfsstat 
Display information about NFS and RPC calls

Examples What it does 
nfsstat 
Displays statistics about NFS and RPC calls 
nfsstat -zcsr 
Initializes statistics (to ZERO) for client (-c), server (-s), and rpc (-r) calls 

pagesize 
Display system page size

ps 
Display status of current processes. This command is useful for determining if
runaway processes are excessively utilizing the CPU or memory.

Examples What it does 
ps avg a displays information about all processes. v displays fields:
PGIN,SIZE,RSS,LIM,TSIZE,TRS,%CPU,%MEM 
ps -ft tty2/0 Lists all the processes running on port tty2/0 
ps -furoger Lists all the processes running under the user roger 
ps -e Display the environment as well as the command 
ps -ef Full listing of all processes in the system. If the 'C' field 
(means processor utilization) has a large value, this means that 
process is a CPU intensive task. 
ps -t- Lists processes not associated with a terminal 


sar 
System Activity Recorder utility found on all UNIX systems that monitors various system functions like

cpu 
hard disk 
terminal IO 
number of files open 
processes running 

sar -u 5 10 Interactively run the sar command and review CPU 
utlization every 10 seconds for 5 interations. 

tprof

Detailed profile of CPU usage by an application. Provides an estimate of 
CPU usage for each routine in a profile. Useful to determine where an application maybe CPU bound.

vmstat 

Statistics about virtual memory and cpu/hard disk usage.

Example: vmstat hdisk0 hdisk1 5 (Display various statistics every 5 seconds)


Linux

free 
This command displays statistics on memory usage. The values represent KB's.

Example...

total used free shared buffers cached 
Mem: 63208 61484 1724 27848 1060 49360 
-/+ buffers/cache: 11064 52144 
Swap: 128516 6500 122016 


du 
This command stands for disk usage and will print the size of the current directory
and subdirectories in 1 KB sizes.

df 
This command displays information for each file system.

Example: df

Filesystem 1024-blocks Used Available Capacity Mounted on 
/dev/sda1 497667 301229 170736 64% / 
/dev/sda2 7469935 5721885 1360884 81% /usr 

env 
This command lists all shell (environment) variables and their contents for the current user.

ps 
This command lists process status. There are many options for this command. Below are the two most common.

Example: ps u (process status for current user)

USER PID %CPU %MEM SIZE RSS TTY STAT START TIME COMMAND 
roger 418 0.0 1.7 1808 1124 p0 S 23:27 0:01 -bash 
roger 690 0.0 0.5 872 356 p0 R 00:09 0:00 ps u 

PID = Unique Process ID 
SIZE = Virtual image size; size of text+data+stack 
RSS = Resident set size; kilobytes of program in memory 
TTY = Controlling tty 
STAT = Information about the status of the process 
R = runnable 
S = sleeping 
D = uninterruptible sleep 
T = stopped or traced 
Z = zombie process 
Second field = W if the process has no resident pages. 
Third field = N if the process has a positive nice value 


top 
This command display a full screen of information of the top processes. 
It will update automatically until the program is stopped. To stop the display, enter q.

procinfo 

gathers some system data from the /proc directory and prints it formatted on the screen.

Last Boot time 
Load Average 
average number of jobs running 
number of runnable processes 
total number of processes 
PID of the last process run (idem) 
Swap info 
Memory resources 
Number of disks 
IRQ info 

procinfo -fn30
To exit, simply press q 


uptime 
This command displays a one line summary showing...

Example: uptime
11:42pm up 18 days, 8:45, 1 user, load average: 0.00, 0.00, 0.00


Solaris

List Solaris Hardware Configuration
$ /usr/sbin/prtconf


Show Swap Space currently installed
Multiply the Blocks column by 512

$ swap -l

How to Display Virtual Memory Statistics (vmstat)

The following example shows the vmstat display of statistics gathered at five-second intervals.

$ vmstat 5


iostat 5

tty md1 md3 md4 md5 cpu
tin tout kps tps serv kps tps serv kps tps serv kps tps serv us sy wt id

How to Check CPU Utilization
#sar

Display CPU utilization with the sar -u command. (The sar command without any options is equivalent to sar -u.) At any given moment, the processor is either busy or idle. When busy, the processor is in either user or system mode. When idle, the processor is either waiting for I/O completion or "sitting still" with no work to do.

Measure CPU utilization during 5 secs one time.

sar -u 5 1


Measure CPU utilization during 60 secs 1440 times and write result in file sar.log.

sar -u -o sar.log 60 1440 

To later review disk and tape activity from that period:

sar -d -f sar.log

Determine the memory used by each Oracle background process on a Solaris

This can be used by anyone who has privleges for the pmap, which can be found in /usr/proc/bin/. 
First, we need to find the process id (PID) of the Oracle background process you wish to determine the memory size for. This is done by issueing the following command:


# ps -u oracle -f

Virtual / Physical Memory Usage

Solaris is a virtual memory system. The total amount of memory that you can use is 
increased by adding swap space to the system. If you ever see "out of memory" messages, adding swap space is the usual fix. Performance of the system is very dependent on how much physical memory (RAM) you have. If you don't have enough RAM to run your workload, performance degrades rapidly.

Physical memory usage can be classified into four groups:

Kernel memory mapped into kernel address space
Process memory is mapped into a process address space
Filesystem cache memory that is not mapped into any address space
Free memory that is not mapped into any address space

RMCmem includes a simple command to summarize this:

# /opt/RMCmem/bin/prtmem
Total physical memory
The total physical memory can be seen using prtconf. Memory is allocated in units called pages, and you can use the 'pagesize' command to see the size in bytes per page:

# /usr/sbin/prtconf | grep Memory
Memory size: 1024 Megabytes

# /usr/bin/pagesize
8192

prtstat -a v


General:-

top

vmstat
$ vmstat 5 3
Displays system statistics (5 seconds apart; 3 times):

procs memory page disk faults cpu 

r b w swap free re mf pi po fr de sr s0 s1 s2 s3 in sy cs us sy id 
0 0 0 28872 8792 8 5 172 142 210 0 24 3 11 17 2 289 1081 201 14 6 80 
0 0 0 102920 1936 1 95 193 6 302 1264 235 12 1 0 3 240 459 211 0 2 97 
0 0 0 102800 1960 0 0 0 0 0 464 0 0 0 0 0 107 146 29 0 0 100 

Having any processes in the b or w columns is a sign of a problem system.
Having an id of 0 is a sign that the cpu is overburdoned.
Having high values in pi and po show excessive paging.

procs (Reports the number of processes in each of the following states) 
r : in run queue 
b : blocked for resources (I/O, paging etc.) 
w : runnable but swapped 

memory (Reports on usage of virtual and real memory) 
swap : swap space currently available (Kbytes) 
free : size of free list (Kbytes) 

page (Reports information about page faults and paging activity (units per second) 
re : page reclaims 
mf : minor faults 
pi : Kbytes paged in 
po : Kbytes paged out 
fr : Kbytes freed 
de : anticipated short-term memory shortfall (Kbytes) 
sr : pages scanned by clock algorith 

disk (Reports the number of disk operations per second for up to 4 disks 

faults (Reports the trap/interupt rates (per second) 

in : (non clock) device interupts 
si : system calls 
cs : CPU context switches 

cpu (Reports the breakdown of percentage usage of CPU time (averaged across all CPUs) 
us : user time 
si : system time 
cs : idle time 


CPU Usage
sar
$ sar -u 10 8
Reports CPU Utilization (10 seconds apart; 8 times):
Time %usr %sys %wio %idle 
11:57:31 72 28 0 0 
11:57:            41 70 30 0 0       
11:57:            51 70 30 0 0       
11:58:01 68 32 0 0 
11:58:11 67 33 0 0 
11:58:21 65 28 0 7 
11:58:31 73 27 0 0 
11:58:            41 69 31 0 0       
Average 69 30 0 1 

#sar -r 5 10


%usr: Percent of CPU in user mode
%sys: Percent of CPU in system mode
%wio: Percent of CPU running idle with a process waiting for block I/O
%idle: Percent of CPU that is idle


mpstat
$ mpstat 10 2
Reports per-processor statistics on Sun Solaris (10 seconds apart; 8 times):
CPU minf mjf xcal intr ithr csw icsw migr smtx srw syscl usr sys wt idl 
0 6 8 0 438 237 246 85 0 0 21 8542 23 9 9 59 
0 0 29 0 744 544 494 206 0 0 95 110911 65 29 6 0 


$ ps -e -o pcpu -o pid -o user -o args | sort -k 1 | tail -21r
Displays the top 20 CPU users on the system.
%CPU PID USER COMMAND 
78.1 4789 oracle ora_dbwr_DDDS2 
8.5 4793 oracle ora_lgwr_DDDS2 
2.4 6206 oracle oracleDDDS2 (LOCAL=NO) 
0.1 4797 oracle ora_smon_DDDS2 
0.1 6207 oracle oracleDDDS2 (LOCAL=NO) 
etc. etc. etc. etc. 

The PID column can then be matched with the SPID column on the V$PROCESS view 
to provide more information on the process:

SELECT a.username, 
a.osuser, 
a.program, 
spid, 
sid, 
a.serial#
FROM v$session a,
v$process b
WHERE a.paddr = b.addr
AND spid = '&pid';

unzip to different foler:-

$ unzip file.zip -d /u01/app


CRON

field allowed values
----- --------------
minute 0-59
hour 0-23
day of month 1-31
month 1-12
day of week 0-7 (both 0 and 7 are Sunday)
user Valid OS user
command Valid command or script.

The first 5 fields can be specified using the following rules:

* - All available values or "first-last".
3-4 - A single range representing each possible from the start to the end of the range inclusive.
1,2,5,6 - A specific list of values.
1-3,5-8 - A specific list of ranges.
0-23/2 - Every other value in the specified range.

The following entry runs a cleanup script a 01:00 each Sunday. Any output or errors from the 
script are piped to /dev/null to prevent a buildup of mails to root.

0 1 * * 0 /u01/app/oracle/dba/weekly_cleanup > /dev/null 2>&1


Useful Files
Here are some files that may be of use:

Path Contents 
/etc/passwd User settings 
/etc/group Group settings for users. 
/etc/hosts Hostname lookup information. 
/etc/system Kernel parameters for Solaris. 
/etc/sysconfigtab Kernel parameters for Tru64.

Check the below for more tools

http://www.cyberciti.biz/tips/top-linux-monitoring-tools.html


Calcuting SWAP Space Recommendation:-


Here is my rule for normal server (Web / Mail etc):
Swap space == Equal RAM size (if RAM < 2GB) 
Swap space == 2GB size (if RAM > 2GB) 

For Oracle server 

Swap space == Equal RAM size (if RAM < 8GB) 
Swap space == 0.50 times the size of RAM (if RAM > 8GB) 

Red Hat minimum swap space recommendation:-

1. Systems with 4GB of ram or less require a minimum of 2GB of swap space 
2. Systems with 4GB to 16GB of ram require a minimum of 4GB of swap space 
3. Systems with 16GB to 64GB of ram require a minimum of 8GB of swap space 
4. Systems with 64GB to 256GB of ram require a minimum of 16GB of swap space

Find the Bit configuration of Server:-

Aix : getconf -a | grep KERN
KERNEL_BITMODE: 64

Solaris :- isainfo -v
32-bit

Linux
Linux users should type the uname command. 
Depending on the platform, you may see 

$ uname -a
Linux gaylord.stata.com 2.6.11-1.27_FC3 #1 Tue May 17 20:24:57 EDT 2005 x86_64 x86_64 x86_64 GNU/Linux

$ uname -a
Linux caddo.stata.com 2.6.9-5.0.5.EL #1 SMP Fri Apr 8 14:20:58 EDT 2005 ia64 ia64 ia64 GNU/Linux

$ uname -a
Linux tango.stata.com 2.6.10-1.771_FC2smp #1 SMP Mon Mar 28 01:10:51 EST 2005 i686 i686 i386 GNU/Linux

In the above listing, 'gaylord' (x86_64 GNU/Linux) and 'caddo' (ia64 GNU/Linux) are 64-bit compliant. 'tango' (i386 GNU/Linux) is only a 32-bit platform

Windows:-
run-> winmsd -> System x82- 32 bit or ia64 - 64 bit



how to Change the ip in solaris

edit the /etc/hosts file and save it using :wq! and reboot or # svcadm restart network/physical


How to change the hostname in solaris

Change the hostname in the following files:

/etc/nodename
/etc/hostname.*interface
/etc/inet/hosts
/etc/inet/ipnodes

and rename directory under /var/crash

# cd /var/crash
# mv oldname newname

then reboot the server.



Versions of Solaris Explained

SunOS is the core operating system comprising the kernel, utilities and basic libraries. Solaris is the broader environment comprising SunOS, OpenWindows and networking support. In other words, SunOS is a component of Solaris.

SunOS and Solaris relate to each other as follows:

For example, when one does a 'uname -a' this reports that the server has SunOS 5.6 installed which means that it actually got Solaris 2.6 installed. .

SUN OS Version Is Solaris Version 
SunOS 5.4 Solaris 2.4 
SunOS 5.5 Solaris 2.5 
SunOS 5.5.1 Solaris 2.5.1 
SunOS 5.6 Solaris 2.6 
SunOS 5.7 Solaris 7 
SunOS 5.8 Solaris 8 
SunOS 5.9 Solaris 9 
SunOS 5.10 Solaris 10 


How Can we tell Solaris OS is running 32-bit or 64-bit?
Use the isalist command to determine whether the machine is running
the 32-bit or 64-bit operating system. If you are running the 64-bit
operating system on an UltraSPARC machine, then isalist
will list sparcv9 first

How to boot in 64/32 bit mode?
To boot a 32-bit kernel, at the ok prompt type:
ok boot [disk or net] kernel/unix



To boot a 64-bit kernel (default), at the ok prompt type:

ok boot [disk or net] kernel/sparcv9/unix

ok boot [disk or net]

Run job in batch now:
at -s now < thejob.sh

Show current process active
ps -efa

Show process information
psrinfo -v

Show version of unix
uname -a

Display System Configuration
sysdef

or

prtconf

Print VTOC
prtvtoc /dev/dsk/c0t0d0s0

Query Disk space
df -k disk space in kilobytes

du -sk disk space summary in kilobytes

How To Configure Sun 450 Hot swap disk drives
1. drvconfig

2. disks

Remove all files and sub-directories
rm -r *

Move all files from one directory to another using tar pipe
from directory /var

mkdir /var1

cd /var

tar cf - . | (cd /var1 && tar xBf -)

Directory compare (don't show files that are the same)
dircmp -s /var /var1

Give User execute permission on a file 
chomod u+x filename gives execute permission to the owner.

Find command to find in current directory and sub directory
find . -name "dbmslogmnr.sql" -print


DATE Command
date mmddHHMM[[cc]yy]

example "date 022610221998"

Get DATE from another unix box 
rdate pluto

Find Command for certain size files
find . -size +10000c 

This example say find all the file > 10000 bytes. 



Find command to find a word in the directory and sub directory
find . -exec grep -ls pkzip {} \;



Linux - Shell Limits to limit user processes (/etc/security/limits.conf)
About Limiting user processes is important for running a stable system. To limit user process, you have just to set shell limit by adding: 

a user name 
or group name
or all users 

to /etc/security/limits.conf file and impose then process limitations. 

Example of /etc/security/limits.conf file 

* hard nofile 65535
* soft nofile 4096
@student hard nproc 16384
@student soft nproc 2047

A soft limit is like a warning and hard limit is a real max limit. For example, following will prevent anyone in the student group from having more than 50 processes, and a warning will be given at 30 processes. 

@student hard nproc 50
@student soft nproc 30

Hard limits are maintained by the kernel while the soft limits are enforced by the shell. 

The /etc/security/limits.conf file contains a list line where each line describes a limit for a user in the form of: 

Where:

can be:
an user name
a group name, with @group syntax
the wildcard *, for default entry
the wildcard %, can be also used with %group syntax, for maxlogin limit
can have the two values:
“soft” for enforcing the soft limits (soft is like warning)
“hard” for enforcing hard limits (hard is a real max limit)
can be one of the following:
core - limits the core file size (KB)
can be one of the following:
core - limits the core file size (KB)
data - max data size (KB)
fsize - maximum filesize (KB)
memlock - max locked-in-memory address space (KB)
nofile - Maximum number of open file descriptors
rss - max resident set size (KB)
stack - max stack size (KB) - Maximum size of the stack segment of the process
cpu - max CPU time (MIN)
nproc - Maximum number of processes available to a single user
as - address space limit
maxlogins - max number of logins for this user
maxsyslogins - max number of logins on the system
priority - the priority to run user process with
ocks - max number of file locks the user can hold
sigpending - max number of pending signals
msgqueue - max memory used by POSIX message queues (bytes)
nice - max nice priority allowed to raise to
rtprio - max realtime priority
chroot - change root to directory (Debian-specific)

How to
Set the limitations
Open the /etc/security/limits.conf file and change the existing values for “hard” and “soft” parameters as it's given in your installation documentation.
Restart the system after making changes.
If the current value for any parameter is higher than the value listed in the installation document, then do not change the value of that parameter.

* hard nofile 65535
* soft nofile 4096
* hard nproc 16384
* soft nproc 2047Verify the limitations
To check the soft and hard limits, log as the user and enter the following ulimit command:

Limitation Soft Hard
file descriptor ulimit -Sn ulimit -Hn
number of processes available to a user ulimit -Su ulimit -Hu
stack ulimit -Ss ulimit -Hs



---
Download the rpm packages for linux os from
http://linux1.fnal.gov/linux/lts47/i386/SL/RPMS/repodata/repoview/glibc-common-0-2.3.4-2.41.html

Probelm:-
I am unable to install glibc-2.3.4-2.41.i386.rpm
[root@test ank]# rpm -Uvh glibc-2.3.4-2.41.i386.rpm
warning: glibc-2.3.4-2.41.i386.rpm: V3 DSA signature: NOKEY, key ID b38a8516
error: Failed dependencies:
glibc-common = 2.3.4-2.41 is needed by glibc-2.3.4-2.41.i386
glibc = 2.3.4-2.39 is needed by (installed) glibc-headers-2.3.4-2.39.i386
glibc = 2.3.4-2.39 is needed by (installed) glibc-devel-2.3.4-2.39.i386
glibc = 2.3.4-2.39 is needed by (installed) glibc-utils-2.3.4

Solution:-
rpm -Uvh glibc-2.3.4-2.41.i386.rpm --nodeps

No comments:

Post a Comment