UNIXLInux For Oracle DBAMustKnow-libre
UNIXLInux For Oracle DBAMustKnow-libre
DBA TEAM
Revision History
Date
13/05/013
Revision
1.0
Name
VikramGrg
Reviewer
Ashish Man. Baisyet
/dev/sda2
/dev/sda1
tmpfs
du command
Display how much disk space is being used by directories.
[oracle@asmdb asmsoft]$ du -ak /softwares/asmsoft/
-a - Shows counts for all files encountered, not only directories.
-k - Use 1024 byte blocks instead of the default 512.
Basic File Navigation
Head command prints the first N number of data of the given input. By default, it prints first 10
lines of each given file.
tail
Show last lines of a file.
$tail -500 alert.log
man
#Print only the last 500 lines of the alert log file.
The Linux command "man" is used at the command line to explain the functions and definitions
of other commands commonly used within Linux. The term "man" is short for manual pages
and gives you a very in-depth explanation of the said command which you are referring to.
$ man ls
$ man chown
"pwd" command displays the present working directory.
[oracle@asmdb ~]$ pwd
/u01/app/oracle/product/11.2.0/dbhome_1
The "ls" command lists all files and directories in the specified directory. If no location is defined
it acts on the current directory.
[oracle@asmdb ~]$ ls
[oracle@asmdb ~]$ ls /u01
[oracle@asmdb ~]$ ls al
$ ls l or ll (Listing in long format).
The "-a" flag lists hidden "." files.
The "-l" flag lists file details (Listing in long format).
"cd" command -> change directories.
[oracle@asmdb ~]$ cd /u01/app/oracle
[oracle@asmdb oracle]$ pwd
/u01/app/oracle
"touch" -> create a new empty file.
[oracle@asmdb ~]$ touch my.log
vi Editor
The default editor that comes with the UNIX/Linux operating system is called vi (visual editor)
* :q!<Return> quit vi even though latest changes have not been saved for this vi call
cat ->Display one or more files contents.
[oracle@asmdb ~]$ cat pfile1.ora
"rm" command -> to delete files and directories.
[oracle@asmdb ~]$ rm my.log
[oracle@asmdb ~]$ rm -rf /softwares/asmsoft1
Recursively(-r) deletes directories and subdirectories with contents forcefully(-f) without
prompt.
"mv" command -> move/rename files and directories.
[oracle@asmdb ~]$ mv myfile.log myfile_bk.log
[oracle@asmdb ~]$ mv * /softwares/asmsoft/
[oracle@asmdb ~]$ mv /archive/arch_bk/* .
File Permissions
Linux Files, Directories and Permissions.
"umask" command -> read or set default file permissions for the current user.
[root@asmdb ~]# umask 022
The default umask value is 0022, which decides the default permission for a new file or
directory. Default permission for a directory is 0777, for files the permissions are 0666 from
which the default umask value 0022 is deducted to get the newly created files or directory
permission.
Note:- The umask value is subtracted from the default file permissions (666) to give the final
permission.
666 : Default permission
022 : - umask value
644 : final permission
Final default permission for a file is calculated as shown below:
Default file permission: 666
Default umask : 022
Final default file permission: 644
Final default permission for a directory is calculated as shown below:
Default directory permission: 777
Default umask: 022
Final default directory permission: 755
"chmod" command -> alter file/folder permissions.
chmod stands for change mode.
[root@asmdb ~]# chmod -R 775 /softwares/
Character eqivalents can be used in the chmod command.
[root@asmdb ~]# chmod o+rwx *.log
[root@asmdb ~]# chmod g+r softwares
[root@asmdb ~]# chmod -Rx *.log
Here u-> user, g-group, o-other
Permission Equivalence
Value
Permission
read (r)
write (w)
execute (x)
OS Users Management
"useradd" command to add OS users.
[root@asmdb ~]# useradd -g oinstall -G asmadmin,asmdba,asmoper -d /home/grid -s
/bin/bash grid
"-g " specifies the primary group.
"-G " specifies secondary groups.
"-d" specifies the default directory.
"-s" specifies the default shell.
-u, --uid UID
The numerical value of the user as ID. This value must be unique, unless the -o option is
used.
usermod" command is used to modify the user settings.
[root@asmdb ~]# usermod -g oinstall -G dba,oper,asmdba oracle
"userdel" command is used to delete existing users.
[root@asmdb ~]# userdel -r npuser
Delete the specified user recursively (deleting its home directory also).
groupadd
Creates a new group account.
[root@asmdb ~]# groupadd dba
Make sure it is created successfully.
The RPM Package Manager (RPM) is an open packaging system, which runs on Red Hat
Enterprise Linux as well as other Linux and UNIX systems. Red Hat, Inc. encourages other
vendors to use RPM for their own products. RPM is distributed under the terms of the GPL.
yum (Yellowdog Updater Modified) is an interactive, rpm based, package manager. perform
installation of new packages, removal of old packages and perform queries on the installed
and/or available packages among many other commands/services.
[root@asmdb ~]# yum install sysstat*.rpm
CRON jobs
CRON : Scheduling Tasks on Linux.
"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)
command
Valid command or script.
Example:Execute every Friday 1AM
So if we want to schedule the script to run at 1AM every Friday, we would need the following
cronjob:
[oracle@asmdb asmsoft]$ crontab -e
0 1 * * 5 /bin/execute/this/script.sh
Mount
The following examples illustrate typical uses of the command mount for attaching the file
directory of a device or partition to the file directory tree of the Linux system.
# mkdir /cdmount
# mount /dev/cdrom /cdmount
Append the mount point as following entry to the "/etc/fstab" file( if required) (for making
permanent mount point).
nfs-server-name:/u04/backup
/backup
nfs rw,bg,intr 0 0
Useful Files
Here are some files (system administration files) that may be of use.
Path
Contents
/etc/passwd
User settings
/etc/group
/etc/hosts
/etc/system
The ps (i.e., process status) command is used to provide information about the currently
running processes.
$ ps -ef | grep pmon
ps aux | grep oracle
$ ps -aux | more
-a :
-u :
-x :
option adds to the list processes that have no controlling terminal, such as daemons.
2) Linux Performance Monitoring:a. iostat reports CPU, disk I/O, and NFS statistics.
b. vmstat reports virtual memory statistics.
c. mpstat reports processors statistics.
a) iostat
:- The iostat command is used for monitoring system input/output device loading by
observing the time the devices are active in relation to their average transfer rates
b) vmstat
:- Report virtual memory statistics:- is a tool that collects and reports data about your
system's memory, swap, and processor resource utilization in real time.
It can be used to determine the root cause of performance and issues related to memory use.
The following example illustrates an interval of one (2) second twenty (10) times:
[oracle@npsoftdb ~]$ vmstat 2 10
Using ramfs or tmpfs you can allocate part of the physical memory to be used as a partition.
tmpfs:- shm / shmfs is also known as tmpfs, which is a common name for a temporary file
storage facility on many Unix-like operating systems. It is intended to appear as a mounted file
system, but one which uses virtual memory instead of a persistent storage device.
tmpfs size should be 75% of your physical RAM as per recommendation
tmpfs will use swap space when necessary. If you don't specify the tmpfs size, it'll be
half of your physical RAM without swap.
Swap partition
swap file or swap partition used by operating systems (Linux/UNIX/Windows) to provide
virtual memory.
Total of swap and physical memory is the virtual memory.
Note:- You can use /dev/shm to improve the performance of application software such as
Oracle or overall Linux system performance.
On heavily loaded system, it can make tons of difference.
$ ipcs -m
To make this swap space partition available even after the reboot, add the following line to the
/etc/fstab file.
# vi /etc/fstab
/dev/ sda5
swap
swap defaults
00
Verify whether the newly created swap area is available for your use.
# swapon s
# free m
If you do t ha e a y additio al disks, you ca create a file so e here o your filesyste
dd command), and use that file for swap space.
usi g