Thursday, May 5, 2011

Configure VNC Server on Solaris

root# ./vncserver
vncserver: couldn't find "Xvnc" on your PATH.


root# cd /usr/X11/bin

root# ls
Xvnc ......

root# pwd
/usr/X11/bin

root# export PATH=$PATH:/usr/X11/bin:/usr/openwin/bin

root# vncserver

You will require a password to access your desktops.

Password:
Verify:

New 'hostname:1 (root)' desktop is hostname:1

Creating default startup script //.vnc/xstartup
Starting applications specified in //.vnc/xstartup
Log file is //.vnc/hostnames:1.log

Tuesday, February 8, 2011

how to add a swap file Linux

Procedure to add a swap file

You need to use dd command to create swapfile. Next you need to use mkswap command to set up a Linux swap area on a device or in a file.

a) Login as the root user

b) Type following command to create 512MB swap file (1024 * 512MB = 524288 block size):
# dd if=/dev/zero of=/swapfile1 bs=1024 count=524288

c) Set up a Linux swap area:
# mkswap /swapfile1

d) Activate /swapfile1 swap space immediately:
# swapon /swapfile1

e) To activate /swapfile1 after Linux system reboot, add entry to /etc/fstab file. Open this file using text editor such as vi:
# vi /etc/fstab

Append following line:
/swapfile1 swap swap defaults 0 0

So next time Linux comes up after reboot, it enables the new swap file for you automatically.

g) How do I verify swap is activated or not?
Simply use free command:
$ free -m

Tuesday, January 25, 2011

Recreate the OraInventory

In cases where the OraInventory is missing or otherwise corrupt, recreate the oraInventory directory on UNIX systems, using the following steps. In a normal installation, there is a Global Inventory (OraInventory) and a Local Inventory ($ORACLE_HOME/inventory).

Locate the oraInst.loc file, which may be in different locations, depending on your system:

/var/opt/oracle/oraInst.loc file
or
/etc/oraInst.loc
Modify the file oraInst.loc file:

cp /var/opt/oracle/oraInst.loc /var/opt/oracle/oraInst.loc.bak
mkdir /u01/oracle/oraInventory

---file contents---
inventory_loc=/u01/oracle/oraInventory
inst_group=oinstall
---file contents---
Important:
Theses example uses a typical directory, considered an $ORACLE_BASE, and a typical UNIX group which installed the Oracle products. Ensure that the correct values are used for your system.

The oraInventory directory is usually a directory under the $ORACLE_HOME. For example, if the $ORACLE_HOME is equal to "/u01/oracle/product/10g", then the OraInventory could be "/u01/oracle/OraInventory".
Change the permissions to be appropriate, (using your directory location):

chmod 644 /var/opt/oracle/oraInst.loc
For consistency, copy the file to Oracle home directory, (using your directory location):

cp $ORACLE_HOME/oraInst.loc $ORACLE_HOME/oraInst.loc.bak
cp /var/opt/oracle/oraInst.loc $ORACLE_HOME/oraInst.loc
Run Oracle Universal Installer from your Oracle home as below, (using your site specific directory location and Oracle home name):

cd $ORACLE_HOME/oui/bin
./runInstaller -silent -attachHome
ORACLE_HOME="/u01/oracle/product/10.2" ORACLE_HOME_NAME="Ora10gHome"
Check the inventory output is correct for your Oracle home:

$ORACLE_HOME/OPatch/opatch lsinventory -detail
If the table at the beginning of the output is showing the proper directories, and the Oracle home components are properly reflected in the details, then the Global Inventory has been successfully created from the Local Inventory. At this time, you may patch an maintain your Oracle home, as normal.

SQL*Plus command line history completion

The rlwrap (readline wrapper) utility provides a command history and editing of keyboard input

for any other command. This is a really handy addition to SQL*Plus and RMAN .


Download the latest rlwrap software from the following URL.
http://utopia.knoware.nl/~hlub/uck/rlwrap/

Unzip and install the software using the following commands.

gunzip rlwrap*.gz
tar -xvf rlwrap*.tar
cd rlwrap*
./configure
make
make check
make install

Run the following commands, or better still append then to the ".bash_profile" of the


oracle software owner.


alias sqlplus='rlwrap ${ORACLE_HOME}/bin/sqlplus'
alias rman='rlwrap ${ORACLE_HOME}/bin/rman'
alias expdp='rlwrap ${ORACLE_HOME}/bin/expdp'

You can now start SQL*Plus or RMAN using "sqlplus" and "rman" respectively, and you will have


a basic command history and the current line will be editable using the arrow and delete keys.

Monday, January 24, 2011

Redhat Package Management (RPM)

Features:
1. Provides package management
a. Query
b. Install
c. Uninstall
d. Upgrade
e. Verify
2. Auto-verifies packages using GPG, MD5, SHA1SUMs
3. Automatically reports on unresolved dependencies




Install (Does NOT overwrite previous package):
Note: Use this method to install a new version of the kernel
1. rpm -ivh *.rpm
2. rpm -ivh http://192.168.75.100/RH5/i386/Server/dhcp-3.0.5-7.el5.i386.rpm



Upgrade (Installs or overwrites existing package):
1. rpm -Uvh *.rpm
2. rpm -Uvh http://192.168.75.100/RH5/i386/Server/dhcp-3.0.5-7.el5.i386.rpm

Freshen (Updates an existing package):
Note: Will NOT install the package, if it doesn't exist locally

1. rpm -Fvh *.rpm - freshens the current version of a package


Removal:
1. rpm -ev *.rpm - removes a pacakge
Note: removal process considers dependencies and will complain if the removal will break 1 or more packages. To get around this, use '--nodeps' option with 'rpm -ev --nodeps *.rpm'

2. rpm -ev gftp


Query:


1. rpm -qa - shows all installed packages
2. rpm -qa | wc -l - this dumps all packages and provides a count
3. rpm -qa | grep -i sendmail
4. rpm -qi nano - dumps info. about the 'sendmail' package as it's recorded in the local RPM database
5. rpm -qf /usr/bin/nano - dumps package membership info. for the 'nano' file
6. rpm -qpi http://192.168.75.100/RH5/i386/Server/dhcp-3.0.5-7.el5.i386.rpm - dumps info. about the uninstalled 'dhcp' package, which resides on the repository
7. rpm -ql package_name - returns all included files


Verify:
1. rpm -Va - verifies ALL packages on the system, returning info. only if there are discrepancies from the original installation

2. rpm -Vf /usr/bin/nano

Task: Change '/usr/bin/nano' then verify

SM5....T /usr/bin/nano

S(file size), M(mode or permissions), 5(MD5), T(mod time)
3. rpm -Vp nano

IPTables in Linux

Features:
1. Firewall for Linux
2. Interface to Netfilter, which is loaded by the kernel
3. Operates primarily @ layers 3 & 4 of the OSI model
4. Modular
5. Provides Network Address Translation (NAT)
6. IPTables can also access other layers (2, 5-7), with modules

1. grep -i config_netfilter /boot/config*

Note: Save rules in: /etc/sysconfig/iptables so that when IPTables is restarted, the rules will be applied OR, update /etc/sysconfig/iptables-config to save the rules automatically

/sbin/iptables - primary ACL modifier utility
/sbin/iptables-restore - restores rules to current IPTables instance
/sbin/iptables-save - saves rules to STDOUT, by default, or to a file


IPTables includes 3 default tables, which you cannot remove:
1. NAT
2. Mangle
3. Filter (Default) - filters inbound/outbound traffic

Note: Each table, includes chains, which include Access Control Entries (ACEs)

Usage:
1. iptables -L

Note: The Filter table includes 3 chains:
1. INPUT - applies to traffic destined to a service that our system is bound to

2. FORWARD - applies to traffic being routed through the system

3. OUTPUT - applies to traffic sourced from our system, heading outbound


Examples:
1. Filter inbound traffic to remote RH5 system to SSH
a. iptables -A INPUT -p tcp --dport 22 -j ACCEPT
b. iptables -A INPUT -j DROP

2. Filter outbound traffic to ANY remote SSH port
a. iptables -A OUTPUT -p tcp --dport 22 -j DROP

3. Flush ALL rules from OUTPUT chain of the Filter table
a. iptables -F OUTPUT

4. Save rules to file, then flush rules
a. iptables-save > iptables.rules.1

5. Reinstate flushed rules
a. iptables-restore iptables.rules.1

Sunday, January 23, 2011

Server Status & Health Check in Linux

Top :

Top Command can provide the top processes, CPU Load, Memory Utilization, Swap Utilization

Running/Zombie Process, Uptime, etc..

iostat:

This command will provide the information about the disk utilization, Read/Write rate, etc..

vmstat:

vmstat command provides the swap memory utilization report

sar (System Activity Reporter)

sar tool can provide the report about CPU Load, iowait and other useful info at specified intervals.

dmesg

dmesg command displays all the server errors including Hardware, booting, network errors

This command will retrieve the information from log files which located in /var/log

Other Useful commands to collect some info about the server :

runlevel - To Know the Current Run Level

netstat –a - To see the Network sessions

netstat –rn - To View the gateways configured

who / finger - To View the Users logged in detail

ps –ef - To view all the running process and its related files

sestatus - To check SELINUX status

service iptables status - To check firewall status

ifconfig –a - To View the Network cards and IP Address configured