Linux Shell Script Questions and Answers #2

Add two numbers in a shell script?

Echo `expr $1 + $2`——–arguments we pass two values
echo ‘$*’—————–list of arguments
echo ‘$#’—————-total number of count
echo ‘$0’————–output first word
 

How will you solve “filename.sh permission denied” in linux?

$ chmod +x filename.sh
 

What will happen when you  execute root.sh?

It’s used to create /etc/oratab file
Set the environment variables (ORACLE_OWNER,ORACLE_HOME)
Intimate the environment variables to bin.
 

How do you see how many instancesare running in Linux?

ps -ef|grep pmon|grep -v grep|wc -l
 

Given an error number,  how will you see description of the error and action in OS level?

oerr ora 0060
00060, 00000, “deadlock detected while waiting for resource”
// *Cause: Transactions deadlocked one another while waiting for resources.
// *Action: Look at the trace file to see the transactions and resources
// involved. Retry if necessary.
 

What is SAR? (System activity report)?

The sar (system activity reporter) command is useful for displaying both current and historical processor load. Use sar with the -u option to report on CPU statistics.
By default, sar will report on the current day’s activities:
$ sar -u

To report on the previous day’s worth of CPU statistics, use the -f option. The files that sar uses to report on statistics for different days of the month are located in the /var/log/sa directory and have the naming convention of saNN,where NN is the two-digit day of the month. For example, to have sar display CPU statistics for the tenth day of the month, run it as follows:

$ sar -u -f /var/log/sa/sa10
02:40:01 PM CPU %user %nice %system %iowait %idle
02:50:01 PM all 0.22 0.00 0.24 0.00 99.54
03:00:01 PM all 0.22 0.00 0.24 0.00 95.53
03:10:01 PM all 0.22 0.00 0.23 0.00 99.55
03:20:01 PM all 0.42 0.00 1.06 2.11 96.41
03:30:01 PM all 0.24 0.00 1.22 0.01 92.54
Average: all 0.19 0.00 0.19 0. 07 99.55

The columns in the prior output have the same meaning as the mpstat output A low %idle could be an indication that the CPUs are underpowered or indicative of a high application load.
$ sar -u 2 20

To use sar to report on the current day’s CPU activity, simply specify the -u option:
$ sar -u

To use sar to report on a previous day in the month, use the -f option. See the examples in
the “Solution” section of this recipe for techniques for reporting on a previous day’s statistics.

If you have multiple CPUs, you can view the output per CPU with the -P ALL options. You
should now see one line per CPU in the output:
$ sar -u -P ALL

Here is a partial listing of the output:
04:30:01 PM 0 0.10 0.00 0.01 0.00 99.99
04:30:01 PM 1 0.11 0.00 0.01 0.00 99.98

To display paging activity:
sar -B 3 100

To display swapping activity:
sar -W 3 100

To display block I/O activity:
sar -b 3 100

To display block I/O activity for each block device:
sar -d 3 100

To display network activity:
sar -n DEV 3 100
 

How will you remove memory segment in linux?

There are two instances currently running

[oracle@sss-oracle ~]$ ps -ef|grep pmon
oracle    4772     1  0 11:12 ?        00:00:00 ora_pmon_test
oracle    2753     1  0 14:12 ?        00:00:00 ora_pmon_sakthi
oracle   13149 13009  0 15:54 pts/1    00:00:00 grep pmon

use $ipcs to view the memory segments
[oracle@sss-oracle ~]$ ipcs

—— Shared Memory Segments ——–
key        shmid      owner      perms      bytes      nattch     status
0×00000000 3375105    oracle    600        393216     2          dest
0×00000000 3407875    oracle    600        393216     2          dest
0×00000000 3440644    oracle    600        393216     2          dest
0×00000000 3473413    oracle    600        393216     2          dest
0×00000000 3506182    oracle    600        393216     2          dest
0×00000000 3899399    oracle    600        393216     2          dest
0×00000000 3571720    oracle    600        393216     2          dest
0×00000000 3604489    oracle    600        393216     2          dest
0×00000000 3637258    oracle    600        393216     2          dest
0x0a2b21c4 3702795    oracle    660        633339904  21
0×51417090 3768332    oracle    640        289406976  15

—— Semaphore Arrays ——–
key        semid      owner      perms      nsems
0x4c0bf348 229376     oracle    660        104
0xa70c84e8 360449     oracle    640        154

—— Message Queues ——–
key        msqid      owner      perms      used-bytes   messages
[oracle@sss-oracle ~]$ sysresv -l “sakthi”
IPC Resources for ORACLE_SID “sakthi” :

Shared Memory:
ID              KEY
3768332         0×51417090

Semaphores:
ID              KEY
360449          0xa70c84e8
Oracle Instance alive for sid “sakthi”
[oracle@sss-oracle ~]$ ipcrm -s 360449
The memory segment is removed.
[oracle@sss-oracle ~]$ ps -ef|grep pmon
oracle    4772     1  0 11:12 ?        00:00:00 ora_pmon_test
oracle   13149 13009  0 15:54 pts/1    00:00:00 grep pmon

Linux Tips

More Linux Questions

Have a Linux Problem
Linux Forum - Do you have a Linux Question?

Linux Books
Linux Certification, System Administration, Programming, Networking Books

Linux Home: Linux System Administration Hints and Tips

(c) www.gotothings.com All material on this site is Copyright.
Every effort is made to ensure the content integrity.  Information used on this site is at your own risk.
All product names are trademarks of their respective companies.
The site www.gotothings.com is in no way affiliated with or endorsed by any company listed at this site.
Any unauthorised copying or mirroring is prohibited.