UNIX Basics for Oracle DBA
Introduction:
Linux is a flavor of UNIX and it is not user friendly and it is case sensitive. It was introduced in 1991 by "Linux Torald"
Def:
Operating System:- An O.S is a software that manage computer hardware and provides a convenient and safe environment for running programs. It acts as an interpreter between program and the hardware resources (monitor, keyboard, etc).
LINUX Architecture:-
Kernal:- A set of functions that wake up's the heart of an operating system. It is used to provided an application interface between programs and physical devices.
- Service provide by the kernal
- Controls execution of process
- Scheduling process fairly for execution on CPU
- Allocate memory for execution
File System:- File System provides organized way of storing and retrieving the data. This is classified in Four types. They are
- Physical File System
- Logical
- Swap in Linux (virtual in windows)
- Network File System
Swap:- In the hard disk the space supports to the RAM for system performance. It acts as a temporary RAM. In windows it is called virtual file the system.
"/ ":- this is the root directory. It is a top of the file system structure all the other directories are mounted under it.
"/boot":- It contains the kernel the core of the operating system. It also contains the files relating to booting the system. Such as boot loader and the initiate RAM Disk.
"/root" :- It is the default Home Directory for root (administrator).
"cd /home" It contains all normal users Home Directory.
"/bin" (Binary's):- It contains commands which are used by normal users and also administrators.
"/sbin" :- It contains administrator related commands. It is not used by normal users.
"/var":- It contains variable information such as Locks, Print, Mail, FTP, Account, cache.
"/usr"(Unix System Resource):- It contains the program and application which are available for users.
"/etc":- It contains all configuration files.
"/dev":- It contains device loads through which the operating system through the H/W & S/W device.
"/tmp":- It contains tempfile gives to the system.
"/proc":- It is a mount point for virtual information about the current running system process.
"/obd":- It contains the 3rd party S/W. Ex:- Media-player, Yahoomsg.
"/media":- It is the default location for Removable Devices such as DVD, pendrive,etc.
"/lib":- It contains library's need by no. of different applications as well as Link kernal.
hostname - ip address will be shown
Example: hostname -i
to set this ip address we give the command is
PWD Present Working/Current Directory
ls Listing the files & Directories.
ls -l Long List
ls -a It shows hidden files
ls -r Reverse order
ls -R To see the particular data of the nested files.
ls -d Directory name is shows
ls -l -S List the files along with size sorting
ls -l -s means Block Size
ls -ltr List the file along with Time & Date.
clear (ctl+l) clear the screen.
Valid card Character:-
* means Multiple Character.
? means Single Character.
Example:- ls r* to shows list files start with r.
File Creation:
File creation are 3 types. They are
1. cat
2. touch
3. vi editor
cat :- By using this we can create new files and also adding new line to an existing file and also we can see file contents.
Example:-
cat > ravi to create the file
xxx
xxx
xxx
xxx
zzz
zzz
ctrl + d --> to save the file.
cat ravi to display the file contents
cat >> ravi Adding New Lines
111
111
111
111
ctrl + d
cat > dba
cat ravi dba >> oracle
cat oracle
touch:- It will creates only n number of empty files but we cannot insert any single character or byte data and we can change Date & Time stamp of File or Directory.
Example:-
touch empty
touch -t 11230832 ravi
ls -ltr
vi editor:-(Visual Interface Editor) It is use for supporting to insert or manage the data.
Editors at Different operating Systems:
For windows Notepad
Dos Edit
Linux command mode vi, ex, nani,etc,.
sysntax:
vi <file name>
In VI editors there are 3 modes available.
1. INSERT mode
2. COMMAND mode
3. EXECUTE mode
steps for vi editor managing:
we open a file with vi command, then the files opened with command mode
when will you go to save & exit that is execute mode
press i,I,a,A,o,O go to insert mode for command.
press 'Esc' key then we can do some actions like copy delete.
press 'Shift + : ' we enter into execution mode from command mode in that we can save/replace etc.
If you want to move from insert mode to execute mode and from execution mode to insert mode 1st we move into command mode.
how to enter into insert mode:
i insert the data at current cursor position
I at the Beginning of the line cursor
a append after cursor position
A append at the end of line
o Insert a line below & enter into insert mode
O Insert a line above & enter into insert mode
r Replace Single Character
R Replace the word
s Delete the current cursor position after insert
S/cc Deletes the entire line & insert
C Delete the after cursor position line
command mode options:-
dd Delete a line
2dd Delete 2 lines
ldw Delete one word
d7w Delete 7 words
x Delete single character after cursor position
10x Delete 10 character after cursor position
X Delete single character before cursor position
10X Delete 10 character before cursor or position
yy copy a line
5yy copy five lines
p paste
u undo
ctrl + R Redo
gg go to 1st line
G go to last line
G99 go to 99th line
shift + zz Save &Exit
h move to left side
l move to right side
j move to next line
k move to above line
n go to the next searching word
/<find> we can find a particular word
Execute mode commands:
:q quite
:q! quite with forcefully
:w save
:wq save & quite
:wq! save quite with forcefully
:x save and exit
:se nu set number(col set number)
:se nonu set no number removes line number
Replacing the words:-
:1,$s/existing word/new word/gc
1 means replace starts from 1st line
$ replace can do up to last time
s means substitute
g global
c conformation
Navigation commands:-
cd Change Directory or move into another directory
syntax:
cd <directory name>
cd .. move to one level back
note: single dot it represents current working directory
double dot represents parent working Directory
cd ../../ move to the 2nd level back
cd - move to the last working directory
cd ~ move to the current user logging home directory
copy/move the file Directory:
syntax:
1. only copy the files
cp < source path> <destination path>
2. copy the directory
cp -r <source path> < destination path>
move the File or Directory:
mv <source path> <destination path>
Remove File or Directory command:-
rm <file name> removing the file
rm -f <file name> removing file forcefully
rm -rf <directory name> remove the directory forcefully
rmdir <directory name> remove the directory forcefully
Links:- There are 2 types of links.
1. Hard Link
2. Soft Link
def: gives a pointer to the particular file. The particular file is called link.
Hard Link Syntax:
ln <source > <destination>
soft link Syntax:-
ln -s source destination
Difference between Hard and Soft Links:
fdisk -l Hard disk configuration
df Disk Free
df -k It shows the mount points in kilobyte.
df -h It shows the mount points in GB
du -h du means disk use file name/ directory name/mount point
Example: du -h /d01
du -sh <file name> shows the total size of file or directory
cat /etc/passwd to see how many users used.
cat /etc/group to see the group
groupdel <group name> to delete groups
cal it shows calender
Example: cal 2012
date to see the Date & Time
date +%b It shows the 3 digits of the month
date +%B It shows the full name of the month
date +%D It shows the date in number
date +%y It shows the year in 2 digits
date +%Y It shows the year in full
gcalctool (or) gnome-calculator to open calculator window.
man (manuals) to show the documentation of the commands
Example: man ls, man df
swap addition:-
swapon -s it shows swap memory size.
swapoff /dev/sda9 those are used to show the details.
free it shows the RAM size and shows the swap size how much free or used
1) Type: It is a file. It has 3 options.
d - means Directory
l - linked
- - file
2) Access permission.
rwx - user
r- - - Groups
r- - - others
3) 1 means link
4) A user/owner of the file
5) group
6) sizing bytes
7) Date & Time
8) File/Directory/linkname
In types are different options are there. They are
p - process file
s - socket file
B - Block Device
C - character device file
Access Mode Access Level
Read (r) USER
Write(w) GROUP
Execute(x) OTHERS
File permission mode:
There are 2 types of file permissions.
1. Symbolic:- in t
2. Numerical / absolute
Symbolic mode:- In this mode we use characters.
Permission Identification character
Read r
write w
Execute x
User u
Group g
others o
controllers:-
Add the permission use '+'
Remove permission use '-'
Equal permission use '='
Numerical or absolute:-
In this mode we will use numbers.
The Read permission for '4'
Write permission for '2'
Execute permission for '1'
Permissions Number
NILL 0
Execute 1
Write 2
Write & Execute 3
Read 4
Read & Execute 5
Read & Write 6
Read,Write & Execute 7
Default Directory Permission:-
chmod -R 777 ravi
R means Recursively
top load average
press 'u' and type user name
'q' means quit.
vmstat Virtual Memory Statistics
iostat input status of the CPU
To set this ip address we give the command is
vi /etc/hosts
Example:
192.168.1.777 ravi.dba.com ravi
to restart the Network Services without restart
# service network restart
Process Kill:
kill -9 <process name/number>
$ replace can do up to last time
s means substitute
g global
c conformation
Navigation commands:-
cd Change Directory or move into another directory
syntax:
cd <directory name>
cd .. move to one level back
note: single dot it represents current working directory
double dot represents parent working Directory
cd ../../ move to the 2nd level back
cd - move to the last working directory
cd ~ move to the current user logging home directory
copy/move the file Directory:
syntax:
1. only copy the files
cp < source path> <destination path>
2. copy the directory
cp -r <source path> < destination path>
move the File or Directory:
mv <source path> <destination path>
Remove File or Directory command:-
rm <file name> removing the file
rm -f <file name> removing file forcefully
rm -rf <directory name> remove the directory forcefully
rmdir <directory name> remove the directory forcefully
Links:- There are 2 types of links.
1. Hard Link
2. Soft Link
def: gives a pointer to the particular file. The particular file is called link.
Hard Link Syntax:
ln <source > <destination>
soft link Syntax:-
ln -s source destination
Difference between Hard and Soft Links:
fdisk -l Hard disk configuration
df Disk Free
df -k It shows the mount points in kilobyte.
df -h It shows the mount points in GB
du -h du means disk use file name/ directory name/mount point
Example: du -h /d01
du -sh <file name> shows the total size of file or directory
cat /etc/passwd to see how many users used.
cat /etc/group to see the group
groupdel <group name> to delete groups
cal it shows calender
Example: cal 2012
date to see the Date & Time
date +%b It shows the 3 digits of the month
date +%B It shows the full name of the month
date +%D It shows the date in number
date +%y It shows the year in 2 digits
date +%Y It shows the year in full
gcalctool (or) gnome-calculator to open calculator window.
man (manuals) to show the documentation of the commands
Example: man ls, man df
swap addition:-
swapon -s it shows swap memory size.
swapoff /dev/sda9 those are used to show the details.
free it shows the RAM size and shows the swap size how much free or used
1) Type: It is a file. It has 3 options.
d - means Directory
l - linked
- - file
2) Access permission.
rwx - user
r- - - Groups
r- - - others
3) 1 means link
4) A user/owner of the file
5) group
6) sizing bytes
7) Date & Time
8) File/Directory/linkname
In types are different options are there. They are
p - process file
s - socket file
B - Block Device
C - character device file
Access Mode Access Level
Read (r) USER
Write(w) GROUP
Execute(x) OTHERS
File permission mode:
There are 2 types of file permissions.
1. Symbolic:- in t
2. Numerical / absolute
Symbolic mode:- In this mode we use characters.
Permission Identification character
Read r
write w
Execute x
User u
Group g
others o
controllers:-
Add the permission use '+'
Remove permission use '-'
Equal permission use '='
Numerical or absolute:-
In this mode we will use numbers.
The Read permission for '4'
Write permission for '2'
Execute permission for '1'
Permissions Number
NILL 0
Execute 1
Write 2
Write & Execute 3
Read 4
Read & Execute 5
Read & Write 6
Read,Write & Execute 7
Default Directory Permission:-
chmod -R 777 ravi
R means Recursively
top load average
press 'u' and type user name
'q' means quit.
vmstat Virtual Memory Statistics
iostat input status of the CPU
To set this ip address we give the command is
vi /etc/hosts
Example:
192.168.1.777 ravi.dba.com ravi
to restart the Network Services without restart
# service network restart
Process Kill:
kill -9 <process name/number>