Leeagt
Inactive User
Set Password to non Expire (Solaris)
passwd -x -1 <account name>
VI command to do a global find and remove
:g/<string>/s/<string>//g
e.g :g/manchester/s/ //g would remove all manchester entries
VI Command to insert word at end of each line
:% s;$<New_word>
VI Command to insert word at start of each line
:1,$s/^/<new_word>/g
To split large files
csplit -k (Keep Files) -f (Use prefix) <prefix name>. <file to split> '/<word to find before split>/' '{*} (repeat the previous pattern as many times as possible)
csplit -k -f mgpasswd. mgpasswd '/Visiting/' '{500}'
Copy a file with update, permissions and time stamp
cp -p <filename>
Display filesystem in gb on AIX
df -gt
Display filesystem in gb on solaris
df -h
VI command to change upercase letters to lowercase
:%s/\([A-Z]\)/\l\1/g
To count the number of files in immediate directory
ls -1p | grep -vc "/$"
To view all zone information from globalzone
zoneadm list -civ
AIX Specific
The highest recently used CPU-intensive user processes in the system:
ps -ef | egrep -v "STIME|$LOGNAME" | sort +3 -r | head -n 15
The %CPU is the percentage of CPU time that has been allocated to that process since the process was started.
ps aux
Display threads and the CPUs that threads or processes are bound to. The TID column shows the threadID.
ps -efmo THREAD
Display processes with the highest CPU utilization:
ps -eo pid,pcpu,args | sort +1n
To find the threadid (tid) of a known process that is using CPU:
ps -mp <WLS_PID> -o THREAD
Display processes with the highest memory usage:
#ps -eo pid,vsz,args | sort +1n
To list the top ten users of paging space in IBM AIX:
svmon -Pgt 10 (paging)
To list the top ten users of realmem in IBM AIX:
svmon -Put 10
To find memory usage:
svmon -u | more
svmon -P | more
To find processes which use the most memory:
svmon -P -t 1
svmon -Pau 1
LINUX Specific
Show a breakdown of utilization by an individual processor. The command shows the kernel level, user CPU, system CPU, nice time, idle time, wait time and interrupts per second. Similar data can be obtained with the sar command.
#mpstat
Display five reports of statistics for all processors at two second intervals, enter:
# mpstat -P ALL 2 5
List processes by % CPU usage:
#ps -e -o pcpu,cpu,nice,state,cputime,args --sort pcpu | sed '/^ 0.0 /d' List processes by % cpu usage
Displays the top ten CPU users on the Linux system:
#ps -eo pcpu,pid,user,args | sort -k 1 -r | head -10
OR
#ps -eo pcpu,pid,user,args | sort -r -k1 | less
List all threads for a particular process:
#ps -C <process> -m -o pid,tid,pcpu,state
List processes by memory usage:
#ps -e -orss=,args= | sort -b -k1,1n | pr -TW$COLUMNS
Show the amount of (remaining) RAM (-m displays in MB):
#free -m
An interactive tool that allows a system administrator to view the process table in order of CPU or memory usage, by user, and at varying refresh rates in real-time.
#top
Solaris Specific
Show all top threads to determine what could be using the most CPU:
#prstat -Lmc -p <pid>
#prstat -L -p <pid> 1 1
To show the PID, user, state, and thread id:
#ps -Le -o pid,user,s,lwp,pcpu,args | awk '$3 != "S" { print }'
Reports paging activity details for applications (executables), data (anonymous) and filesystem activity:
#vmstat -p
Prints out details of memory use by a process:
#pmap -x <pid>
To find how much disk space is used by users in kilobytes in Solaris:
#quot -af
Commands that can be used on most UNIX platforms
Running iostat provides much information, but the values of concern are %user and %sys. If (%user + %sys) > 80 percent over a period of time, then it is likely the bottleneck is CPU. In particular, it is necessary to watch for average CPU being greater than 70 percent with peaks above 90 percent.
#iostat
To report system-wide process use, swapping, memory use, disk I/O and CPU use:#vmstat
To provides statistics on the average length of the run queue, the percentage of time the run queue is occupied, the average length of the swap queue and the percentage of time the swap queue is occupied.
#sar
Breaks the time into user, system, time waiting for blocked I/O (i.e., NFS, disk, etc.) and idle time.
#sar -u
#sar -q
#sar -k
One advantage to using sar is that you can write the data to a file and then post-process it when the system is not busy. The file is created using the -a and -o flags. An example of creating a file of 30 snapshots, each two seconds apart, would look like:
#sar a o sardata.out 2 30
This file would then be processed using:
#sar -u -f sardata.out
passwd -x -1 <account name>
VI command to do a global find and remove
:g/<string>/s/<string>//g
e.g :g/manchester/s/ //g would remove all manchester entries
VI Command to insert word at end of each line
:% s;$<New_word>
VI Command to insert word at start of each line
:1,$s/^/<new_word>/g
To split large files
csplit -k (Keep Files) -f (Use prefix) <prefix name>. <file to split> '/<word to find before split>/' '{*} (repeat the previous pattern as many times as possible)
csplit -k -f mgpasswd. mgpasswd '/Visiting/' '{500}'
Copy a file with update, permissions and time stamp
cp -p <filename>
Display filesystem in gb on AIX
df -gt
Display filesystem in gb on solaris
df -h
VI command to change upercase letters to lowercase
:%s/\([A-Z]\)/\l\1/g
To count the number of files in immediate directory
ls -1p | grep -vc "/$"
To view all zone information from globalzone
zoneadm list -civ
AIX Specific
The highest recently used CPU-intensive user processes in the system:
ps -ef | egrep -v "STIME|$LOGNAME" | sort +3 -r | head -n 15
The %CPU is the percentage of CPU time that has been allocated to that process since the process was started.
ps aux
Display threads and the CPUs that threads or processes are bound to. The TID column shows the threadID.
ps -efmo THREAD
Display processes with the highest CPU utilization:
ps -eo pid,pcpu,args | sort +1n
To find the threadid (tid) of a known process that is using CPU:
ps -mp <WLS_PID> -o THREAD
Display processes with the highest memory usage:
#ps -eo pid,vsz,args | sort +1n
To list the top ten users of paging space in IBM AIX:
svmon -Pgt 10 (paging)
To list the top ten users of realmem in IBM AIX:
svmon -Put 10
To find memory usage:
svmon -u | more
svmon -P | more
To find processes which use the most memory:
svmon -P -t 1
svmon -Pau 1
LINUX Specific
Show a breakdown of utilization by an individual processor. The command shows the kernel level, user CPU, system CPU, nice time, idle time, wait time and interrupts per second. Similar data can be obtained with the sar command.
#mpstat
Display five reports of statistics for all processors at two second intervals, enter:
# mpstat -P ALL 2 5
List processes by % CPU usage:
#ps -e -o pcpu,cpu,nice,state,cputime,args --sort pcpu | sed '/^ 0.0 /d' List processes by % cpu usage
Displays the top ten CPU users on the Linux system:
#ps -eo pcpu,pid,user,args | sort -k 1 -r | head -10
OR
#ps -eo pcpu,pid,user,args | sort -r -k1 | less
List all threads for a particular process:
#ps -C <process> -m -o pid,tid,pcpu,state
List processes by memory usage:
#ps -e -orss=,args= | sort -b -k1,1n | pr -TW$COLUMNS
Show the amount of (remaining) RAM (-m displays in MB):
#free -m
An interactive tool that allows a system administrator to view the process table in order of CPU or memory usage, by user, and at varying refresh rates in real-time.
#top
Solaris Specific
Show all top threads to determine what could be using the most CPU:
#prstat -Lmc -p <pid>
#prstat -L -p <pid> 1 1
To show the PID, user, state, and thread id:
#ps -Le -o pid,user,s,lwp,pcpu,args | awk '$3 != "S" { print }'
Reports paging activity details for applications (executables), data (anonymous) and filesystem activity:
#vmstat -p
Prints out details of memory use by a process:
#pmap -x <pid>
To find how much disk space is used by users in kilobytes in Solaris:
#quot -af
Commands that can be used on most UNIX platforms
Running iostat provides much information, but the values of concern are %user and %sys. If (%user + %sys) > 80 percent over a period of time, then it is likely the bottleneck is CPU. In particular, it is necessary to watch for average CPU being greater than 70 percent with peaks above 90 percent.
#iostat
To report system-wide process use, swapping, memory use, disk I/O and CPU use:#vmstat
To provides statistics on the average length of the run queue, the percentage of time the run queue is occupied, the average length of the swap queue and the percentage of time the swap queue is occupied.
#sar
Breaks the time into user, system, time waiting for blocked I/O (i.e., NFS, disk, etc.) and idle time.
#sar -u
#sar -q
#sar -k
One advantage to using sar is that you can write the data to a file and then post-process it when the system is not busy. The file is created using the -a and -o flags. An example of creating a file of 30 snapshots, each two seconds apart, would look like:
#sar a o sardata.out 2 30
This file would then be processed using:
#sar -u -f sardata.out