Oracle
Oracle
DOCUMENTS
JAVA,ORACLE,UNIX
1 | Page
JAVA
Page | 2
1. In
tr
od
uc
tio
n
to
Ja
va
2. O
O
PS
co
nc
ep
ts
3. Ac
ce
ss
M
od
if
er
s
4. Da
ta
Ty
pe
s
5. Ar
ra
ys
Introduction to Java:
Java is a object oriented language because it deals with objects i.e., like comparing
one object with other or call one object with other. Java is simple, robust, secure,
portable, object-oriented programming language, platform independent.
OOPS Concepts:
Class
Object
Abstraction
Page | 3
Encapsulation
Inheritance
Polymorphism
Page | 4
3.Protect
4.Default
Business implementation: Access modifiers are the most important while we are
developing our code because it is the scope where we define the data that can be
retried globally or locally.
Generally, we dont know where to use and how to use while we are developing a
code for an application. We need to follow the business requirements, Naming
conventions and keep the code in short and simple way for better way of
understanding. The coding should be simple and short.
Generics:
Page | 5
Generic methods and generic classes enable programmers to specify, with a
single method declaration, a set of related methods, or with a single class
declaration, a set of related types. Generics is used for sorting arrays of
objects.
Annotations:
Annotations form of metadata, provide data about a program that is not part
of the program itself. Annotations have no direct effect on the operation of
the code they annotate.
Uses of annotations:
Collections:
Collections is a single unit of objects and is a framework that provides an
architecture to store and manipulate the group of objects.
By using java collection you perform all the operations on a data such as
searching, sorting, insertion, manipulation, deletion etc.
1. Collections provides readymade architecture.
2.They represents set of classes and interface.
Page | 6
Iterator interface:
Iterator interface provides the facility of iterating the elements in forward
direction only.
It iterates the list of objects and removing can also be done.
There are two ways to iterate the elements collections in java. They are:
1. By iterator interface
2. By for-each loop interface
Fail Fast iterator : Hash map - Fail fast contains the original collection of
objects we are unable to remove the objects.
Fail Safe Iterator : Hash table - Fail safe contain the copy of original
objects , so we are able to remove the objects easily by using Remove().
Lists:
Array List:
Page | 7
Java Array List class uses a dynamic array for storing the elements. It
extends Abstract List class and implements List interface. Java Array List
class can contain duplicate elements and also maintains insertion order.
1. Java Array List class is non synchronized.
2. It allows random access because array works at the index basis.
3. In this class, manipulation is slow because a lot of shifting needs to be
occurred if any element is removed from the array list.
There are two array lists in the java collections. They are:
1. Non-generic:
Sets:
Hash Set:
A hash set uses hash table to store the elements. It extends Abstract Set
class and implements Set interface and contains unique elements only.
Page | 8
A linked hash set contains unique elements only like Hash Set. It extends
Hash Set class and implements Set interface and maintains insertion order.
Tree Set:
A tree set contains unique elements only like Hash Set. The Tree Set class implements
Navigable Set interface that extends the Sorted Set interface. Maintainsascending order.
Maps:
A map contains values on the basis of key i.e. key and value. Each key and
value pair is known as an entry. Map contains only unique keys.Map is
useful if you have to search, update or delete elements on the basis of key.
Entry Interface:
Entry is the sub interface of Map. So we will be accessed it by Map.Entry
name. It provides methods to get key and value.
Exception Handling:
The exception handling in java is one of the powerful
mechanismtohandletheruntime errors so that normal flow of the application
can be maintained without any interruptions.
There are three types of exceptions:
1. Checked Exception
2. Unchecked Exception
Page | 9
3. Error
1) Checked Exception:
The classes that extend Throwable class except Runtime Exception and
error are known as checked exceptions like IO Exception, SQL Exception etc.
these are checked at compile-time.
2) Unchecked Exception:
1. try
2. catch
3. finally
4. throw
5. throws
1) Try block:A try block is used to enclose the code that might throw an
exception. It must be used within the method. Java try block must be
followed by either catch or finally block.
Page | 10
2) Catch block:Java catch block is used to handle the Exception. It must
be used after the try block only. Multiple catch blocks can also be used
with a single try.
Page | 11
Class not found exception: In jar files we have number of classes .Like a,
b, c, d. I am trying to call class E. There is no call E in jar file. On that class
not found exception occur. And also whenever the jar files misses some
classes when they are imported.
Java I/O (Input and Output) is used to process the input and produce the
output based on the input.Java uses the concept of stream to make I/O
operation fast. The java.io package contains all the classes required for
input and output operations. Filehandling in javais performed by java IO
API. It is handled by I/o packages through which we can read and write.
Stream:
Read Write
Page | 12
Input stream:
Java application uses an input stream to read data from a source, it may
be a file, an array, peripheral device or socket.
Output stream:
Multi-Threading:
P11 P2
write
Read
P3
Upload
Page | 13
Multitasking:
Multitasking is a process of executing multiple tasks simultaneously. We
use multitasking to utilize the CPU. Multitasking can be achieved by two
ways:
1. Process-based Multitasking(Multiprocessing)
2. Thread-based Multitasking(Multithreading)
2. Process is heavyweight.
2. Thread is lightweight.
Thread Class:
Page | 14
Thread Life Cycle:
Start ()
Born State Runnable State
Run()
Running State
Sleep ()
Dead/Terminated Wait State
Stop ()
Page | 15
List of Topics Java
1.JDBC
JDBC:
Java JDBC is a java API to connect and execute query with the database. JDBC
API uses jdbc drivers to connect with the database.
JDBC API
Data Base
API:
JDBC Driver:
JDBC Driver is a software component that enables java application to
interact with the database. There are 4 types of JDBC drivers:
1. JDBC-ODBC bridge driver
Page | 16
2. Native-API driver (partially java driver)
There are 5 steps to connect any java application with the database in
java using JDBC. They are as follows:
1. Register the driver class
2. Creating connection
3. Creating statement
4. Executing queries
5. Closing connection
Page | 17
2) Create the connection object:
The getConnection() method of DriverManager class is used to establish connection with
the database.
Page | 18
1. paste the ojdbc14.jar file in jre/lib/ext folder
2. set classpath
2) set classpath:
1.Temporary
2. Permanent
4) public void rollback(): Drops all changes made since the previous
commit/rollback.
5) public void close(): closes the connection and Releases a JDBC resources
immediately.
Page | 19
Java CallableStatement Interface:
CallableStatement interface is used to call the stored procedures and
functions.We can have business logic on the database by the use of stored
procedures and functions that will make the performance better because
these are precompiled.
Suppose you need the get the age of the employee based on the date of
birth, you may create a function that receives date as the input and
returns age of the employee as the output.
Transaction management:
Commit
Transaction failed
Multithreading:
Requires single memory space. Processor can handle the processes in one
second lag or any application running with web. Parallelism process can be
done without any interruption when more users are using.
servlet:
Page | 20
Server side program, here the client requires and the server responds.
Request comes to dispatcher servlet.
Servlet engine: As soon as the request comes creates a thread internally and
then it allocates servlet instance calls [Service method].
A thread could be extension of core java thread.
Thread safe: At time process happens but at time one users should not get
wrong information because of other user.
1.One servlet can handle multiple requests.
2.Object should be thread safe.
3.Minimal number of instances.
Servlet:
Dynamically generates HTML pages. Spring uses servlet as its base.
Life cycle:
1.Loading
2.Instantiating and initializing
3.Request processing
4.destroying
1.Loading:
Web application class loader.
2.Instantiating and initializing:
Class.forName
Call init() method
Pass the servlet config object
Initializing will be two types as per requirement
Page | 21
1. Eager: Deploying the application we use eager all the
files loading in the first request it comes.
2. Lazy: Dont want to load all the files during
deployement.
3.Requesting Processing:
Service method is used to handle all request service () should be
implemented thread safe.
Instantiation doPost()
Initialization doGet()
Invokes init()
Page | 22
doTrace()
Service
request
Invokes destroy()
response doPut()
Destroy doDelete()
Invokes destroy()
doHead()
Unavailable doOptions()
servlet API:
It is a servlet interface.
Generic servlet:
It does not support Http servlet.
servlet API:
ServletsGeneric ServletHttp ServletMy servlet
Any object is passing from one class to other if it is serializable and then
sent, it would be safe.
Servlets
Generic servlets
Http servlets
Page | 23
My Servlets
JSP:
Java Servlet Pages.
Present dynamic content to users.
Life cycle:
1.Translation
2. Compilation
3. Loading
4. Instantiation and Initialization
5. Request processing
6. Destroy
Tracking session:
Page | 24
Introduction to web:
Web features:
1.Client/Server
2.HTTP
4.URL addresses
Web Application:
1. request dispatching
2. security
3. concurrency
4. life-cycle management
ANT:
Page | 25
1.Build tool: it builds software according to a set of rules. An Apache Jakarta
project. Jakarta is an umbrella heading for all the Java related Apache
projects. Open source, Apache License
2. Automated tool
JVM:
The Java Virtual Machine defines various run-time data areas that are used
during execution of a program. Some of these data areas are created on Java
Virtual Machine start-up and are destroyed only when the Java Virtual
Machine exits. Other data areas are per thread. Per-thread data areas are
created when a thread is created and destroyed when the thread exits.
Memory Management:
PC Registers
Page | 26
Types of Java JVM Run-time Memory Areas
1. Heap Area
2. Method area
3. Java VM Stack
5. PC Registers
1. Heap Area:
The heap area represents the runtime data area, from which the memory is
allocated for all class instances and arrays, and is created during the virtual
machine startup.
2. Method area:
Method area stores per-class structures such as the runtime constant pool;
field and method data; the code for methods and constructors, including the
special methods used in class, instance, and interface initialization.
3. Java VM Stack:
Each of the JVM threads has a private stack created at the same time as that
of the thread. The stack stores frames. A frame is used to store data and
partial results and to perform dynamic linking, return values for methods,
and dispatch exceptions.
5. PC Registers:
Page | 27
Each of the JVM threads has its own program counter (pc) register. At any
point, each of the JVM threads is executing the code of a single method,
namely the current method for that thread.
Garbage collection:
Garbage collection is the process of automatically detecting memory that is
no longer in use, and allowing it to be used again. Java employs garbage
collection to free memory that has been used by objects, saving
programmers having to explicitly dispose of them.
ORACLE
Page | 28
List of Topics Technical course (oracle)
1. Introduction to oracle 10g
2. Application server and
database.
3. System development life
cycle
4. Data Storing on different
models
5. Sql statements
Page | 29
Oracle 10g include everything needed to deploy, develop and manage
internet applications.
Other benefits like scalability, reliability and secure architecture.
Application server and database:
Oracle 10g Application server runs all internet applications.
Oracle 10g database stores all data.
Oracle 10g Application server provides integration between users,
applications and data.
System Development Life Cycle:
From idea to final production we can develop a data base by using system
database life cycle.
Stages of SDLC
1. Strategy and Analysis
2. Design
3. Build and document
4. Transactions
5. Production.
Data Storing on different models:
1. Electronic spread sheets( Excel sheets)
2. Filing cabins
3. Database
Sql statements:
1. Data Definition Language.
2. Data Manipulation Language.
3. Data Control Language
4. Transaction control.
Page | 30
2. Logical storage structure
We can see the storage is done in a file which is nothing but the physical
appearance.
1. Data files: Files where we can store the data in data base.
2. Control file: It contains basic information of the data base which is also the
binary file.
3. Redo log file: The changes that had been done in the data base that would
be stored in other file which is nothing but the Redo files.We can also recall
the information or data whenever the data base crashes.
4. Archive File:
Oracle database allocates space for all the data in the data base. There is
Table space, Segment, Extent, Block in the logical storage stucture.
Blocks ExtendsSegments
1. Data blocks: Data blocks area the smallest unit of storage that oracle data
base can use.
4. Table Spaces:
Page | 31
These are categorized into four types:
Parsing:
1.SQL Parsing:
2.Soft Parsing:
Schematic check
3.Hard Parsing:
Keys:
1) Primary Keys: All tables have unique keys called Primary keys which do
not allow null values.
2) Unique Keys: These keys are unique but these keys allow null values.
3) Not null keys:
ORACLE
Joins: Joins are used to combine two are more tables.
Inner joins: Returns all rows when there is at least one match in BOTH
tables.
Page | 32
Outer joins: Return all rows from the left table, and the matched rows from
the right table.
left join: Return all rows from the right table, and the matched rows from
the left table.
right join: Return all rows when there is a match in ONE of the tables.
List of Topics
Materialized view, indexes
(oracle)
Materialized view:
Snapshot logs create procedure for refresh.
Constraints : constraints are used to restrict the data.
Indexes : To improve the performance.
Objects : objects are 3 types
User objects: We used in user schema.
DBA Objects: We can get all objects ,if we have access are not.
All Objects : we can get all objects , if we have access.
Topic Oracle
1.Tables
2.sequences
3.views
4.Index
1. Tables:
Page | 33
Tables are data base objects that store the information in a form of rows and
columns.
2. Sequences:
3. Views:
View is another way that can store the query for us.
Apart from saving our query view can also be used to secure the data.
Types of views:
Simple view:
Complex view:
Complex view is one which is created by using more than one table.
Page | 34
Complex view does contain any function or groups of data.
Force\No Force:
Drop view:
4. Index:
Indexes are optional structures associated with tables and clusters that allow
SQL statements to execute more quickly against a table.
There are
Bitmap:
Bit map index will create separate index for each unique type of column
work best for columns with a small set of values.
When dealing with bit map index, RDBMS will actually matrix algebra to find
rows that to be locked.
Simple-index column:
Simple-index column is one that is created based on the one table column.
Composite -index column is one that is created based on the one or more
than one table column.
Impact indexes:
Page | 35
Impact indexes are the indexes that are automatically created by oracle
database when an object is created.
Indexes are automatically created by the primary key constraint and unique
key constraint.
UNIQUE :- Ensures that each row for a column must have a unique value.
FOREIGN KEY :- Ensure the referential integrity of the data in one table to
match values in another table.
Joins :-
INNER JOIN: Returns all rows when there is at least one match in BOTH
tables.
LEFT JOIN: Return all rows from the left table, and the matched rows from the
right table.
RIGHT JOIN: Return all rows from the right table, and the matched rows from
the left table.
FULL JOIN: Return all rows when there is a match in ONE of the tables.
SELF JOIN: The SQL SELF JOIN is used to join a table to itself as if the table
were two tables, temporarily renaming at least one table in the SQL
statement.
Page | 36
Oracle: Data Base Objects
Table
Views
Index
Constraints
Procedures
Functions
Packages
Materialized Views
Index, constraints & triggers will drop if the table will drop. & View will
get invalid but not dropped.
Page | 37
select * from recycle_ bin to get dropped table info then it can be
restore again.
In procedure grant execute for other schemas like grant select, insert
for table.
Grant should be given from user itself. But synonyms should be given
which is created in that other user.
Create or replace for procedures, functions & triggers are there so that
without dropping the query it can be updated without revoking the
permission for other users. [which have grant permission on those
objects.]
List of Topics
Page | 38
INDEX: Types of indexes are:
B-TREE: By default, the Oracle creates a b_ tree index. In a b-tree, you walk the
branches until you get to the node that has the data you want to use. In the classic
b-tree structure, there are branches from the top that lead to leaf nodes that
contain the data. If I wanted to find the row - id for the number 28 in the b-tree, I
would start at the top or header block.
BITMAP: Oracle bitmap indexes are very different from standard b-tree indexes. In
bitmap structures, a two-dimensional array is created with one column for every row
in the table being indexed. Each column represents a distinct value within the
bitmapped index. This two-dimensional array represents each value within the index
multiplied by the number of rows in the table.
At row retrieval time, Oracle decompresses the bitmap into the RAM data buffers so
it can be rapidly scanned for matching values. These matching values are delivered
to Oracle in the form of a Row-ID list, and these Row-ID values may directly access
the required information.
FUNCTION BASED: Rather than indexing a column, you index the function on that
column, storing the product of the function, not the original column data. When a
query is passed to the server that could benefit from that index, the query is
rewritten to allow the index to be used.
Simple View
Complex View
Cycle
Maximum Value
Minimum Value
Page | 39
Current _ Value
Next _ Value
After DML
It is the most common type of partitioning and is often used with dates.
For a table with a date column as the partitioning key, the January-2005 partition
would contain rows with partitioning key values from 01-Jan-2005 to 31-Jan-2005.
List Partitioning: List partitioning enables you to explicitly control how rows map
to partitions by specifying a list of discrete values for the partitioning key in the
description for each partition.
The advantage of list partitioning is that you can group and organize unordered and
unrelated sets of data in a natural way.
Page | 40
For a table with a region column as the partitioning key, the North America partition
might contain values Canada, USA, and Mexico.
SQL Constraints:
If there are any violation between constraint and data, the action is
aborted by the constraint.
1) Column level:
Syntax:
2) Table level:
Syntax:
Page | 41
CREATE TABLE [schema_name] table_name (Column_namedatatype [DEFAULT
expr],Column_name [CONSTRAINT Cons_Name] Constraint_type(column_name));
1) Not Null:
In the above query for eid we mentioned not null with column. Which means that
eidshoud contain a value. Which cant be a null value.
2) Unique:
Unique key ensures that no two values are the same in the table.
Oracle does not allow Primary & Unique key to be defined on the same
column.
Syntax:
qual VARCHAR2(10));
Example:
Page | 42
SQL> ALTER TABLE Product ADD CONSTRAINT
3) Check Constraints:
It ensures that all the values entered by the user for that column
satisfy the certain conditions.
We cannot call or use functions like SYSDATE, USER, UID inside the
check condition.
In the above ex we add check constraint for gender column. Which means user can
enter either M or F only.
4) Default:
The default value will be added to all new records, if no other value is
specified.
Ex:
CREATE TABLE Persons(PId number NOT NULL, LastName varchar2(25) NOT NULL,
FirstName varchar2(20),Address varchar2(20),City varchar2(20) DEFAULT
'Sandnes');
Page | 43
They specify the column names to which they applied.
Syntax:
1) Primary Key:
To create a Primary Key on the column order_number for the table Orders
At column level
At table level
2) Foreign Key:
Page | 44
The tables in the relationship are child table and parent table.
The table containing the primary key then becomes the Parent table
(Master table).
The table that contains the foreign key becomes the Child table.
The foreign key can values could be one of the values that are in
primary key or null.
It goes without saying that the Primary key constraint defined on the
table must already exist before to create a foreign key.
Syntax:
And
By using Alter
Specify the child table name with the column names and its datatype.
Ex:
At table level:
Page | 45
FOREIGN KEY(order_number) REFERENCES Orders(Order_number),
At column level:
3) Composite Constraint:
Oracle:
These PL/SQL coding standards were written to allow for consistency in PL/SQL code
written by various developers while allowing for some individual styles and
preferences to be expressed. The central purpose of any coding standard for SQL
and PL/SQL must deal with database performance, clarity of code, and
maintainability of code. This standard should be considered a guideline for
developing easily maintainable SQL and PL/SQL applications in a high-performance
Oracle database.
Using a set of naming conventions for PL/SQL objects tends to create more
meaningful identifiers. This section of the standard will come into play most often
when creating identifiers (variables and constants) inside blocks of code.
Page | 46
-Packages: Whenever create a file stored in two Packages. Its stored in database.
-Cursors
-Procedure
-Function
-Exception.
SQL - Functions :
1) Single Row Functions: It returns a value for every row that is processed in a
query.Numeric Functions:
Character Functions :
Case Manipulation Functions:
Lower, upper, Initcap
Page | 47
god
GOD
God
Date Functions:
31-JUN-2017
Page | 48
Conversion Functions:
To_char :Converts Numeric and Date values to a character string value.
To_number: Converts a character string value to Numeric values .
To_date: Converts a valid Numeric and Character values to a Date value
2) Group Functions: These functions group the data based on the values returned
by the query. The group functions are used to calculate aggregate values like total
or average, which return just one total or one average value after processing a
group of rows.
Aggregate functions:
Also Known as Multi value function or multi row function.
1. SUM: we can add the value of entire column
2. Max : we can get max value of column
3. Min: we can get min value of column
4. AVG: we can get average value of column
5. COUNT: In this null values are not countable.
Ex : select dept , max(salary) from emp1 group by dept having count(id) >1;
Page | 49
UNIX
Page | 50
List of Topics 1. Introduction to unix
2. Unix command structure
3. File and directory related
commands
4. Shell Meta characteristics
5. Building block Primitives
Unix:
Security:
Background tasks:
Pipes:
File system:
The file system is in the form of Tree structure. Mainly based on root.
The root can split into many partitions but root file is mandatory.
Page | 51
UNIX has multiple file systems
A file system
Boot block:
Super block:
Has the state of the file system-its size, where to find the free space on the
file system, how many files it can store etc.
Inode block:
Data Block:
Hierarchy:
/ (root)
usr
sh ls
shadow
tty lp password
Page | 52
Here bin, dev, etc are the non leaf nodes because these contain other
dictionaries.
Leaf nodes:
Here sh, ls, tty, lp are leaf nodes because they do not have any other
directories.
[options] [arguments]
Specific commands are the options file1 and file2 are the
arguments
2 types of commands:
Page | 53
Shell Scripts:
The shell executes these scripts by spawning another shell. The child shell
becomes the parent of the commands that feature in the script. The child
shell executes the commands in the script.
Commands/Utilities:
Clear command:
$ clear
date command:
$ date
$ date +%T
$ date +%D
$ date +%Y
$ date +%B
Note: Nearly every lowercase and uppercase alphabet is having some format
meaning with date command. To find out all the options, use man command.
Page | 54
cal command:
$ cal
2. To display the calendar for Jan month(month value 01) for 2002 year
$ cal 01 2002
$ cal 2009
who command:
1. To display the details of all the users who are currently logged in
$ who
$ who am i
type command:
$ type clear
$ type alias
alias command:
Page | 55
1. To create alias name of an existing command
$ alias d=date
$ alias
cat command:
Ctrl+d
1. cat command will create an empty file with name file1 in current
directory
3. As soon as user will press ctrl+d, all the data entered by the user on
the terminal will be saved in the file
Page | 56
.
Ctrl+d
1. All the data entered on the screen will be saved in this existing file.
2. If file1 is already having some data, new data given by user will
overwrite the previous data.
$ cat file1
1. file1 data followed by file2 data will be printed on the screen as shown
below:
$ cat file1
$ cat file2
Page | 57
$ cat >> file1
Ctrl+d
1. All the data entered on the screen will be saved in this existing file.
2. If file1 is already having some data, new data given by user will be
appended with the previous data.
mkdir command:
$ mkdir d1
$ mkdir path/d1
$ mkdir p d1/d2/d3
-p means parent
cd command:
$ cd dir1
This will change current directory to dir1 if dir1 is present in current directory
$ cd path/dir1
Page | 58
This will change current directory to dir1 if dir1 is present in the mentioned
path
$ cd OR $ cd ~
$ cd /
$ cd ..
head:
Display the first count lines of file. If count is not specified, then first ten
lines are printed by default. If no files are specified, head asks for the input
from the standard input.
tail:
Display the last count lines of a file. If count is not specified, then last ten
lines are printed by default. If no files are specified, tail asks for the input
from the standard input.
Page | 59
Syntax: $ tail [n/+n] file_name
wc:
Displays total no of lines, words and characters in any data.
Syntax: $ wc [lwc] file_name
tr:
Translate characters. Used on output of some other command.
Syntax: $ cmd_output | tr [option] src_charset tar_charset
Cut:
Retrieves specific fields or characters from the data. Used on output of some
other command or file content.
Sort:
Used to order the data. Used on output of some other command or file
content. Default sorting is as per the English dictionary.
Syntax: $ cmd_output | sort [option]
$ sort [option] file
grep:
Used for pattern search in the given data. Global Regular Expression Parser.
Syntax: $ grep [option] pattern data
Prints lines starting with any pattern : $ grep ^pattern file_name
Prints lines ending with any pattern : $ grep pattern$ file_name
Uniq:
Page | 60
Removes adjacent repeated lines in the given data.
Syntax: $ uniq [option] data
Cmp:
Compares two files and give the first difference that encounters.
Syntax: $ cmp file1 file2
Comm:
Compares two files and the result will be given in 3 columns.
1st column: uniq dada from file1.
2nd column: uniq dada from file2.
3rd column: uniq dada from both the files.
diff:
Used to get all the difference in between the two files.
Syntax: $ diff file1 file2
Ps:
Displays the list of processes submitted to kernel
Syntax: $ ps
$ ps f :Full Listing showing PPID
$ ps e :Including user and system processes
bg:
Used to see the status in the background.
Page | 61
Syntax: $bg
Fg:
Used to bring any background job in foreground.
Syntax: $ fg %JobID OR fg #PID
nice:
Execute a command with updated scheduling priority.
Syntax: $ nice [option] [command]
nohup:
Executes the command in background even after log out from the session.
Syntax: $ nohup command
kill:
Used to send a signal to a particular process.
Syntax: $ kill [signal_info] PID
$ kill [signal_info] %JobID
df:
Prints file system disk space usage.
Syntax: $ df [FILE]
du:
Estimates file space use.
Syntax: $ du [FILE]
Page | 62
Compression Utilities:
Used to compress the files and directories.
gzip:
Utility for compression and decompression of files. Compressed files have
.gz extension.
Syntax: $ gzip file1 [file2]
$ gzip d file1.gz
gunzip:
Utility for decompression of files having extension .gz
Same as gzip d
Syntax: $ gunzip file1.gz
zcat:
Used to view the content of compressed file.
Syntax: $ zcat file1.gz
zmore:
Used to view the content of the compressed file pagewise.
Syntax: $ zmore file1.gz
tar:
Creates a tape archive file. Extracts from archive file.
Syntax: $ tar -cvf file1.tar file1
$ tar -xvf file1.tar
untar:
Used to unzip the files or untar.
Page | 63
List of Topics 1. Communication commands
2. File Transfer commands
3. Telnet
4. Unix Security
5. Changing Passwords
6. File security
7. File Permissions
Communication commands:
Write:
Writes a message to another user who is logged in. Can be used by any
user.
Syntax: $ write user_id
mesg:
Changes permission for receiving messages. Gives permission status.
Syntax: $ mesg
$ mesg y[or n]
wall:
Writes a message to all users who are currently logged in.
Syntax: $ wall [g group] message
put:
Used to transfer a file from the source terminal to the destination terminal.
Syntax: $ put filename
Page | 64
get:
Used to transfer a file from destination terminal to source terminal.
Syntax: $ get filename
mput:
Used to transfer multiple files from the source terminal to the destination
terminal.
Syntax: $ mput file1 [file2]
mget:
Used to transfer multiple files from destination terminal to source terminal.
Syntax: $ mget file1 [file2]
bye:
Used to close the FTP session.
Syntax: $ bye
close:
Also used to close the FTP session. System will give Good Bye message
then type bye.
Syntax: $ close
help:
This command displays the list of FTP commands that can be used by the
user. User can also type ? symbol for the same.
Syntax: $ help
$?
Page | 65
![Command]:
Used to execute some commands in local machine. Shifts the control from
ftp prompt to local machine.
Syntax: $ ![Command [arg]]
Telnet:
Used for connecting to UNIX .
telnet [hostname]
File Security:
Classes of users for a file.
Owner
Group
Others
Classes of Permissions for a file.
Read (r)
Write (w)
Execute (x)
File Permissions:
Page | 66
1.vi editor & its important features:
Features:
Omnipresent: vi Editor works on different UNIX flavors.
Fast: In vi editor, Editing and various operations are very fast.
Powerful UNDO features: In vi Editor, text in lines could be undone with very
less effort.
Limitations:
Less User-friendly: As vi Editor does not have a graphical user interface,
hence the user needs to have a knowledge of the commands before the user
works on the editor.
Highly case-sensitive: vi Editor is highly case-sensitive. i.e. a letter in small
case would has a different meaning in comparison with the same letter in
upper case.
E.g. a appends the data after the current character, whereas A appends
the data after the current line.
Keystrokes: As vi Editor operates in various modes, a letter could have
different meaning in different modes.
E.g. In command mode, a stands for append operation, whereas in insert
mode, a stands for data.
vi operating mode:
start
Command mode
I,I,o,O,a,A Insert mode
esc
enter
Escape mode
end
Page | 67
:q
vi editor commands:
These commands are used to move, change, replace or manipulate a file.
Features:
1. Interactive and background processing
2. Input/output redirection
3. Pipes
4. Wild card matching
5. Programmable
1. Shell Variables
2. Programming language constructs
3. Shell Scripts
Day 15 Tuesday,
November 29, 2016
Page | 68
List of Topics 1. Positional Parameters
2. Special Parameters
3. Selectional Constructs
4. Iterational Constructs
1.Positional Parameters:
A command in UNIX is interpreted by the shell. When a command is entered and
<Enter> key is pressed, the shell puts each word on the command line into special
variables as follows
1. The command name is put into the variable called $0
2. The first argument is put into the variable called $1
3. The second argument is put into the variable called $2 and so on.
The UNIX shell creates variable up to $9
These variables are also called positional parameters of the command line.
set file1 file2 file3
$0 bash, $1- file1, $2 file2, $3 file3
2.Special Parameters:
Besides the variables $0 to $9, the shell also assigns values to the following
variables, called Special Parameters
$$ PID number of current shell
$# contains the number of Command Line Arguments
$0 Command Name
$* contains the entire string of arguments
$? Exit Status of the last executed command
$! PID number of the last background command
$@ Same as $* but fetches each argument separately when enclosed in double
quotes
3. Selectional Constructs:
-if
-case
Page | 69
4.Iterational Constructs:
-for
-while
-until
Page | 70