Sei sulla pagina 1di 11

top (display Linux tasks )

The top program provides a dynamic real-time view of a running system. It can display
system summary information as well as a list of tasks currently being managed by the Linux
kernel. The types of system summary information shown and the types, order and size of
information displayed for tasks are all user configurable



Common hot keys:

t - Displays summary information off and on.
m - Displays memory information off and on.
A - Sorts the display by top consumers of various system resources. Useful for quick
identification of performance-hungry tasks on a system.
f - Enters an interactive configuration screen for top. Helpful for setting up top for a specific
task.
o - Enables you to interactively select the ordering within top.
r - Issues renice command.
k - Issues kill command.
z - Turn on or off color/mono





vmstat (Report virtual memory statistics )

vmstat reports information about processes, memory, paging, block IO, traps, disks and cpu
activity. The first report produced gives averages since the last reboot. Additional reports
give information on a sampling period of length delay. The process and memory reports are
instantaneous in either case.


-f switch displays the number of forks since boot. This includes the fork, vfork, and clone
system calls, and is equivalent to the total number of tasks created. Each process is
represented by one or more tasks, depending on thread usage. This display does not
repeat.
-m displays slabinfo.
-n switch causes the header to be displayed only once rather than periodically.
-s displays a table of various event counters and memory statistics. This display does not
repeat.


w (Show who is logged on and what they are doing)
w displays information about the users currently on the machine, and their processes. The
header shows, in this order, the current time, how long the system has been running, how
many users are currently logged on, and the system load averages for the past 1, 5, and 15
minutes.
The following entries are displayed for each user: login name, the tty name, the remote
host, login time, idle time, JCPU, PCPU, and the command line of their current process.

The JCPU time is the time used by all processes attached to the tty. It does not include past
background jobs, but does include currently running background jobs.



-h Don't print the header.
-u Ignores the username while figuring out the current process and cpu times. To
demonstrate this, do a "su" and do a "w" and a "w -u".
-s Use the short format. Don't print the login time, JCPU or PCPU times.
-f Toggle printing the from (remote hostname) field. The default as released is for the from
field to not be printed, although your system administrator or distribution maintainer may
have compiled a version in which the from field is shown by default.
-V Display version information.
-o Old style output. Prints blank space for idle times less than one minute.
user Show information about the specified user only.

uptime (Tell How Long The System Has Been Running)

uptime gives a one line display of the following information. The current time, how long the
system has been running, how many users are currently logged on, and the system load
averages for the past 1, 5, and 15 minutes.

ps (Report a snapshot of the current processes.)

ps command will report a snapshot of the current processes. To select all processes use the
-A or -e option.
To see every process on the system using standard syntax:
$ ps -e
$ ps -ef
$ ps -eF
$ ps -ely

To see every process on the system using BSD syntax:
$ ps ax
$ ps axu

To print a process tree:
$ ps -ejH
$ ps axjf

To get info about threads:
$ ps -eLf
$ ps axms

To get security info:
$ ps -eo euser,ruser,suser,fuser,f,comm,label
$ ps axZ
$ ps -eM

To see every process running as root (real & effective ID) in user format:
$ ps -U root -u root u

To see every process with a user-defined format:
$ ps -eo pid,tid,class,rtprio,ni,pri,psr,pcpu,stat,wchan:14,comm
$ ps axo stat,euid,ruid,tty,tpgid,sess,pgrp,ppid,pid,pcpu,comm
$ ps -eopid,tt,user,fname,tmout,f,wchan








Find Out The Top 10 Memory Consuming Process
$ ps auxf | sort -nr -k 4 | head -10


Find Out top 10 CPU Consuming Process
$ ps -auxf | sort -nr -k 3 | head -10









free - (Display amount of free and used memory in the system )
free displays the total amount of free and used physical and swap memory in the system, as
well as the buffers used by the kernel. The shared memory column should be ignored; it is
obsolete.

-b Display the amount of memory in bytes.
-c count Display the result count times. Requires the -s option.
-g Display the amount of memory in gigabytes.
-k Display the amount of memory in kilobytes. This is the default.
-l Show detailed low and high memory statistics.
-m Display the amount of memory in megabytes.
-o Display the output in old format, the only difference being this option will disable the
display of the "buffer adjusted" line.
-s Continuously display the result delay seconds apart. You may actually specify any floating
point number for delay, usleep(3) is used for microsecond resolution delay times.
-t Display a line showing the column totals.
-V Display version information.

mpstat (Report processors related statistics.)

The mpstat command writes to standard output activities for each available processor,
processor 0 being the first one. Global average activities among all processors are also
reported.
Use mpstat -P ALL to display average CPU utilization per processor.


iostat (Report Central Processing Unit (CPU) statistics and input/output statistics
for devices and partitions.)

The iostat command is used for monitoring system input/output device loading by observing
the time the devices are active in relation to their average transfer rates. The iostat
command generates reports that can be used to change system configuration to better
balance the input/output load between physical disks.



COMMANDS BASICS

tar command examples

Create a new tar archive.
$ tar cvf archive_name.tar dirname/

Extract from an existing tar archive.
$ tar xvf archive_name.tar

View an existing tar archive.
$ tar tvf archive_name.tar


grep command examples

Search for a given string in a file (case in-sensitive search).
$ grep -i "the" demo_file

Print the matched line, along with the 3 lines after it.
$ grep -A 3 -i "example" demo_text

Search for a given string in all files recursively
$ grep -r "demo" *


find command examples

Find files using file-name ( case in-sensitve find)
# find -iname "MyCProgram.c"

Execute commands on files found by the find command
$ find -iname "MyCProgram.c" -exec md5sum {} \;

Find all empty files in home directory
# find ~ -empty


ssh command examples

Login to remote host
ssh -l jsmith remotehost.example.com

Debug ssh client
ssh -v -l jsmith remotehost.example.com

Display ssh client version
$ ssh -V
OpenSSH_3.9p1, OpenSSL 0.9.7a Feb 19 2003


export command examples

To view oracle related environment variables.
$ export | grep ORACLE
declare -x ORACLE_BASE="/u01/app/oracle"
declare -x ORACLE_HOME="/u01/app/oracle/product/10.2.0"
declare -x ORACLE_SID="med"
declare -x ORACLE_TERM="xterm"

To export an environment variable:
$ export ORACLE_HOME=/u01/app/oracle/product/10.2.0


ls command examples

Display filesize in human readable format (e.g. KB, MB etc.,)
$ ls -lh
-rw-r----- 1 atithya team-dev 8.9M Jun 12 15:27 arch-linux.txt.gz

Order Files Based on Last Modified Time (In Reverse Order) Using ls -ltr
$ ls -ltr

Visual Classification of Files With Special Characters Using ls -F
$ ls F







gzip command examples

To create a *.gz compressed file:
$ gzip test.txt

To uncompress a *.gz file:
$ gzip -d test.txt.gz

Display compression ratio of the compressed file using gzip -l
$ gzip -l *.gz
compressed uncompressed ratio uncompressed_name
23709 97975 75.8% asp-patch-rpms.txt

Potrebbero piacerti anche