Linux KT for Fresher

download Linux KT for Fresher

of 21

Transcript of Linux KT for Fresher

  • 7/30/2019 Linux KT for Fresher

    1/21

    LINUX KT for freshers

    1) How to see the version of a Oracle Enterprise Linux server

    A: cat /etc/*release*

    2) How to verify a package installed is correct

    A. rpm -V

    This will return no value if the package is successfully installed.

    3) How to check if the Linux is 32bit of 64bit

    A. uname m, this will give as x86_64 on a 64 bit machine and i686

    on a 32 bit machine.

    Database version:

    [prodora@usncx062 etc]$ sqlplus '/ as sysdba'

    SQL*Plus: Release 11.2.0.2.0 Production on Wed Jul 6 06:38:52 2011

    Copyright (c) 1982, 2010, Oracle. All rights reserved.

    Connected to:

    Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit

    Production

    With the Partitioning, OLAP, Data Mining and Real Application Testingoptions

    SYS@prod AS SYSDBA>select * from v$version;

  • 7/30/2019 Linux KT for Fresher

    2/21

    BANNER

    --------------------------------------------------------------------------------

    Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit

    Production

    PL/SQL Release 11.2.0.2.0 - Production

    CORE 11.2.0.2.0 Production

    TNS for Linux: Version 11.2.0.2.0 - Production

    NLSRTL Version 11.2.0.2.0 - Production

    SYS@prod AS SYSDBA>select version from v$instance;

    VERSION

    11.2.0.2.0

    4) How to check the file size in human readable format using ls command

    A. If you give ls -lh this will give the file size like in MB,

    GB etc, example below[root@usncx058 fs01]# ls -lh redo01a.log

    -rw-rw---- 1 perf1ora oinstall 1.1G May 26 03:58 redo01a.log

    5) How to check the system uptime

    A. To check the system uptime, use the command uptime, example

    below

    linapp40.diebold.com]:/home/parapus #uptime

    05:12:37 up 16 days, 2:23, 5 users, load average: 0.05, 0.19, 0.17

  • 7/30/2019 Linux KT for Fresher

    3/21

    6) How to see what are the mount points mounted on a server and see

    the size of the mount point in human readable format

    A. df -h, example below, try using this command on any Linux server

    The first line give the details of File system, in our case it gives the

    name of the logical volumeThe second line gives the total size of the logical volume

    The third line gives the total size utilized

    The fourth line gives the available free space

    The fifth line give the mount point name.

  • 7/30/2019 Linux KT for Fresher

    4/21

    7) What is the command to switch a user in Linux

    A. su -

    8) What is the command to see the server utilization

    A. top, example below

    top Header Explanation

    PID Process ID

    USER Owner of process

    PR Process priority

    NI Nice value

    VIRT Virtual memory used by process

    RES Non-swapped physical memory used by the process

    SHR Shared memory used by the process

  • 7/30/2019 Linux KT for Fresher

    5/21

    S Status of process

    %CPU Percentage of CPU usage

    %MEM Percentage of physical memory usage

    TIME+ Total CPU time used by process

    top is also interactive.

    For example, pressing Shift+M sorts the output by memory usage.

    Interactive top Commands

    top Command Explanation

    Shift+M Sort by memory usage

    Shift+P Sort by CPU usage

    Shift+N Sort by PID

    Shift+T Sort by TIME+

    k Kill a specific process by PID

    u Sort by specific user

    spacebar Immediately refresh the output

    h Show help

    q Quit top

  • 7/30/2019 Linux KT for Fresher

    6/21

    9) How to check the memory used on the server

    A. Use free -m or cat /proc/meminfo to see the memory status on a

    Linux server, example below

    In this example the total amount of available memory is 32494 MB.

    3091 MB are used by processes and 29403 MB are free for other

    applications. Do not get confused by the first line which shows that

    25898MB are free! If you look at the usage figures you can see that

    most of the memory use is for buffers and cache. Linux always tries to

    use RAM to speed up disk operations by using available memory forbuffers (file system metadata) and cache (pages with actual contents

    of files or block devices). This helps the system to run faster because

    disk information is already in memory which saves I/O operations. If

    space is needed by programs or applications like Oracle, then Linux

    will

    free up the buffers and cache to yield memory for the applications. If

    your system runs for a while you will usually see a small number under

    the field "free" on the first line.

  • 7/30/2019 Linux KT for Fresher

    7/21

    $ cat /proc/meminfo also gives the details of memory status as below, this

    also give the details of HugePages if it is implemented.

  • 7/30/2019 Linux KT for Fresher

    8/21

  • 7/30/2019 Linux KT for Fresher

    9/21

    10) Command to check the process status

    $ ps aux this give the details of all the process running on the

    machine, this sort as per the PID example below

    The header explanation is as below

    USER username

    PID process id

    %CPU CPU utilization

    %MEM Memory utilization

    VSZ Virtual memory usage of entire process = VmLib + VmExe +

    VmData + VmStk

    RSS Resident set size = the non-swapped physical memory that a

    task has used; Resident Set currently in physical memory including

    Code, Data, Stack

    TTY terminal

  • 7/30/2019 Linux KT for Fresher

    10/21

    STAT Status

    START Date

    TIME Time taken for execution of the command

    COMMAND command name (only the executable name). Modifications

    to the command name will not be shown. A process marked

    is partly dead, waiting to be fully destroyed by its parent.

    $ ps aux |grep will sort as per username, example below

    11) vmstat reports information about processes, memory, paging,

    block IO, traps, and cpu activity, example below

  • 7/30/2019 Linux KT for Fresher

    11/21

    The following values are under the memory header:

    Two columns are under the procs header: r and b. The value under the

    r column indicates the number of processes waiting for runtime. The

    value under the b column tells you the number of processes in

    uninterruptible sleep.

    swpd Amount of virtual memory used

    free Amount of free memory

    buff Amount of memory used in buffers

    cache Amount of memory used as cache

    Under the swap header:

    si Amount of memory swapped in from the disk

    so Amount of memory swapped to the disk

    Under the io header:

    bi Number of blocks received from a block device

    bo Number of blocks sent to a block device

    Under the system header:

    in Number of interrupts per second

    cs Number of context switches per second

  • 7/30/2019 Linux KT for Fresher

    12/21

    Under the cpu header:

    us Percentage of time the processor(s) spent running non-kernel code

    sy Percentage of time the processor(s) spent running kernel code

    id Percentage of time spent not running any code

    wa Percentage of time spent waiting for I/O

    st Percentage of time the processor(s) spent running kernel code

    12) Find out who is utilizing or eating the CPUs

    $ ps -eo pcpu,pid,user,args | sort -k 1 -r | head -10

    13) Find Out The Top 10 Memory Consuming Process

    $ ps aux | sort -nr -k 4 | head -10

  • 7/30/2019 Linux KT for Fresher

    13/21

  • 7/30/2019 Linux KT for Fresher

    14/21

    free command also give the swap details

    16) Network statistics

    To see how to network is utilized, use the below command

    $ sar -n DEV | more this data is collected from

    /var/log/sa/sa file

    $ sar -n DEV -f /var/log/sa/sa25 this will show the data from the file

    dated 25th of the current month.

  • 7/30/2019 Linux KT for Fresher

    15/21

    17) To check which file/directory using space more on a mount point,

    use the below command on a Linux server

    To check this first cd to the mount point for example if you want to

    check the size of each folders under /mnt/oraperf1/perf1db

    1) $ cd /mnt/oraperf1/perf1db

    2) $ du -sh * |sort -n |tail this will check the folder size in Human

    readable format and sort it with size

    3) In the above example the app folder is utilizing more

  • 7/30/2019 Linux KT for Fresher

    16/21

    4) Now cd to that app folder and see what is utilized more, in this way

    we can identify what is causing the space issue and check how to

    clear this.

    18) To list open files use lsof, this will be helpful to trouble shoot

    space issue. For example if someone move a file which is currently in

    use for clearing space, this wont free up space. To check these use

    lsof

    lsof /mnt/oraperf6 |more

    19) To check the number of CPUs on a system

    $ cat /proc/cpuinfo

    20) To check the print queue, go to the concurrent manger tier and

    issue the below command

    $ lpstat -t |grep

  • 7/30/2019 Linux KT for Fresher

    17/21

    If there is any pending queue it will show as above, if there is nothing

    pending it will give the status as below.

    21) To give a print you can use the below command

    $ lp -d

    22) To see the reboot history of a system use the below command

    $ last reboot

    23) To get the details of CPU give the below command

    $ grep "model name" /proc/cpuinfo

    24) To see the last 10 file and sort with last modified time, use the

    below command

    $ ls -lrt |tail

  • 7/30/2019 Linux KT for Fresher

    18/21

    25) To create soft link use the below command

    $ ln -s filename symlink

    Example below

    $ ln -s /mnt/oradevshare/oraperf1/applptmp temp

    $ ls -l temp

    lrwxrwxrwx 1 perf1ora oinstall 34 May 26 02:29 temp ->

    /mnt/oradevshare/oraperf1/applptmp

    26) To create hard link use the below command

    $ ln filename hardlink

    Please find the details of the Hard Links and Symbolic (or Soft) Links

    27) To check the IP address of a server, use the below command

    $ hostname -i

    Hard Links Symbolic (or Soft) Links

    Multiple names pointing to same

    inode

    Additional names pointing to original

    name

    Increments link count Separate file

    All names are equal Additional names can be broken

    Data preserved until all names

    removed

    Data lost if original name removed

    Must be on same file system Can span across file systems

  • 7/30/2019 Linux KT for Fresher

    19/21

    Example below

    28) To see the Kernel IP routing table use the below command

    $ netstat r

    Example below

    29) To see the active connection on a server use the below

    command

    $ netstat -e |more

    Example below

  • 7/30/2019 Linux KT for Fresher

    20/21

    30) Archiving file and compressing files

    To archive files we use tar and to compress files we use gzip

    Example below

    $ tar -cvf abc.tar abcthis will create an archive of the folder abc

    $ gzip abc.tar will compress the abc.tar as abc.tar.gz

    31) To uncompress the extract files

    To uncompress a file which is compressed using gzip, use the

    command below

    $ gunzip abc.tar.gz this will uncompress as abc.tar

    To extract the files of abc.tar, use the command below

    $ tar -xvf abc.tar

    32) To create a file use vi/vim editors

    The vi/vim editor has three modes

    1) Command mode

    2) Insert mode

    3) EX mode

    To create a file

  • 7/30/2019 Linux KT for Fresher

    21/21

    $ vi abc will Open a vi editor window this will open in command

    mode

    To go to insert mode, press I now you can enter what you want to

    the file

    To save the file you have to go to EX mode, to go to EX mode you have

    to go to :

    To save and quit use :wq

    To quit without saving use :q!

    Check man vi to get more options