Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 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 <packagename> 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 Testing options

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

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 <filename> 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

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 volume The 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) What is the command to switch a user in Linux A. su - <username>

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

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

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 for buffers (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.

$ cat /proc/meminfo also gives the details of memory status as below, this also give the details of HugePages if it is implemented.

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

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 <defunct> is partly dead, waiting to be fully destroyed by its parent.

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

11) vmstat reports information about processes, memory, paging, block IO, traps, and cpu activity, example below

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

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

14) To display the activities of each available process use mpstat -P ALL, details below

15)

Checking Swap Space Size and Usage

You can check the size and current usage of swap space by running the command: $ grep SwapTotal /proc/meminfo

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<currentdate> file

$ sar -n DEV -f /var/log/sa/sa25 this will show the data from the file dated 25th of the current month.

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

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 <printer name>

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<printername> <filename>

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

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

Hard Links
Multiple names pointing to same inode Increments link count All names are equal Data preserved until all names removed Must be on same file system

Symbolic (or Soft) Links


Additional names pointing to original name Separate file Additional names can be broken Data lost if original name removed Can span across file systems

27)

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

$ hostname -i

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

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 abc this 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

$ 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

You might also like