Professional Documents
Culture Documents
Unix/Linux Commands For Oracle Dbas Dba Team
Unix/Linux Commands For Oracle Dbas Dba Team
DBA TEAM
Revision History
df command in Linux provides disk space usage information of your file systems.
[oracle@asmdb ~]$ df -h
du command
Display how much disk space is being used by directories.
tail
Show last lines of a file.
$tail -500 alert.log #Print only the last 500 lines of the alert log file.
man
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
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
vi Editor
The default editor that comes with the UNIX/Linux operating system is called vi (visual editor)
[oracle@asmdb ~]$ vi filename.txt
The vi editor has three modes, command mode, insert mode and command line mode.
To Exit vi
Usually the new or modified file is saved when you leave vi. However, it is also possible
to quit vi without saving the file.
* :q!<Return> quit vi even though latest changes have not been saved for this vi call
chggrp
Change group of the named file or directory.
Example:
$ su - root #switch to root account (or use “su –“ only).
$ chgrp oracle test.txt #Change the group ownership of the test file.
$ ls –l test #Display again the test file information using the long list
format (-l)
File Permissions
"umask" command -> read or set default file permissions for the current user.
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.
Permission Equivalence
Value Permission
4 read (r)
2 write (w)
1 execute (x)
"chown" command -> reset/change the ownership of files/directories.
OS Users Management
The numerical value of the user as ID. This value must be unique, unless the -o option is
used.
Delete the specified user recursively (deleting its home directory also).
groupadd
dba:x:502:oracle,grid
If you want to create a group with a specific group id, do the following.
Process Management
[root@asmdb ~]# ps
[root@asmdb ~]# ps -ef | grep pmon
Specific processes can be killed by specifying the process id in the kill command.
The "uname" and "hostname" commands can be used to get information about the host.
[oracle@asmdb ~]$ uname -a
Linux asmdb.nepasoft.com.np 2.6.18-8.el5 #1 SMP Fri Jan 26 14:15:21 EST 2007 i686 i686 i386
GNU/Linux
[oracle@asmdb ~]$ hostname
asmdb.nepasoft.com.np
In order to save space on the file system you may wish to compress files such as archived redo
logs. This can be using either the gzip or compress commands or Other Compression methods.
gzip myfile
gunzip myfile.gz
free -m
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.
CRON jobs
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
View all Mount points
# mount
Append the mount point as following entry to the "/etc/fstab" file( if required) (for making
permanent mount point).
mount /backup
Useful Files
Here are some files (system administration files) that may be of use.
Path Contents
The following example illustrates an interval of one (2) second twenty (10) times:
[oracle@npsoftdb ~]$ vmstat 2 10
Here: 'r' the run queue ,
'b' the wait queue
In the default operation, vmstat displays memory statistics in kilobytes.
Note:- If the sum of columns id (Idle) and wa (Wait IO) is almost 100,this means there are
some configuration problems.
Because the machine is seem it does not doing anything but disk IO operations.
Tmpfs on Linux:-
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.
To see all shared memory segments that are allocated on the system, execute:
$ ipcs -m
If counter is greater than 0, then the resource is available, and if the counter is 0 or less, then
that resource is busy or being used by someone else. This simple mechanism helps in
synchronizing multithreaded and multiprocess based applications
(Semaphores can be thought of as simple counters that indicate the status of a resource)
[root@npsoftdb ~]# df -h
# mkdir -p /mnt/tmp
# df –h
# 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 don’t have any additional disks, you can create a file somewhere on your filesystem(using
dd command), and use that file for swap space.