Sunday, June 23, 2013

HOWTO: Increase swap space on RedHat Enterprise Linux

To add a swap file:
1. Determine the size of the new swap file and multiple by 1024 to determine the block size. For example, the block size of a 64 MB swap file is 65536.
2. At a shell prompt as root, type the following command with count being equal to the desired block size:
# dd if=/dev/zero of=/swapfile bs=1024 count=65536
3. Setup the swap file with the command:
# mkswap /swapfile
4. To enable the swap file immediately but not automatically at boot time:
# swapon /swapfile
5. To enable it at boot time, edit /etc/fstab to include:
/swapfile swap swap defaults 0 0
The next time the system boots, it will enable the new swap file.
6. After adding the new swap file and enabling it, make sure it is enabled by viewing the output of the command cat /proc/swaps or free.

Wednesday, June 12, 2013

CREATION OF MOUNT POINT IN LINUX PLATFORM


ENTRIES AT THE SOURCE MACHINE 

[root@R0458 /]# ls
A01   dev   lib         misc  opt   root  selinux  sys       u01
bin   etc   lost+found  mnt   proc  rpms  soft     tftpboot  usr
boot  home  media       net   R12   sbin  srv      tmp       var
[root@R0458 /]# vi /etc/exports
[root@R0458 /]# service network restart
Shutting down interface eth0:                              [  OK  ]
Shutting down loopback interface:                          [  OK  ]
Bringing up loopback interface:                            [  OK  ]
Bringing up interface eth0: 
Determining IP information for eth0... done.
                                                           [  OK  ]
[root@R01458 /]# service nfs restart
Shutting down NFS mountd:                                  [  OK  ]
Shutting down NFS daemon:                                  [  OK  ]
Shutting down NFS quotas:                                  [  OK  ]
Shutting down NFS services:                                [  OK  ]
Starting NFS services:  exportfs: No options for /R12 172.24.3.30: suggest 172.24.3.30(sync) to avoid warning
exportfs: No host name given with /R12 (rw,sync), suggest *(rw,sync) to avoid warning
exportfs: No options for /soft 172.24.13.13: suggest 172.24.13.13(sync) to avoid warning
exportfs: No host name given with /soft (rw,sync), suggest *(rw,sync) to avoid warning
exportfs: No options for /R12 172.24.2.22: suggest 172.24.2.22(sync) to avoid warning
exportfs: No host name given with /R12 (rw,sync), suggest *(rw,sync) to avoid warning
exportfs: duplicated export entries:
exportfs:       *:/R12
exportfs:       *:/R12
exportfs: No options for /R12 172.24.1.14: suggest 172.24.1.14(sync) to avoid warning
exportfs: No host name given with /R12 (rw,sync), suggest *(rw,sync) to avoid warning
exportfs: duplicated export entries:
exportfs:       *:/R12
exportfs:       *:/R12
exportfs: No options for /R12 172.24.3.27: suggest 172.24.3.27(sync) to avoid warning
exportfs: No host name given with /R12 (rw,sync), suggest *(rw,sync) to avoid warning
exportfs: duplicated export entries:
exportfs:       *:/R12
exportfs:       *:/R12
                                                           [  OK  ]
Starting NFS quotas:                                       [  OK  ]
Starting NFS daemon:                                       [  OK  ]
Starting NFS mountd:                                       [  OK  ]
[root@R0458 /]#

ENTRIES AT THE EXPORT FILE 

/R12 172.24.3.27 (rw,sync)
~                                                                              
~                                                                               ~                                                                              
~                                                                              
"/etc/exports" 5L, 137C


ENTRIES AT THE TARGET MACHINE 

[root@brn Desktop]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda5             220G  127G   83G  61% /
/dev/sda3             996M   35M  910M   4% /tmp
/dev/sda1             965M   23M  893M   3% /boot
tmpfs                 3.0G   12K  3.0G   1% /dev/shm
[root@brn Desktop]# ls
beginning-shell-scripting.pdf  new file 2~
brn.dmp                        oracle10ginstallsteps.doc
brn_imp.log                    p_123
brn.log                        prasad ora
control.sql                    PTCwork.txt
control.sql~                   R12
Database_Cloning               Rman_backup
EMP_IMP_11g                    rman-duplicate-database-on-the-same-host.doc
EMP_IMP_Export_11g             Sam Alapati 11g.pdf
exp                            Screenshot-1.png
exp_hr.log                     Screenshot-2.png
hr.dmp                         Screenshot.png
new file                       SNAP R12
new file~                      STEPS_FOR_DUPLICATE_DB
new file 1                     temp
new file 1~                    total_space
new file 2
[root@brn Desktop]# cd R12/
[root@brn R12]# cd /
[root@brn /]# ls
11gdb  BRN_DOCUMENT  etc   lost+found  mnt  proc  selinux  srv       tmp  var
bin    clone_11g     home  media       net  root  setups   sys       u01
boot   dev           lib   misc        opt  sbin  Soft     tftpboot  usr
[root@brn /]# mkdir /R12
[root@brn /]# ll
total 196
drwxrwxrwx   3 oracle dba   4096 May 14 12:16 11gdb
drwxr-xr-x   2 root   root  4096 May 14 02:00 bin
drwxr-xr-x   4 root   root  4096 May 14 00:04 boot
drwxrwxrwx   5 oracle dba   4096 May 14 10:34 BRN_DOCUMENT
drwxrwxrwx   3 oracle dba   4096 Jun  6 15:16 clone_11g
drwxr-xr-x  12 root   root  3720 Jun 12 18:23 dev
drwxr-xr-x 132 root   root 12288 Jun 12 16:57 etc
drwxr-xr-x   4 root   root  4096 May 24 18:29 home
drwxr-xr-x  13 root   root 12288 May 14 01:59 lib
drwx------   2 root   root 16384 May 13 23:49 lost+found
drwxr-xr-x   2 root   root  4096 Jun 12 15:28 media
drwxr-xr-x   2 root   root     0 Jun 10 10:39 misc
drwxr-xr-x   2 root   root  4096 Aug  8  2008 mnt
drwxr-xr-x   2 root   root     0 Jun 10 10:39 net
drwxr-xr-x   6 root   root  4096 May 14 14:30 opt
dr-xr-xr-x 222 root   root     0 Jun 10 10:38 proc
drwxr-xr-x   2 root   root  4096 Jun 12 18:36 R12
drwxr-x---  23 root   root  4096 Jun 12 17:04 root
drwxr-xr-x   2 root   root 12288 May 14 02:00 sbin
drwxr-xr-x   2 root   root  4096 May 13 23:50 selinux
drwxrwxrwx   3 oracle dba   4096 May 14 11:53 setups
drwxrwxrwx   3 root   root  4096 May 22 17:23 Soft
drwxr-xr-x   2 root   root  4096 Aug  8  2008 srv
drwxr-xr-x  11 root   root     0 Jun 10 10:38 sys
drwxr-xr-x   3 root   root  4096 May 13 23:58 tftpboot
drwxrwxrwt   9 root   root  4096 Jun 12 18:22 tmp
drwxrwxrwx   6 oracle dba   4096 Jun 12 17:20 u01
drwxr-xr-x  15 root   root  4096 Jun 12 13:55 usr
drwxr-xr-x  28 root   root  4096 May 14 00:06 var
[root@brn /]# mount -t nfs 172.24.4.18:/R12 /R12
[root@brn /]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda5             220G  127G   83G  61% /
/dev/sda3             996M   35M  910M   4% /tmp
/dev/sda1             965M   23M  893M   3% /boot
tmpfs                 3.0G   12K  3.0G   1% /dev/shm
172.24.4.5:/R12       193G  147G   36G  81% /R12
[root@brn /]# ll

Saturday, June 8, 2013

These questions are the most frequently asked in interviews.

These questions are the most frequently asked in interviews.
  1. To fetch ALTERNATE records from a table. (EVEN NUMBERED)
    select * from emp where rowid in (select decode(mod(rownum,2),0,rowid, null) from emp);
  2. To select ALTERNATE records from a table. (ODD NUMBERED)
    select * from emp where rowid in (select decode(mod(rownum,2),0,null ,rowid) from emp);
  3. Find the 3rd MAX salary in the emp table.
    select distinct sal from emp e1 where 3 = (select count(distinct sal) from emp e2 where e1.sal <= e2.sal);
  4. Find the 3rd MIN salary in the emp table.
    select distinct sal from emp e1 where 3 = (select count(distinct sal) from emp e2where e1.sal >= e2.sal);
  5. Select FIRST n records from a table.
    select * from emp where rownum <= &n;
  6. Select LAST n records from a table
    select * from emp minus select * from emp where rownum <= (select count(*) - &n from emp);
  7. List dept no., Dept name for all the departments in which there are no employees in the department.
    select * from dept where deptno not in (select deptno from emp); 
    alternate solution:  select * from dept a where not exists (select * from emp b where a.deptno = b.deptno);
    altertnate solution:  select empno,ename,b.deptno,dname from emp a, dept b where a.deptno(+) = b.deptno and empno is null;
  8. How to get 3 Max salaries ?
    select distinct sal from emp a where 3 >= (select count(distinct sal) from emp b where a.sal <= b.sal) order by a.sal desc;
  9. How to get 3 Min salaries ?
    select distinct sal from emp a  where 3 >= (select count(distinct sal) from emp b  where a.sal >= b.sal);
  10. How to get nth max salaries ?
    select distinct hiredate from emp a where &n =  (select count(distinct sal) from emp b where a.sal >= b.sal);
  11. Select DISTINCT RECORDS from emp table.
    select * from emp a where  rowid = (select max(rowid) from emp b where  a.empno=b.empno);
  12. How to delete duplicate rows in a table?
    delete from emp a where rowid != (select max(rowid) from emp b where  a.empno=b.empno);
  13. Count of number of employees in  department  wise.
    select count(EMPNO), b.deptno, dname from emp a, dept b  where a.deptno(+)=b.deptno  group by b.deptno,dname;
  14.  Suppose there is annual salary information provided by emp table. How to fetch monthly salary of each and every employee?
    select ename,sal/12 as monthlysal from emp;
  15. Select all record from emp table where deptno =10 or 40.
    select * from emp where deptno=30 or deptno=10;
  16. Select all record from emp table where deptno=30 and sal>1500.
    select * from emp where deptno=30 and sal>1500;
  17. Select  all record  from emp where job not in SALESMAN  or CLERK.
    select * from emp where job not in ('SALESMAN','CLERK');
  18. Select all record from emp where ename in 'BLAKE','SCOTT','KING'and'FORD'.
    select * from emp where ename in('JONES','BLAKE','SCOTT','KING','FORD');
  19. Select all records where ename starts with ‘S’ and its lenth is 6 char.
    select * from emp where ename like'S____';
  20. Select all records where ename may be any no of  character but it should end with ‘R’.
    select * from emp where ename like'%R';
  21. Count  MGR and their salary in emp table.
    select count(MGR),count(sal) from emp;
  22. In emp table add comm+sal as total sal  .
    select ename,(sal+nvl(comm,0)) as totalsal from emp;
  23. Select  any salary <3000 from emp table. 
    select * from emp  where sal> any(select sal from emp where sal<3000);
  24. Select  all salary <3000 from emp table. 
    select * from emp  where sal> all(select sal from emp where sal<3000);
  25. Select all the employee  group by deptno and sal in descending order.
    select ename,deptno,sal from emp order by deptno,sal desc;
  26. How can I create an empty table emp1 with same structure as emp?
    Create table emp1 as select * from emp where 1=2;
  27. How to retrive record where sal between 1000 to 2000?
    Select * from emp where sal>=1000 And  sal<2000
  28. Select all records where dept no of both emp and dept table matches.
    select * from emp where exists(select * from dept where emp.deptno=dept.deptno)
  29. If there are two tables emp1 and emp2, and both have common record. How can I fetch all the recods but common records only once?
    (Select * from emp) Union (Select * from emp1)
  30. How to fetch only common records from two tables emp and emp1?
    (Select * from emp) Intersect (Select * from emp1)
  31.  How can I retrive all records of emp1 those should not present in emp2?
    (Select * from emp) Minus (Select * from emp1)
  32. Count the totalsa  deptno wise where more than 2 employees exist.
    SELECT  deptno, sum(sal) As totalsal
    FROM emp
    GROUP BY deptno
    HAVING COUNT(empno) > 2

SQL > SQL Commands

Basic Unix commands for Oracle DBAs

Basic Unix commands for Oracle DBAs

Get total RAM on the Linux system

Linux Operating System stores memory information in /proc/meminfo file.
cat /proc/meminfo
MemTotal: 16439648 kB
MemFree: 349904 kB
….
Linux free command takes information from meminfo file and prints it
free -k
total used free shared buffers cached
Mem: 16439648 15840476 599172 0 348872 11497768
-/+ buffers/cache: 3993836 12445812
Swap: 16779884 464 16779420

To get no of cpu in linux

cat /proc/cpuinfo|grep processor|wc -l
Linux Performance monitoring Commands are:
1) top
2) vmstat
3) sar

To get Disk/Filesystem space usage in Linux

df

It shows the available disk space.
Example.
$ df
$ df -k       (-k will show values in kilobytes)
$ df -kh      (-h print sizes in human readable format (e.g., 1K 234M 2G) )

set -o emacs

To enable UP arrow key and to get last command and command history for Oracle and other users use below command.
$ set -o emacs

cal

This command show a calendar for a specified month and/or year.
Example. To show this month’s calendar, enter:
$ cal
To show the twelve-month calendar for 2010, enter:
$ cal 2012
To show a calendar for just the month of May 2013, enter:
$ cal 5 2013

cat

This is one of the most flexible Unix commands. You can use to create, view and concatenate files.
Examples:
To create a file called test:
$ cat >test
To view a file use cat in a different way:
$ cat test
To write the contents of the file mytestfile to standard output with each line numbered:
$ cat -n mytestfile
To concatenate two files into one, files test1 and test2 and write the result to test.all use:
$ cat test1 test2 > test.all

cd

To change directory. Use this command to change directories.
Example:
To change to ORACLE_HOME directory enter:
$ cd /home/oracle/product/10g
$ cd $ORACLE_HOME
$ cd ~       Go back to home directory, useful if you’re lost.
$ cd ..       Go back one directory.

chmod

To changes the permissions on a file.
Example.
To change the permissions on file ‘test.txt’ to read only:
$ chmod 444 test.txt
chmod 600 {filespec} You can read and write; the world can’t. Good for files.
chmod 700 {filespec} You can read, write, and execute; the world can’t. Good for scripts.
chmod 644 {filespec} You can read and write; the world can only read. Good for web pages.
chmod 755 {filespec} You can read, write, and execute; the world can read and execute. Good for programs you want to share, and your public_html directory.

clear

This command clears the terminal screen.
Example.
To clear the terminal screen, enter
$ clear

cp

Use this to copy files.
Example.
To make a copy of the file ‘tnsnames.ora’ as ‘tnsnames_bkp.ora’:
$ cd /home/oracle/product/10g/network/admin
$ cp tnsnames.ora tnsnames_bkp.ora

date

Use this command to check the date and time.
Example.
$ date
Thu Mar 11 19:42:14 GMT 2010

echo

The echo command echoes its arguments. Use it to determine if certain environment variables are set. Precede the variable you would like to see by a dollar sign ($).
Examples:
To find out the location of the ORACLE_HOME or ORACLE_SID or PATH variable use:
$ echo $ORACLE_HOME
/home/oracle/product/10g
$ echo $ORACLE_SID
Ora10g
$ echo $PATH

find

Use this command to find a particular file or groups of files.
Examples.
To find the file initora10g.ora, you may use:
$ find / -name initora10g.ora -print
Modify the above command to search the current directory and its  subdirectories by replacing the slash with a period.
$ find . -name initora10g.ora -print
To list all files in your home directory by using the following:
$ find $HOME -print
To find  the location of tnsnames.ora use:
$ find / -name tnsnames.ora -print
To find the location of listener.ora use:
$ find / -name listener.ora -print
To find the location of alert.log file use:
$ find / -name alert*.log -print

grep

Use this command to search for information in a file or files.
Example:
To check the status of the Oracle PMON from the OS.
$ ps -ef | grep pmon
To get a list of process on the unix machine corresponding for a user. For example to list all running processes for oracle user on linux box
$ ps -ef| grep oracle
To to list all running processes for root user on linux box
$ ps -ef| grep root

hostname

Provides the hostname of the box you are currently working on. This is particularly useful when you have telnet sessions to several boxes at one time and when there is confusion as to which box you are currently on.
Example:
$  hostname
    Linux2

ls

This shows the contents of a particular directory.
Example:
cd /home/oracle/product/10g/bin
$ ls
$ ls –l
$ ls –ltr
$ ls -al
-l         detail listing of files
-t         sort by modification time
-r         reverse order while sorting
-a,        display all files( Use this to include hidden files. For Example .profile or .bash_profile )

man

Useful command that can help you figure out the syntax and purpose of most UNIX commands. Enter ‘man’ followed by the command you would like to execute, and you will get a quick rundown of what the command does and a description of how to use it.
Examples:
$ man ls         Displays details about the ls command.
$ man cat        Displays details about the cat command.
$ man chmod      Displays details about the chmod command.

mkdir

Use this command to create new directory.
Example:
To create a subdirectory in the home directory of your Unix account, use the mkdir command. For example, to create a subdirectory called Test, at the Unix prompt from within your home directory, enter.
$  mkdir test

more

Shows listing one screen at a time. More is a command used to read text files.
Example.
To see the page wise details of below files use the commands as mentioned below.
$ cd /home/oracle/product/10g/network/admin
$ more tnsnames.ora
$ more listener.ora
$ more sqlnet.ora

mv

Use this command to move or rename files.
Examples:
To rename the file ‘test.txt’ to ‘test.old’:
$ mv test.txt test.old
To move a file named Test from a subdirectory named my_new to another subdirectory named my_old , enter:
$ mv -i my_new/Test my_old

ps

To see list of all the operating system processes that are running.
Example:
$ ps
$ ps –ef|grep pmon

pwd

It means present working directory. Use this command to find out what directory you are working in.
Example.
$ pwd

setenv ( This command works on c shell only)

Use this command to set envirorment variables.
Example:
To change the default printer from hpx123 to myprinter:
$ echo $PRINTER
   hpx123
$ setenv PRINTER myprinter
$ echo $PRINTER
   myprinter
whatis – This command is used to get the definition or usage of any linux command.
Example:
$ whatis ls
$ whatis ps
$ whatis who

Miscellaneous Unix commands

chgrp – changes the group ownership of a file
chown – changes owner of file
r – To redo the last command typed. Useful when you have typed a long command and do not want to type the entire command again.
w – who is logged in, and what are they doing
wc – display a count of lines, words and characters in a file
which – locate a command; display its pathname or alias
who – who is on the system
whoami – display the effective current username
whois – Internet user name directory service
chsh -s {shell-name} {user-name} Command to change login shell in Linux / UNIX operating system
Example : chsh -s /bin/ksh  oracle
vi
The vi editor (short for visual editor) is a screen editor which is available on almost all Unix and Linux systems.

Vi has two modes insertion mode and command mode.
The editor begins in command mode, where the cursor movement and text deletion and pasting occur.
Insertion mode begins upon entering an insertion or change command.
[ESC] returns the editor to command mode (where you can quit, for example by typing :q!).
Most commands execute as soon as you type them except for “colon” commands which execute when you press the return key.

Basic UNIX commands For Oracle Database Administrator DBA

Basic UNIX commands For Oracle Database Administrator DBA 

1.ls -l for listing the files as well as directories those are kept in   
the particular working directory
syntax
[root@neemotech root]#ls -l



2.ls -la same as ‘ls -l’but by this command we can also see the hiden
files.
syntax
[root@neemotech root]#ls -la
3.ls -li same as ‘ls -la’ but it will also shows us the inode number of
each and every file
syntax
[root@neemotech root]#ls -li
4.ls by this command we can see only file name nothing else  
syntax
[root@neemotech root]#ls
5.clear it will clear the screen(short cut ctl+l)  
syntax
[root@neemotech root]#clear
6.exit to end a current session as well current terminal logging  
syntax
[root@neemotech root]exit
7.touch to create a new empty file   
syntax
[root@neemotech root]#touch
8.cd to change the working/present directory      
syntax
[root@neemotech root]#cd /home/neemo
where ‘/home/neemo’ is the desired directory to be change from
‘/root’
9.cat to view the contents of a file and it is also used for creating a  
new file with some contents
syntax
[root@neemotech root]#cat <file name>       to view file contents
[root@neemotech root]#cat > newfilename     enter,then you can write something in
the file and then to save the file contents press clt+d then enter

10.mkdir to make a new directory
syntax
[root@neemotech root]#mkdir newdirname
you can also create a directory at your desired path without
changing your present working directory
syntax
[root@neemotech root]#mkdir /home/neemo/newdirname
11.rm to remove a empty file   
syntax
[root@neemotech root]#rm filename
Page 1Basic Commands
12.rmdir to remove a empty directory
syntax
[root@neemotech root]#rmdir directoryname
13.rm [-i/-r/-f] to remove a directory with its subdirectories as well as its
files that is to remove a directory which already contains some files in it
syntax
[root@neemotech root]#rm -i directory/filename
-i  stands for interactively
-r  stands for recursively
-f  stands for forcefully
14.cp to copy something in a destination file or directory  
syntax
[root@neemotech root]#cp sourcepath destinationpath
example: [root@neemotech root]#cp /home/neemo/webmin.rpm /root/abcd
in this example the webmin.rpm file will be copied in
/root/abcd directory
15.mv to move one file or directory from one place to another place, it  
is also used for renaming adirectory or file
syntax
[root@neemotech root]#mv source destination
[root@neemotech root]#mv oldfilename newfilename     [to change the file name]
16.man to view the mannual page of commands for syntax  
syntax
[root@neemotech root]#man commandname
17.info to view the information about any command  
syntax
[root@neemotech root]#mkdir info
18.–help to view the help doccuments of a command
syntax
[root@neemotech root]#commandname –help
19.dir to view the subdirectories and filesn under the directory  
syntax
[root@neemotech root]#dir
20.su – to become a super user
syntax
[neemo@neemotech neemo]$su -
output wil be
[root@neemotech root#]
21.who by this command you can see the user name and their ip addresses   
who have loged in on your server
syntax
[root@neemotech root]#who
22.whoami this command shows your current logged in terminal user name
syntax
[root@neemotech root]#whoami
23.who am i this command shows you the logged in terminal number and user
name and more detailed information
Page 2Basic Commands
syntax
[root@neemotech root]#who am i
24.pwd to view the present working directory  
syntax
[root@neemotech root]#pwd
25.rpm -ivh to intall a rpm package
syntax
[root@neemotech root]#rpm -ivh packagename.rpm
rpm stands for ‘redhat package manager’
-i  stands for install
-v  stands for verbose mode
-h  stands for with hash sign(#)
26.rpm -q to querry about any rpm package  
syntax
[root@neemotech root]#rpm -q packagename
27.rpm -e to uninstall a rpm package
synatx
[root@neemotech root]#rpm -e package
28.find / -name to find any file or directory in linux file system
syntax
[root@neemotech root]#find / -name filename
29.su username to switch from one user to another users home directory
syntax
[root@neemotech root]#su neemo
output will be
[neemo@neemotech root]#cd
[neemo@neemotech neemo]#

30.su – username to switch from one user to another user users home
directory directly
syntax
[root@neemotech root]#su – neemo
31.useradd to create a new user
synatx
[root@neemotech root]#useradd username
32.passwd to give a password of a user
syntax
[root@neemotech root]#passwd neemo
output will be
give a password for user neemo:(here you have to type a password for neemo user)
confirm password:(again type the same password)
33.userdel to remove a user from linux
syntax
[root@neemotech root]#userdel neemo
Page 3Basic Commands
34.groupadd to add a new group
syntax
[root@neemotech root]#groupadd groupname
35.groupdel to delete a group
syntax
[root@neemotech root]#groupdel groupname
36.chown to change the ownership of a file or directory
syntax
[root@neemotech root]#chown ownername filename
example:
[root@neemotech /]#ls -l
output
drwxrw-rw-    2 root   root       4096 Mar 11 12:03 abcd
(permission)   (own)  (group own)(size)            (name)
[root@neemotech root]#chown neemo /abcd
in this example /abcd directory owner will be change to neemo user
effect
[root@neemotech /]#ls -l
drwxrw-rw-    2 neemo   root       4096 Mar 11 12:03 abcd
37.chgrp to change the group ownership of a file or directory
syntax
[root@nettec root]#chgrp newgroupownername filename
example
[root@neemotech /]#ls -l
drwxrw-rw-    2 neemo   root       4096 Mar 11 12:03 abcd
[root@neemotech root]#chgrp neemo /abcd
effect
[root@neemotech /]#ls -l
drwxrw-rw-    2 neemo   neemo       4096 Mar 11 12:03 abcd
38.chmod to change the permission of a file or directory
drwxrw-rw-    2 root   root       4096 Mar 11 12:03 abcd
(permission)   (ownr)  (grpownr) (size)            (name)                    IN
OCTAL VALUE
d  stands for directiry                                 READ=4
r  stands for read only permission                      WRITE=2
w  stands for write only permission                     EXECUTE=1
x  stands for execute only permission
drwxrw-rw- FIRST OCTET FOR DENOTING THE DIRECTORY OR FILE OR LINK FILE ETC.
SECOND THREE OCTET FOR USER OR OWNER PERMISSION (rwx OR 7 IN
OCTAL VALUE)
THIRD THREE OCTET FOR GROUP PERMISSION (rw- OR 6 IN OCTAL VALUE)
FORTH THREE OCTET FOR OTHERS PERMISSION (rw- OR 6 IN OCTAL VALUE)
SYNTAX
[root@nettec root]#chmod value fileordirectoryname
example
[root@neemotech /]#ls -l
drwxrw-rw-    2 neemo   root       4096 Mar 11 12:03 abcd
[root@neemotech /]#chmod 402 /abcd
[root@neemotech /]#ls -l
drw—–w-    2 neemo   neemo       4096 Mar 11 12:03 abcd
40.usermod to modify the user profile
Page 4Basic Commands
synatx
[root@neemotech root]#usermod -parameter groupname username

UNIX Commands for DBAs

UNIX Commands for DBAs

This article contains a brief list of commands that most UNIX DBAs will need on a regular basis. Over time I've been adding more Linux-related entries.
Related articles.

Basic File Navigation

The "pwd" command displays the current directory.
root> pwd
/u01/app/oracle/product/9.2.0.1.0
The "ls" command lists all files and directories in the specified directory. If no location is defined it acts on the current directory.
root> ls
root> ls /u01
root> ls -al
The "-a" flag lists hidden "." files. The "-l" flag lists file details.
The "cd" command is used to change directories.
root> cd /u01/app/oracle
The "touch" command is used to create a new empty file with the default permissions.
root> touch my.log
The "rm" command is used to delete files and directories.
root> rm my.log
root> rm -R /archive
The "-R" flag tells the command to recurse through subdirectories.
The "mv" command is used to move or rename files and directories.
root> mv [from] [to]
root> mv my.log my1.log
root> mv * /archive
root> mv /archive/* .
The "." represents the current directory.
The "cp" command is used to copy files and directories.
root> cp [from] [to]
root> cp my.log my1.log
root> cp * /archive
root> cp /archive/* .
The "mkdir" command is used to create new directories.
root> mkdir archive
The "rmdir" command is used to delete directories.
root> rmdir archive
The "find" command can be used to find the location of specific files.
root> find / -name dbmspool.sql
root> find / -print | grep -i dbmspool.sql
The "/" flag represents the staring directory for the search. Wildcards such as "dbms*" can be used for the filename.
The "which" command can be used to find the location of an executable you are using.
oracle> which sqlplus
The "which" command searches your PATH setting for occurrences of the specified executable.

File Permissions

See Linux Files, Directories and Permissions.
The "umask" command can be used to read or set default file permissions for the current user.
root> umask 022
The umask value is subtracted from the default permissions (666) to give the final permission.
666 : Default permission
022 : - umask value
644 : final permission
The "chmod" command is used to alter file permissions after the file has been created.
root> chmod 777 *.log

Owner      Group      World      Permission
=========  =========  =========  ======================
7 (u+rwx)  7 (g+rwx)  7 (o+rwx)  read + write + execute
6 (u+wx)   6 (g+wx)   6 (o+wx)   write + execute
5 (u+Rx)   5 (g+Rx)   5 (o+Rx)   read + execute
4 (u+r)    4 (g+r)    4 (o+r)    read only
2 (u+w)    2 (g+w)    2 (o+w)    write only
1 (u+x)    1 (g+x)    1 (o+x)    execute only
Character eqivalents can be used in the chmod command.
root> chmod o+rwx *.log
root> chmod g+r   *.log
root> chmod -Rx   *.log
The "chown" command is used to reset the ownership of files after creation.
root> chown -R oinstall.dba *
The "-R" flag causes the command ro recurse through any subdirectories.

OS Users Management

See Linux Groups and Users.
The "useradd" command is used to add OS users.
root> useradd -G oinstall -g dba -d /usr/users/my_user -m -s /bin/ksh my_user
  • The "-G" flag specifies the primary group.
  • The "-g" flag specifies the secondary group.
  • The "-d" flag specifies the default directory.
  • The "-m" flag creates the default directory.
  • The "-s" flag specifies the default shell.
The "usermod" command is used to modify the user settings after a user has been created.
root> usermod -s /bin/csh my_user
The "userdel" command is used to delete existing users.
root> userdel -r my_user
The "-r" flag removes the default directory.
The "passwd" command is used to set, or reset, the users login password.
root> passwd my_user
The "who" command can be used to list all users who have OS connections.
root> who
root> who | head -5
root> who | tail -5
root> who | grep -i ora
root> who | wc -l
  • The "head -5" command restricts the output to the first 5 lines of the who command.
  • The "tail -5" command restricts the output to the last 5 lines of the who command.
  • The "grep -i ora" command restricts the output to lines containing "ora".
  • The "wc -l" command returns the number of lines from "who", and hence the number of connected users.

Process Management

See Linux Process Management (ps, top, renice, kill).
The "ps" command lists current process information.
root> ps
root> ps -ef | grep -i ora
Specific processes can be killed by specifying the process id in the kill command.
root> kill -9 12345

uname and hostname

The "uname" and "hostname" commands can be used to get information about the host.
root> uname -a
OSF1 oradb01.lynx.co.uk V5.1 2650 alpha

root> uname -a | awk '{ print $2 }'
oradb01.lynx.co.uk

root> hostname
oradb01.lynx.co.uk

Error Lines in Files

You can return the error lines in a file using.
root> cat alert_LIN1.log | grep -i ORA-
The "grep -i ORA-" command limits the output to lines containing "ORA-". The "-i" flag makes the comparison case insensitive. A count of the error lines can be returned using the "wc" command. This normally give a word count, but the "-l" flag alteres it to give a line count.
root> cat alert_LIN1.log | grep -i ORA- | wc -l

Remove Old Files

The find command can be used to supply a list of files to the rm command or the "-delete" command can be used directly.
find /backup/logs/ -name daily_backup* -mtime +21 -exec rm -f {} ;

find /backup/logs/daily_backup* -mtime +5 -exec rm -f {} \;

find /backup/logs/daily_backup* -mtime +5 -delete;

File Exists Check

The Bash shell allows you to check for the presence of a file using the "[ -e filepath ]" comparison. In the following script a backup log is renamed if it is present and files older than 30 days are deleted are deleted.
#!/bin/bash
if [ -e /tmp/backup.log ]; then
  DATE_SUFFIX=`date +"%Y"-"%m"-"%d"`
  mv /tmp/backup.log /tmp/backup-$DATE_SUFFIX.log
fi

# Delete old log files.
find /tmp/backup*.log -mtime +30 -delete;
This is one example of a log rotation, where the most current log doesn't include the date in it's name.

Rotate Log Files

See the previous section for another variant on log rotation.
The following script provides an example of how to manage a log rotation using the Bash shell. The log file includes the date in the file name. Files older than 30 days are deleted.
#!/bin/bash
DATE_SUFFIX=`date +"%Y"-"%m"-"%d"`
LOG_FILE=/tmp/backup-$DATE_SUFFIX.log

# Do something that needs logging.
echo "Send this to log" >> $LOG_FILE 2>&1

# Delete old log files.
find /tmp/backup*.log -mtime +30 -delete;

Perform Action for Every File in a Directory

The following scripts shows two methods for performing an action for each file in a directory.
#!/bin/bash
for FILE in `ls /tmp/`; do
  # Do something with the file name.
  echo $FILE;
done

# Or this.

for FILE in $( ls /tmp/ ); do
  echo $FILE
done

Perform Action for Every Line in a File

The following scripts shows a method for performing an action for each line in a file.
#!/bin/bash
while read LINE; do
  # Do something with the line.
  echo $LINE;
done < /tmp/myfile.txt

alias

An alias is a named shortcut for a longer command using the following format.
alias name='command'
For example, if you require sudo access for a specific command, you might want to include this as an alias so you don't have to remember to type it.
alias myscript='sudo -u oracle /path/to/myscript'

Remove DOS CR/LFs (^M)

Remove DOS style CR/LF characters (^M) from UNIX files using.
sed -e 's/^M$//' filename > tempfile
The newly created tempfile should have the ^M character removed.
Where available, it is probably better to use the dos2unix and unix2dos commands.

Run Commands As Oracle User From Root

The following scripts shows how a number of commands can be run as the "oracle" user the "root" user.
#!/bin/ksh
su - oracle <<EOF
ORACLE_SID=LIN1; export ORACLE_SID
rman catalog=rman/rman@w2k1 target=/ cmdfile=my_cmdfile log=my_logfile append 
EOF
This is often necessary where CRON jobs are run from the root user rather than the oracle user.

Compress Files

See Linux Archive Tools (tar, star, gzip, bzip2, zip, cpio).
In order to save space on the filesystem you may wish to compress files such as archived redo logs. This can be using either the gzip or the compress commands. The gzip command results in a compressed copy of the original file with a ".gz" extension. The gunzip command reverses this process.
gzip myfile
gunzip myfile.gz
The compress command results in a compressed copy of the original file with a ".Z" extension. The uncompress command reverses this process.
compress myfile
uncompress myfile

General Performance

vmstat

Reports virtual memory statistics.
# vmstat 5 3
procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu------
 r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa st
 0  0      0 1060608  24372 739080    0    0  1334    63 1018 1571 14 11 66 10  0
 0  0      0 995244  24392 799656    0    0  6302   160 1221 1962 10 10 62 18  0
 0  0      0 992376  24400 799784    0    0     1    28  992 1886  3  2 95  0  0
#
See the vmstat man page.

free

Reports the current memory usage. The "-/+ buffers/cache:" line represents the true used and free memory, ignoring the Linux file system cache.
# free
             total       used       free     shared    buffers     cached
Mem:       8178884    4669760    3509124          0     324056    1717756
-/+ buffers/cache:    2627948    5550936
Swap:     10289148          0   10289148
#

iostat

Reports I/O statistics.
# iostat
Linux 3.2.10-3.fc16.x86_64 (maggie.localdomain)  03/19/2012  _x86_64_(4 CPU)

avg-cpu:  %user   %nice %system %iowait  %steal   %idle
           2.02    0.23    0.51    0.78    0.00   96.46

Device:            tps    kB_read/s    kB_wrtn/s    kB_read    kB_wrtn
sda               9.23       100.55        62.99    1796672    1125538
dm-0             13.60       100.31        62.99    1792386    1125524
dm-1              0.02         0.08         0.00       1432          0

#

CPU Usage

See Linux Process Management (ps, top, renice, kill).

sar

On Linux systems sar (System Activity Reporter) is probably one of the simplest and most versatile tools for reporting system utilization including CPU, memory, disk and network activity. It automatically collects system activity statistics when installed using the following command.
# yum install sysstat
The sar command syntax takes the following form.
# sar [options] [interval [count]]
The "options" parameters determine what is reported, which will be discussed later. The "interval" parameter indicates the time interval in seconds between samples. The "count" parameter indicates the number of samples that will be taken before the command ends. If "count" is omitted, the sampling will continue indefinitely. If both "interval" and "count" are omitted, the command will report the values from the 10 minute samples taken since the machine was last restarted.
As seen in the sar man page, there are lots of available options, but some starting points you may find interesting include:
  • CPU:
    • Basic CPU: sar [-u] [interval [count]]
    • Load Average: sar -q [interval [count]]
  • Memory:
    • Kernel Paging: sar -B [interval [count]]
    • Unused Memory: sar -r [interval [count]]
    • Swap Space: sar -S [interval [count]]
  • Disk:
    • Average Disk I/O: sar -b [interval [count]]
    • Disk I/O: sar -dp [interval [count]]
  • Network:
    • Network: sar -n DEV [interval [count]]
    • Network Errors: sar -n EDEV [interval [count]]
Here is an example of the output from a CPU report.
# sar -u 1 5
Linux 2.6.32-100.0.19.el5 (ol5-112.localdomain)  06/27/2011

03:10:07 PM     CPU     %user     %nice   %system   %iowait    %steal     %idle
03:10:08 PM     all      0.00      1.01     23.23     75.76      0.00      0.00
03:10:09 PM     all      0.00      1.02     35.71     63.27      0.00      0.00
03:10:10 PM     all      0.98      3.92     35.29     59.80      0.00      0.00
03:10:11 PM     all      0.00      1.03     29.90     69.07      0.00      0.00
03:10:12 PM     all      0.00      2.00     35.00     63.00      0.00      0.00
Average:        all      0.20      1.81     31.85     66.13      0.00      0.00
#

mpstat

Reports processor related statistics.
# mpstat 10 2
Linux 2.6.32-100.0.19.el5 (ol5-112.localdomain)  06/27/2011

01:59:57 PM  CPU   %user   %nice    %sys %iowait    %irq   %soft  %steal   %idle    intr/s
02:00:07 PM  all    1.21    0.00    0.90    0.20    0.00    0.00    0.00   97.69    980.50
02:00:17 PM  all    0.70    0.00    0.40    0.00    0.00    0.10    0.00   98.79    973.77
Average:     all    0.95    0.00    0.65    0.10    0.00    0.05    0.00   98.24    977.14
#
See the mpstat man page.

top

Displays top tasks.
# top
top - 13:58:17 up 2 min,  1 user,  load average: 2.54, 1.11, 0.41
Tasks: 160 total,   6 running, 154 sleeping,   0 stopped,   0 zombie
Cpu(s): 77.1%us, 22.6%sy,  0.0%ni,  0.0%id,  0.0%wa,  0.3%hi,  0.0%si,  0.0%st
Mem:   2058872k total,   879072k used,  1179800k free,    23580k buffers
Swap:  4095992k total,        0k used,  4095992k free,   620116k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
 2882 oracle    20   0  610m  64m  56m R 24.9  3.2   0:02.20 oracle
 2927 root      20   0 90328 3832 2604 R 24.6  0.2   0:00.89 Xorg
 2931 oracle    20   0  605m  34m  31m R 11.5  1.7   0:00.35 oracle
 2933 oracle    20   0  605m  34m  30m S  9.8  1.7   0:00.30 oracle
 2888 oracle    20   0  614m  52m  40m S  6.9  2.6   0:00.78 oracle
 2935 oracle    20   0  604m  22m  20m S  6.2  1.1   0:00.19 oracle
 2937 oracle    20   0  604m  19m  17m R  4.6  1.0   0:00.14 oracle
 2688 oracle    -2   0  603m  15m  13m S  4.3  0.8   0:01.08 oracle
 2685 oracle    20   0  603m  15m  13m S  0.7  0.8   0:00.22 oracle
 2939 oracle    20   0  217m 4084 3504 R  0.7  0.2   0:00.02 oracle
 2698 oracle    20   0  604m  18m  16m S  0.3  0.9   0:00.17 oracle
 2702 oracle    20   0  609m  22m  14m S  0.3  1.1   0:00.17 oracle
 2704 oracle    20   0  618m  21m  19m S  0.3  1.1   0:00.21 oracle
 2714 oracle    20   0  603m  20m  18m S  0.3  1.0   0:00.18 oracle
    1 root      20   0 10364  704  588 S  0.0  0.0   0:00.36 init
    2 root      20   0     0    0    0 S  0.0  0.0   0:00.00 kthreadd
    3 root      RT   0     0    0    0 S  0.0  0.0   0:00.00 migration/0
    4 root      20   0     0    0    0 S  0.0  0.0   0:00.00 ksoftirqd/0
    5 root      RT   0     0    0    0 S  0.0  0.0   0:00.00 watchdog/0
    6 root      20   0     0    0    0 S  0.0  0.0   0:00.03 events/0
    7 root      20   0     0    0    0 S  0.0  0.0   0:00.00 cpuset
    8 root      20   0     0    0    0 S  0.0  0.0   0:00.00 khelper
    9 root      20   0     0    0    0 S  0.0  0.0   0:00.00 netns
#
The PID column can then be matched with the SPID column on the V$PROCESS view to provide more information on the process.
SELECT a.username, 
       a.osuser, 
       a.program, 
       spid, 
       sid, 
       a.serial#
FROM   v$session a,
       v$process b
WHERE  a.paddr = b.addr
AND    spid = '&pid';
See the top man page.

Hide Passwords

You may be required to use passwords in scripts calling Oracle tools, like SQL*Plus, Export/Import and RMAN etc. One method to remove the credentials from the script itself is to create a credentials file to hold them. In this case I'm using "/home/oracle/.scottcred", which contains the following.
scott/tiger
Change the permissions to make sure the file is only visible to the owner.
$ chmod 600 /home/oracle/.scottcred
Now replace references to the credentials with the contents of the file.
$ expdp < /home/oracle/.scottcred schemas=SCOTT directory=DATA_PUMP_DIR dumpfile=SCOTT.dmp logfile=expdpSCOTT.log
Alternatively, consider using one of the following:

Automatic Startup Scripts on Linux

This text has been replaced by a separate article here.

CRON

See CRON : Scheduling Tasks on Linux.
There are two methods of editing the crontab file. First you can use the "crontab -l > filename" option to list the contents and pipe this to a file. Once you've editied the file you can then apply it using the "crontab filename".
  • Login as root
  • crontab -l > newcron
  • Edit newcron file.
  • crontab newcron
Alternatively you can use the "crontab -e" option to edit the crontab file directly.
The entries have the following elements.
field          allowed values
-----          --------------
minute         0-59
hour           0-23
day of month   1-31
month          1-12
day of week    0-7 (both 0 and 7 are Sunday)
user           Valid OS user
command        Valid command or script.
The first 5 fields can be specified using the following rules.
*       - All available values or "first-last".
3-4     - A single range representing each possible from the start to the end of the range inclusive.
1,2,5,6 - A specific list of values.
1-3,5-8 - A specific list of ranges.
0-23/2  - Every other value in the specified range.
The following entry runs a cleanup script a 01:00 each Sunday. Any output or errors from the script are piped to /dev/null to prevent a buildup of mails to root.
0 1 * * 0 /u01/app/oracle/dba/weekly_cleanup > /dev/null 2>&1

Cluster Wide CRON Jobs On Tru64

On clustered systems cron is node-specific. If you need a job to fire once per cluster, rather than once per node you need an alternative approach to the standard cron job. One approach is put forward in the HP best practices document (Using cron in a TruCluster Server Cluster), but in my opinion a more elegant solution is proposed by Jason Orendorf of HP Tru64 Unix Enterprise Team (TruCluster Clustercron).
In his solution Jason creates a file called /bin/cronrun with the following contents.
#!/bin/ksh
set -- $(/usr/sbin/cfsmgr -F raw /)
shift 12
[[ "$1" = "$(/bin/hostname -s)" ]] && exit 0
exit 1
This script returns TRUE (0) only on the node which is the CFS serving cluster_root.
All cluster wide jobs should have a crontab entry on each node of the cluster like.
5 * * * /bin/cronrun && /usr/local/bin/myjob
Although the cron jobs fire on all nodes, the "/bin/cronrun &&" part of the entry prevents the script from running on all nodes except the current CFS serving cluster_root.

NFS Mount (Sun)

The following deamons must be running for the share to be seen by a PC.
  • /usr/lib/nfs/nfsd -a
  • /usr/lib/nfs/mountd
  • /opt/SUNWpcnfs/sbin/rpc.pcnfsd
To see a list of the nfs mounted drives already present type.
exportfs
First the mount point must be shared so it can be seen by remote machines.
share -F nfs -o ro /cdrom
Next the share can be mounted on a remote machine by root using.
mkdir /cdrom#1
mount -o ro myhost:/cdrom /cdrom#1

NFS Mount (Tru64)

On the server machine, if NFS is not currently setup do the following.
  • Application Manager -> System Admin -> Configuration -> NFS
  • Select the "Configure system as an NFS server" option.
  • Accept all defaults.
Create mount point directory.
mkdir /u04/backup
Append the following entry to the "/etc/exports" file.
/u04/backup
Make sure the correct permissions are granted on the directory.
chmod -R 777 /u04/backup
On the client machine, if NFS is not currently setup do the following.
  • Application Manager -> System Admin -> Configuration -> NFS
  • Select the "Configure system as an NFS client" option.
  • Accept all defaults.
Create mount point directory.
mkdir /backup
Append an following entry to the "/etc/fstab" file.
nfs-server-name:/u04/backup     /backup         nfs rw,bg,intr 0 0
Finally, mount the fileset.
mount /backup
At this point you can start to use the mount point from your client machine. Thanks to Bryan Mills for his help with Tru64.

Samba/CIFS Mount (Linux)

See Linux Samba Configuration.
Create a directory to use for the mount point.
# mkdir /host
Add the following line to the "/etc/fstab" file.
//192.168.0.4/public /host   cifs rw,credentials=/root/.smbcred,uid=500,guid=500 0 0
Create a file called "/root/.smbcred" with the following contents.
username=myuser
password=mypassword
Change the permissions on the credentials file.
# chmod 600 /root/.smbcred
Mount the share.
# mount /host

PC XStation Configuration

Download the CygWin setup.exe from http://www.cygwin.com.
Install, making sure to select all the X11R6 (or XFree86 in older versions) optional packages.
If you need root access add the following entry into the /etc/securettys file on each server.
<client-name>:0
From the command promot on the PC do the following.
set PATH=PATH;c:cygwinbin;c:cygwinusrX11R6bin
XWin.exe :0 -query <server-name>
The X environment should start in a new window.
Many Linux distributions do not start XDMCP by default. To allow XDMCP access from Cygwin edit the "/etc/X11/gdm/gdm.conf" file. Under the "[xdmcp]" section set "Enable=true".
If you are starting any X applications during the session you will need to set the DISPLAY environment variable. Remember, you are acting as an XStation, not the server itself, so this variable must be set as follows.
DISPLAY=<client-name>:0.0; export DISPLAY

xauth (Magic Cookie)

Access to X servers can get broken when using su and sudo commands. The xauth command provides a solution to this. The process involves the following stages:
  • Check your current display number.
  • Use xauth list to get a list of magic cookies.
  • Switch to the new user.
  • Use xauth add to set the magic cookie for your display number.
An example of this is shown below.
$ echo $DISPLAY
localhost:12.0
$ xauth list
ol6.localdomain/unix:12  MIT-MAGIC-COOKIE-1  be64852468ca3c334720b10bb3c4d3cb
$ sudo su oracle
$ xauth add ol6.localdomain/unix:12  MIT-MAGIC-COOKIE-1  be64852468ca3c334720b10bb3c4d3cb
You will now be able to access the X server, just as you could before the user switch.

Useful Profile Settings

See Linux Groups and Users : Important Files.
The following ".profile" settings rely on the default shell for the user being set to the Korn shell (/bin/ksh).
The backspace key can be configured by adding the following entry.
stty erase "^H"
The command line history can be accessed using the [Esc][k] by adding the following entry.
set -o vi
Auto completion of paths using a double strike of the [Esc] key can be configured by adding the following entry.
set filec

Useful Files

Here are some files that may be of use.
Path Contents
/etc/passwd User settings
/etc/group Group settings for users.
/etc/hosts Hostname lookup information.
/etc/system Kernel parameters for Solaris.
/etc/sysconfigtab Kernel parameters for Tru64.
/etc/sysctl.conf Kernel parameters for Linux.
For more information see:
 Hope this helps. Regards Tim...

Easy Oracle Linux Commands


Easy Oracle Linux Commands

Mastering Linux syntax is complex, and these excerpts from some Rampant Easy Linux books are a great reference:



 

Basic LINUX commands that a DBA should know

Basic LINUX commands that a DBA should know

groupadd 
This is the command used to create new group. At OS level group is used to give and take  pivillages.
Syntax : groupadd <group name>
Ex : [root@rac5 ~]# groupadd group1
View : [root@rac5 ~]# cat /etc/group  -This command used to view which user belongs to which group.
Output: group1:x:607:

useradd 
This is the command used to create a new user in a group.
Syntax : useradd -g <group name> <user name>
Ex : [root@rac5 ~]# useradd -g group1 user1

passwd
This is the command used to give password for create use or to update the password.
Syntax : passwd <user name>
Ex: [root@rac5 ~]# passwd user1
Output :
[root@rac5 ~]# Changing password for user soufir.
New UNIX password:
BAD PASSWORD: it is based on a dictionary word
Retype new UNIX password:
passwd: all authentication tokens updated successfully.

date
a. This is the command used to view the current system date.
Syntax : date
Output : Wed Oct 27 21:55:36 IST 2010
b. In order to update the date we can give :
Syntax : [root@rac5 ~]# date -s "2 OCT 2010 14:00:00"  OR
[root@rac5 ~]# date --set="27 OCT 2010 21:56:00"
Output : Sat Oct  2 14:00:00 IST 2010

cal
This command shows the calender of current year or any.
Ex : [root@rac5 ~]#  Cal
Output : [root@rac5 ~]#    October 2010
                        Su Mo Tu We Th Fr Sa
                            1  2
             3  4  5  6  7  8  9
            10 11 12 13 14 15 16
            17 18 19 20 21 22 23
            24 25 26 27 28 29 30
            31

pwd 
This command is to view the present working directory.
Ex : [root@rac5 ~]# pwd
Output : [root@rac5 ~]# /root.

cd
a.This is the command used to change a directory
Ex : [oracle@rac5 ~]$ ls
authorized_keys  file   file2  oraInventory  stand.ora
authorized-keys  file1  file3  soufir
[oracle@rac5 ~]$ cd soufir
[oracle@rac5 soufir]$
b.This is used to go back to parent directory
Ex : cd ..

mkdir
This command is used for make a new directory.
 Ex : mkdir dir1

rmdir
This commad is used for remove a directory.
 Ex : rmdir dir1

rm -rf
This command is used to forcefully remove a direcory.
Ex : rm -fr dir1

man
This command is used to show the online manual pages of related commands
Ex : man ls

ls
This command is used to list all contents of directories
Ex : ls

ls -lt
This command is used to list lot of information about contents of directories
Ex : ls -lt
The permissions are the first 10 characters of the line (-rwxrwx---) and can be broken down as follows.

-
rwx
r--
r--
1
root
root
765
Apr 23
file.txt
File type
Owner
Group
All
Links
Owner
Group
Size
Mod date
Filename


touch
This command is used create an empty file
Ex : touch file1

cat
This command is used to create and view files of directories
Ex : cat file1
cat file1 > newfile   // owerwrite newfile with file1
cat file1 >> newfile  // append newfile the contents with file1

cp
This command is used to copy a file from one to another 
Ex : cp file1 filenew 

mv
This command is used to rename the name of a file to other
Ex : mv file1 filenew

su
This command is used to switch one user to other. it doesnot change the current working directory. so you cant access the /usr/sbin  directories.
Ex : su soufir

su -
This command is used to switch one user with changing current working directory.
Ex : su - soufir