Basic Unix Editing Commands

Thursday, May 20, 2010

Basic Editing

Editing commands require that you be in command mode. Many of the editing commands have a different function depending on whether they are typed in upper or lower case. Often, editing commands can be preceded by a number to indicate a repetition of the command. 

NOTE: Unless specified otherwise, the instructions in this section assume that you are in the command mode. 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Deleting characters. To delete a character from a file, move the cursor until it is on the incorrect letter, then type x. The character under the cursor disappears. To remove four characters (the one under the cursor and the next three) type 4x. To delete the character before the cursor, type X (upper case). 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
Deleting words. To delete a word, move the cursor to the first letter of the word and type dw. The command deletes the word and the space following it. To delete three words, type 3dw.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
Deleting lines. To delete a whole line, type dd. The cursor does not have to be at the beginning of the line. dd deletes the entire line containing the cursor and places the cursor at the start of the next line. 2dd deletes two lines.
To delete from the cursor position to the end of the line, type D (upper case).

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

 Replacing characters. To replace one character with another, move the cursor to the character to be replaced. Type r, then the replacement character. The new character will appear, and you will still be in command mode.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
Replacing words. To replace one word with another, move to the start of the incorrect word and type cw. The last letter of the word to be replaced will turn into a $. You are now in change mode and may type the replacement. The new text does not need to be the same length as the original. Press ESC to get back to command mode. 3cw allows you to replace three words.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
Replacing lines. To change text from the cursor position to the end of the line, type C (upper case). Type the replacement text and press ESC. Press ESC again to get back to command mode.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
Inserting text. To insert text in a line, position the cursor where the new text should go and type i. Enter the new text. The text is inserted before the cursor. Press ESC to get back to command mode.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
Appending text. To add text to the end of a line, position the cursor on the last letter of the line and type a. Enter the new text. This adds text after the cursor. Press ESC to get back to command mode.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Opening a blank line. Type o (lower case) to insert, or open, a blank line below the current line. Type O (upper case) to insert a blank line above the current line. Press ESC to get back to command mode. 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Joining lines. The command J (upper case) lets you join two lines together. Put the cursor on the first line to be joined and type J. 3J lets you join 3 lines together.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Undoing. Undo your most recent edit by typing u (lower case). U (upper case) undoes all the edits on a single line, as long as the cursor stays on that line. Once you move off a line, you can't use U to restore it.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Moving Around In a File
These shortcuts, which work in command mode, allow you to move more quickly through a file.
Key(s)
Movement
w
forward word by word
b
backward word by word
$
to end of line
0 (zero)
to beginning of line
H
to top line of screen
M
to middle line of screen
L
to last line of screen
G
to last line of file
1G
to first line of file
ctrl-f
jump forward one screen
ctrl-b
jump backward one screen
ctrl-d
scroll down one-half screen
ctrl-u
scroll up one-half screen
Moving by searching. To move quickly in a file, search for text. In command mode, type a / (slash) followed by the text to search for. Press Return. The cursor moves to the first occurrence of that text. Repeat the search in a forward direction by typing n (lower case), or in a backward direction by typing N (upper case).

General

apropos command
Locate commands by keyword lookup.
exit
Terminate your current session, or shell.
man command
Display the Unix manual page describing a given Unix command.

File System Navigation

cd
Return to your home directory.
cd directory
Change directory to make directory your current directory.
file files
Determine file type.
ls
List the contents of the current directory.
ls names
List the contents of the directories; names can name files and/or directories:
ls -l
. . . in a long format, showing permissions, owner, size, and other file info.
ls -a
. . . all files, including "hidden" files (file names that begin with a dot ".").
ls -R
. . . Recursively, for all subdirectories.
ls -t
. . . in time order (when modified, newest to oldest) rather than in name order.
pwd
Display the name of the current directory, or "print working directory."

File/Directory Manipulation

compress files
Reduces the size of a file.
uncompress files
Restores compressed files to their original form.
cp file1 file2
Copy file(s).
cp files directory
Copy file(s) into a directory.
cp -r dir1 dir2
Copy a directory and, recursively, its subdirectories.
mkdir directory
Create, or "make" a directory.
mv file1 file2
Move a file or, if file1 and file2 are in the same directory, rename a file.
mv files directory
Move files into a directory.
mv dir1 dir2
If directory dir2 exists, move dir1 into dir2; otherwise, rename dir1 as dir2.
rm files
Remove (erase) file(s).
rm -r names
Remove files, directories, and recursively, any subdirectories.
rmdir directory
Remove directory (directory must be empty).

Data Manipulation

cat files
Concatenate file(s); you can use cat to display the contents of a file (this is not advisable if the file is a binary file).
grep "pattern" files
Display all lines in the files that match a pattern.
more files
Display contents of files one screen at a time.
sort files
Order the lines in a file or files alphabetically (this command does not alter the file or files -- it merely displays the sorted output to the screen):
sort -r files
. . . in reverse order.
sort -n files
. . . numerically (puts 2 before 10 instead of after).

Networking/Communications

finger user@umich.edu
Displays information about a U-M user from the U-M Online Directory.
ssh hostname
Connect to a remote host using Secure Shell.
telnet hostname
Connect to a remote host using the telnet protocol.
talk user
Initiate a conversation with another user (end conversation with Control-C); talk works only between machines of the same architecture.

Miscellaneous

!!
Repeat last shell command.
!string
Repeat last shell command that began with string (for example, type "!m" to repeat the last command that began with "m").
cal
Display a calendar of the current month.
cal month year
Display a calendar of the given month and year. Note that the year must be fully qualified, for example, "2003" and not "03."
clear
Clears terminal screen.
date
Display the current local date and time.
who
Display a list of users currently logged in.




Q. What is echo $? Command do?
A. It returns the status of last command run. E.g if we run grep command then if the patter is found in the file it shows 0, pattern not found then 1 and file not found then 2.



Read more...

Software Engineering Terms - A

Tuesday, May 18, 2010

ACCEPTANCE CRITERIA



The criteria that the software component, product, or system must satisfy in order to be accepted by the customer.



ACCEPTANCE PROCESS



The process used to verify that a new or modified software product is fully operational and meets the customer's requirements.



ACCEPTANCE TESTING



Formal testing conducted by the customer to determine whether or not a software product or system satisfies the documented acceptance criteria. Successful completion of acceptance testing defines the point at which the customer will accept the product as a successful implementation.



ACTIVITY



A major unit of work to be completed in achieving the objectives of a software project. An activity incorporates a set of tasks to be completed, consumes resources, and results in work products. An activity may contain other activities in a hierarchical manner. All project activities are described in the Project Plan.



ACTOR



A person or system that interacts with the software application in support of a specific process or to perform a specific operation or related set of operations. See Use Case.



ALGORITHM



A set of well-defined rules for the solution to a problem in a finite number of steps. Generally implemented as a logical or mathematical test or calculation. See Business rules.



ANOMALY



A nice word for "bug." Anything observed in the operation of software that deviates from expectations based on design documentation or user references.



APPLICATION



One or more software executables designed to fulfill a specific set of business functions individually or in cooperation with other applications.



ASSESSMENT



A formal examination of a deliverable, generally by a quality assurance reviewer, for the presence of a specific set of attributes and structural elements. An assessment is not an in-depth examination of content, as the content of a deliverable may be outside the reviewer’s domain of expertise. See Review.



ASSUMPTION



A condition that is generally accepted as truth without proof or demonstration.



ATTRIBUTE



A piece of information describing part of a particular entity.



AUDIT



An independent examination of software or software documentation to assess compliance with predetermined criteria.



AUTHENTICATION



The ability of each party in a transaction to verify the identity of the other parties.

Read more...

Java Basics

Java Basics

1.The Java interpreter is used for the execution of the source code.
True
False
Ans: a.


2) On successful compilation a file with the class extension is created.
a) True
b) False
Ans: a.


3) The Java source code can be created in a Notepad editor.
a) True
b) False
Ans: a.


4) The Java Program is enclosed in a class definition.
a) True
b) False
Ans: a.


5) What declarations are required for every Java application?
Ans: A class and the main( ) method declarations.


6) What are the two parts in executing a Java program and their purposes?
Ans: Two parts in executing a Java program are:
Java Compiler and Java Interpreter.
The Java Compiler is used for compilation and the Java Interpreter is used
for execution of the application.


7) What are the three OOPs principles and define them?
Ans : Encapsulation, Inheritance and Polymorphism are the three OOPs
Principles.
Encapsulation:
Is the Mechanism that binds together code and the data it manipulates, and
keeps both safe from outside interference and misuse.
Inheritance:
Is the process by which one object acquires the properties of another
object.
Polymorphism:
Is a feature that allows one interface to be used for a general class of
actions.
 

8) What is a compilation unit?
Ans : Java source code file.


9) What output is displayed as the result of executing the following
statement?
System.out.println("// Looks like a comment.");
// Looks like a comment
The statement results in a compilation error
Looks like a comment
No output is displayed
Ans : a.


10) In order for a source code file, containing the public class Test, to
successfully compile, which of the following must be true?
It must have a package statement
It must be named Test.java
It must import java.lang
It must declare a public class named Test
Ans : b


11) What are identifiers and what is naming convention?
Ans : Identifiers are used for class names, method names and variable names.
An identifier may be any descriptive sequence of upper case & lower case
letters,numbers or underscore or dollar sign and must not begin with
numbers.


12) What is the return type of program's main( ) method?
Ans : void


13) What is the argument type of program's main( ) method?
Ans : string array.


14) Which characters are as first characters of an identifier?
Ans : A – Z, a – z, _ ,$


15) What are different comments?
Ans : 1) // -- single line comment
2) /* --
*/ multiple line comment
3) /** --
*/ documentation


16) What is the difference between constructor method and method?
Ans : Constructor will be automatically invoked when an object is created.
Whereas method has to be call explicitly.


17) What is the use of bin and lib in JDK?
Ans : Bin contains all tools such as javac, applet viewer, awt tool etc., whereas Lib contains all packages and variables.

Read more...

VB6/ASP to .NET Migration Interview Questions

Friday, May 7, 2010

What is functional equivalence?
In the context of a Microsoft Visual Basic upgrade, achieving functional equivalence means that the exact functionality of a Visual Basic 6.0 application is retained in the Visual Basic .NET application after it has been upgraded, but before new features are added.
Achieving functional equivalence provides you with a working .NET version of your application, but it is usually considered an intermediate step in the process of upgrading an application.

What is application advancement?
Application advancement is the improvement of the upgraded application beyond the specifications of the original system.
Application advancement involves identifying, and then modifying or extending, the areas of your application that will benefit from the many improvements that the .NET Framework offers.
What is a proof of concept?
A proof of concept is the migration of a representative piece of code, used as evidence to demonstrate whether a project is ideal or feasible. It can help you to avoid wasting time on poor coding decisions and can allow you to validate solutions in an isolated condition.
A proof of concept will help you to determine the real cost of the most common issues that appear in the upgrade wizard's upgrade report.
What are some activities that my upgrade project plan should include?
In addition to the tasks your organization typically performs during a software development project, your plan for the upgrade project should include the following activities:
* Defining the project scope:
* Performing an application analysis.
* Assessing the current and the target architecture.
* Analyzing and designing new functionality.
* Selecting an upgrade strategy.
* Making an inventory of source code.
* Preparing the source code.
* Preparing to handle upgrade issues.
* Unit testing.
* Validating functional equivalence and acceptance.
* Implementing and testing new functionality.
* Deploying the Visual Basic .NET application. 

Why is defining the project scope so important?
Defining the scope of your project is the all-important stage of project planning because you establish the project goals and the manageable tasks that will accomplish these goals, setting a comprehensive roadmap and defining realistic expectations. 

What does performing an application analysis accomplish?
An application analysis will determine the most appropriate upgrade strategy for the project. The goal of this activity is to ensure that the project adapts to your real business needs and that your expectations are realistic about the outcome of the project.

What strategies should I consider when selecting an upgrade?
When selecting to upgrade your application, you should consider the following two upgrade strategies: a complete upgrade and a staged upgrade.
With a complete upgrade, all components of your application are upgraded and deployed as a whole. This does not mean they are upgraded in parallel; it means only that no effort is made to deploy the application in a production environment until all components have been moved to .NET.
The staged upgrade strategy allows you to upgrade some parts of your application before you upgrade others. This allows a more controlled, gradual upgrade where the application is upgraded a part or component at a time.

What are the advantages of a complete upgrade strategy?
Some of the advantages of a complete upgrade strategy are:
* Upgraded applications can be advanced with new functionality that uses .NET technologies and techniques.
* Upgraded applications can be integrated into new .NET solutions, making them usable in more scenarios.
* Fully-upgraded applications can be used on new hardware and new versions of Windows.
And what are some of the disadvantages?
Some of the disadvantages of a complete upgrade strategy are:
* Some Visual Basic 6.0 features cannot be automatically or easily upgraded to Visual Basic .NET.
* A completely upgraded application could have a different user interface or may have different behavior.
* A Visual Basic .NET application requires a compatible version of the .NET Framework to be installed on target computers.
* Developers responsible for performing the upgrade or for maintaining the resulting application may have to learn new skills to perform the upgrade. 

What are the advantages of a staged upgrade strategy?
Some of the advantages of a staged upgrade strategy are:
* More control over the progress and the cost of the upgrade project.
* Minimized risk, because you return the application to a stable production-quality state after each stage.
* Upgraded components can often immediately benefit from the performance and scalability features of .NET without having to wait for the entire application to be upgraded.
* Upgrading of the low priority or costly portions of an application can be postponed indefinitely, resulting in a partial upgrade.
And what are some of the disadvantages?
Some of the disadvantages of a staged upgrade strategy are:
* Performance improvements will not be as noticeable as in a full upgrade because of the added overhead required for COM interoperability.
* Applications with a dependency on COM components are harder to deploy and maintain than applications that are fully upgraded to .NET because COM objects need to be registered and have versioning issues that .NET objects do not.
* A staged upgrade requires the implementation of wrappers or interfaces to provide the interoperability mechanisms between the .NET and the legacy code. These wrappers will often be temporary and will be discarded later. 

What are vertical upgrades?
Vertical upgrades involve isolating and upgrading all n-tiers of a single module of your application without modifying other parts of the application.

What are horizontal upgrades?
Horizontal upgrades involve upgrading an entire tier of your application without modifying the other tiers.
What are some points I should consider when deciding if a horizontal upgrade strategy is appropriate, and if so, which tier is the most suitable to upgrade first?
You should consider the following points when deciding on a horizontal upgrade:
* Your application is on a large number of Web servers. A prerequisite for the deployment of a Visual Basic .NET application is that the common language runtime (CLR) must be installed on each Web server. If your application is deployed on a large number of servers in a Web farm configuration, this can be an issue. If you have relatively fewer servers in middle tiers than in other tiers, consider using a horizontal upgrade and then upgrading the middle tier first.
* Your application uses a large amount of shared code. If your Visual Basic application uses a large number of DLLs or other types of shared code, constants, or custom libraries in the middle tier, choosing to upgrade this tier first can help you manage the upgrade of your entire application. However, if you do this, you will destabilize a large number of components that use the shared code and thereby affect the testing process.
* Your application has a complex middle tier. Complex object hierarchies in the middle tier should be kept as a unit. Deciding where to isolate an application with a complex middle-tier object hierarchy is difficult, and upgrading only parts of a complex middle tier typically necessitates numerous interoperability calls between environments, resulting in performance degradation. 

What are some issues I should consider when replacing the middle tier?
To transparently replace middle-tier components with .NET components without affecting client code, you must maintain the original GUIDS and ProgIDs of your COM components. In addition, you must properly handle replacement of the class interface generated by Visual Basic components when you attempt to transparently replace a COM component.
You will have to translate the ADO.NET datasets that are returned from your upgraded middle-tier components to ADO recordsets that are used in your original Visual Basic code.
You will need to deploy the interoperability assemblies for the middle tier components.
Interoperability between Visual Basic .NET and Visual Basic 6.0 can become prevalent in this type of upgrade, depending on how you choose to define the application tiers. If the distance between the tiers is widened by making one side of the communication a .NET assembly, you may be increasing the amount of marshaling that is occurring in your application, which can negatively affect performance.

Why is estimating the cost requirements for a software development project a complex task?
Estimating the cost requirements for a software development project is typically a complex task because of the wide range of quality in software implementation and the varying programming abilities of developers.

What is the Visual Basic 6.0 Code Advisor?
The Visual Basic 6.0 Code Advisor is an add-in for Visual Studio 6.0. It can be used to scan your Visual Basic 6.0 source code for practices that do not comply with configurable coding standards.

What is the ASP to ASP.NET Migration Assistant?
The ASP to ASP.NET Migration Assistant is an add-in to Visual Studio .NET, created by ArtinSoft for Microsoft, that helps you upgrade your ASP pages and applications to ASP.NET.

What is an Assembly?
An assembly is the smallest deployable unit of a .NET application; it is a collection of classes, configuration files, resource files, and any other files that your application needs at run time.
An assembly can be an executable (EXE) or a dynamically linked library (DLL).
By default, assemblies are installed into the same directory as the owning application. This type of assembly is called a private assembly. Because it is installed in the application directory, there is no chance of it interfering with other applications installed on the same computer.
You can also create shared assemblies that are installed into a system wide repository for assemblies called the global assembly cache. These assemblies can be used by multiple independent applications. The advantage of these assemblies is that they use less disk space and less memory.
You can easily install multiple versions of the same assembly in the global assembly cache, and it will maintain these assemblies separately.

Read more...

Frequently Used Unix Commands

Thursday, May 6, 2010

Unix Command Summary

 

For more documentation on a command, consult a good book, or use the man pages. For example, for more information on grep, use the command man grep.

 

cat  -  for creating and displaying short files

 

This is one of the most flexible Unix commands. We can use to create, view and concatenate files. For our first example we create a three-item English-Spanish dictionary in a file called "dict."

 

   % cat >dict

     red rojo

     green verde

     blue azul

<control-D>

   %

 

<control-D> stands for "hold the control key down, then tap 'd'". The symbol > tells the computer that what is typed is to be put into the file dict. To view a file we use cat in a different way:

 

   % cat dict

     red rojo

     green verde

     blue azul

   %

 

If we wish to add text to an existing file we do this:

   % cat >>dict

     white blanco

     black negro

     <control-D>

   %

 

Now suppose that we have another file tmp that looks like this:

 

   % cat tmp

     cat gato

     dog perro

   %

 

Then we can join dict and tmp like this:

   % cat dict tmp >dict2

 

We could check the number of lines in the new file like this:

 

   % wc -l dict2

8

 

The command wc counts things --- the number of characters, words, and line in a file.

 

--------------------------------------------------------------------------------

 

chmod --- change permissions

This command is used to change the permissions of a file or directory. For example to make a file essay.001 readable by everyone, we do this:

 

   % chmod a+r essay.001

 

To make a file, e.g., a shell script mycommand executable, we do this

 

   % chmod +x mycommand

 

Now we can run mycommand as a command.

To check the permissions of a file, use ls -l . For more information on chmod, use man chmod.

 

--------------------------------------------------------------------------------

 

cd --- change directory

Use cd to change directory. Use pwd to see what directory you are in.

 

   % cd english

   % pwd

   % /u/ma/siya/english

   % ls

novel poems

   % cd novel

   % pwd

   % /u/ma/siya/english/novel

   % ls

ch1 ch2 ch3 journal scrapbook

   % cd ..

   % pwd

   % /u/ma/siya/english

   % cd poems

   % cd

   % /u/ma/siya

 

--------------------------------------------------------------------------------

 

cp --- for copying files

Use cp to copy files or directories.

   % cp foo foo.2

 

This makes a copy of the file foo.

   % cp ~/poems/jabber .

 

This copies the file jabber in the directory poems to the current directory. The symbol "." stands for the current directory. The symbol "~" stands for the home directory.

 

--------------------------------------------------------------------------------

 

date --- display date

Use this command to check the date and time.

   % date

Mon May  3 10:25:33 IST 2010

 

--------------------------------------------------------------------------------

 

echo --- echo argument

The echo command echoes its arguments. Here are some examples:

 

   % echo this

     this

   % echo $EDITOR

     /usr/local/bin/emacs

   % echo $PRINTER

     b129lab1

 

Things like PRINTER are so-called environment variables. This one stores the name of the default printer --- the one that print jobs will go to unless you take some action to change things. The dollar sign before an environment variable is needed to get the value in the variable. Try the following to verify this:

 

   % echo PRINTER

     PRINTER

 

--------------------------------------------------------------------------------

 

ftp --- connect to a remote machine to download or upload files

 

Use ftp to connect to a remote machine, then upload or download files. See also: ncftp

 

Example 1: We'll connect to the machine fubar.net, then change director to mystuff, then download the file homework11:

 

   % ftp solitude

     Connected to fubar.net.

     220 fubar.net FTP server (Version wu-2.4(11) Mon Apr 18 17:26:33 MDT 1994) ready.

   Name (solitude:carlson): jeremy

     331 Password required for jeremy.

   Password:

     230 User jeremy logged in.

   ftp> cd mystuff

     250 CWD command successful.

   ftp> get homework11

   ftp> quit

 

Example 2: We'll connect to the machine fubar.net, then change director to mystuff, then upload the file collected-letters:

 

   % ftp solitude

     Connected to fubar.net.

     220 fubar.net FTP server (Version wu-2.4(11) Mon Apr 18 17:26:33 MDT 1994) ready.

   Name (solitude:carlson): jeremy

     331 Password required for jeremy.

   Password:

     230 User jeremy logged in.

   ftp> cd mystuff

     250 CWD command successful.

   ftp> put collected-letters

   ftp> quit

 

The ftp program sends files in ascii (text) format unless you specify binary mode:

 

   ftp> binary

   ftp> put foo

   ftp> ascii

   ftp> get bar

 

The file foo was transferred in binary mode, the file bar was transferred in ascii mode.

 

--------------------------------------------------------------------------------

 

grep --- search file

Use this command to search for information in a file or files. For example, suppose that we have a file dict whose contents are

 

   red rojo

   green verde

   blue azul

   white blanco

   black negro

 

Then we can look up items in our file like this;

   % grep red dict

     red rojo

   % grep blanco dict

     white blanco

   % grep brown dict

   %

 

Notice that no output was returned by grep brown. This is because "brown" is not in our dictionary file.

 

Grep can also be combined with other commands. For example, if one had a file of phone numbers named "ph", one entry per line, then the following command would give an alphabetical list of all persons whose name contains the string "Fred".

 

   % grep Fred ph | sort

     Alpha, Fred: 333-6565

     Beta, Freddie: 656-0099

     Frederickson, Molly: 444-0981

     Gamma, Fred-George: 111-7676

     Zeta, Frederick: 431-0987

 

The symbol "|" is called "pipe." It pipes the output of the grep command into the input of the sort command.

For more information on grep, consult

 

   % man grep

 

--------------------------------------------------------------------------------

 

head --- display first part of file

Use this command to look at the head of a file. For example,

 

   % head essay.001

 

displays the first 10 lines of the file essay.001 To see a specific number of lines, do this:

 

   % head -20 essay.001

 

This displays the first 20 lines of the file.

 

--------------------------------------------------------------------------------

 

ls --- see what files you have

Use ls to see what files you have. Your files are kept in something called a directory.

 

   % ls

     foo       letter2

     foobar    letter3

     letter1   maple-assignment1

   %

 

Note that you have six files. There are some useful variants of the ls command:

 

   % ls l*

     letter1 letter2 letter3

   %

 

Note what happened: all the files whose name begins with "l" are listed. The asterisk (*) is the " wildcard" character. It matches any string.

--------------------------------------------------------------------------------

 

lpr --- standard print command (see also print )

This is the standard Unix command for printing a file. It stands for the ancient "line printer." See

 

   % man lpr

 

for information on how it works. See print for information on our local intelligent print command.

 

--------------------------------------------------------------------------------

 

more --- use to read files

More is a command used to read text files. For example, we could do this:

 

   % more poems

 

The effect of this to let you read the file "poems ". It probably will not fit in one screen, so you need to know how to "turn pages". Here are the basic commands:

 

q --- quit more

spacebar --- read next page

return key --- read next line

b --- go back one page

For still more information, use the command man more.

 

--------------------------------------------------------------------------------

 

mkdir --- create directory

Use this command to create a directory.

   % mkdir essays

 

To get "into" this directory, do

   % cd essays

 

To see what files are in essays, do this:

   % ls

 

There shouldn't be any files there yet, since you just made it. To create files, see cat or emacs.

 

--------------------------------------------------------------------------------

 

mv --- for moving and renaming files

Use this command to change the name of file and directories.

 

   % mv foo foobar

 

The file that was named foo is now named foobar

 

--------------------------------------------------------------------------------

 

ncftp --- especially good for downloading files via anonymous ftp.

Use ncftp for anonymous ftp --- that means you don't have to have a password.

 

   % ncftp ftp.fubar.net

     Connected to ftp.fubar.net

   > get jokes.txt

 

The file jokes.txt is downloaded from the machine ftp.fubar.net.

 

--------------------------------------------------------------------------------

 

print --- custom print command (see also lpr )

This is a moderately intelligent print command.

   % print foo

   % print notes.ps

   % print manuscript.dvi

 

In each case print does the right thing, regardless of whether the file is a text file (like foo ), a postcript file (like notes.ps, or a dvi file (like manuscript.dvi. In these examples the file is printed on the default printer. To see what this is, do

 

 

   % print

 

and read the message displayed. To print on a specific printer, do this:

   % print foo jwb321

   % print notes.ps jwb321

   % print manuscript.dvi jwb321

 

To change the default printer, do this:

   % setenv PRINTER jwb321

 

--------------------------------------------------------------------------------

 

pwd --- find out what directory you are in

Use this command to find out what directory you are working in.

   % pwd

/u/ma/jeremy

   % cd homework

   % pwd

/u/ma/jeremy/homework

   % ls

assign-1 assign-2 assign-3

   % cd

   % pwd

/u/ma/jeremy

   %

 

--------------------------------------------------------------------------------

 

rm --- remove a file

Use rm to remove files from your directory.

   % rm foo

     remove foo? y

   % rm letter*

     remove letter1? y

     remove letter2? y

     remove letter3? n

   %

 

The first command removed a single file. The second command was intended to remove all files beginning with the string "letter." However, our user (Jeremy?) decided not to remove letter3.

 

--------------------------------------------------------------------------------

 

rmdir --- remove directory

Use this command to remove a directory. For example, to remove a directory called "essays", do this:

 

   % rmdir essays

 

A directory must be empty before it can be removed. To empty a directory, use rm.

 

--------------------------------------------------------------------------------

 

rsh --- remote shell

Use this command if you want to work on a computer different from the one you are currently working on. One reason to do this is that the remote machine might be faster. For example, the command

 

   % rsh solitude

 

connects you to the machine solitude. This is one of our public workstations and is fairly fast.

 

See also: telnet

 

--------------------------------------------------------------------------------

 

setenv --- set an environment variable

   % echo $PRINTER

     labprinter

   % setenv PRINTER myprinter

   % echo $PRINTER

     myprinter

 

--------------------------------------------------------------------------------

 

sort --- sort file

Use this commmand to sort a file. For example, suppose we have a file dict with contents

red rojo

green verde

blue azul

white blanco

black negro

 

Then we can do this:

   % sort dict

     black negro

     blue azul

     green verde

     red rojo

     white blanco

 

Here the output of sort went to the screen. To store the output in file we do this:

   % sort dict >dict.sorted

 

You can check the contents of the file dict.sorted using cat , more , or emacs .

 

--------------------------------------------------------------------------------

 

tail --- display last part of file

Use this command to look at the tail of a file. For example,

 

   % head essay.001

 

displays the last 10 lines of the file essay.001 To see a specific number of lines, do this:

 

   % head -20 essay.001

 

This displays the last 20 lines of the file.

 

--------------------------------------------------------------------------------

 

tar --- create an archive, add or extract files

Use create compressed archives of directories and files, and also to extract directories and files from an archive. Example:

 

   % tar -tvzf foo.tar.gz

 

displays the file names in the compressed archive foo.tar.gz while

 

   % tar -xvzf foo.tar.gz

 

extracts the files.

 

--------------------------------------------------------------------------------

 

telnet --- log in to another machine

Use this command to log in to another machine from the machine you are currently working on. For example, to log in to the machine "solitude", do this:

 

   % telnet solitude

 

See also: rsh.

 

--------------------------------------------------------------------------------

 

top --- display the most resource consuming processes in the below format

 

CPU TTY  PID USERNAME PRI NI   SIZE    RES STATE    TIME %WCPU  %CPU COMMAND

 0   ? 19984 root     240 20  2268K   576K run      0:33 28.76 28.71 gzip

 

--------------------------------------------------------------------------------

 

wc --- count characters, words, lines

Use this command to count the number of characters, words, and lines in a file. Suppose, for example, that we have a file dict with contents

 

red rojo

green verde

blue azul

white blanco

black negro

 

Then we can do this

   % wc dict

     5      10      56  dict

 

This shows that dict has 5 lines, 10 words, and 56 characters.

 

The word count command has several options, as illustrated below:

 

   % wc -l dict

     5 dict

   % wc -w dict

     10 dict

   % wc -c dict

     56 dict

 

--------------------------------------------------------------------------------

 

Read more...

Database Interview Questions - 4

Tuesday, May 4, 2010

Q: Can dual table be deleted, dropped or altered or updated or inserted?
A: Yes

Q: If content of dual is updated to some value computation takes place or not?
A: Yes

Q: If any other table same as dual is created would it act similar to dual?
A: Yes

Q: For which relational operators in where clause, index is not used?
A: <> , like '% ...' is NOT functions, field +constant, field || ''

Q: Assume that there are multiple databases running on one machine. How can you switch from one to another?
A: Changing the ORACLE_SID


Q: What are the advantages of Oracle?
A:           

·         Portability : Oracle is ported to more platforms than any of its competitors, running on more than 100 hardware platforms and 20 networking protocols.

·         Market Presence : Oracle is by far the largest RDBMS vendor and spends more on R & D than most of its competitors earn in total revenue. This market clout means that you are unlikely to be left in the lurch by Oracle and there are always lots of third party interfaces available.

·         Backup and Recovery : Oracle provides industrial strength support for on-line backup and recovery and good software fault tolerence to disk failure. You can also do point-in-time recovery.

·         Performance : Speed of a 'tuned' Oracle Database and application is quite good, even with large databases. Oracle can manage > 100GB databases.

·         Multiple database support : Oracle has a superior ability to manage multiple databases within the same transaction using a two-phase commit protocol.

Q: What is a forward declaration? What is its use?
A: PL/SQL requires that you declare an identifier before using it. Therefore, you must declare a subprogram before calling it. This declaration at the start of a subprogram is called forward declaration. A forward declaration consists of a subprogram specification terminated by a semicolon.


Q: What are actual and formal parameters?
A:

·         Actual Parameters : Subprograms pass information using parameters. The variables or expressions referenced in the parameter list of a subprogram call are actual parameters. For example, the following procedure call lists two actual parameters named emp_num and amount:
Eg. raise_salary(emp_num, amount);

·         Formal Parameters : The variables declared in a subprogram specification and referenced in the subprogram body are formal parameters. For example, the following procedure declares two formal parameters named emp_id and increase:
Eg. PROCEDURE raise_salary (emp_id INTEGER, increase REAL) IS current_salary REAL;

Q: What are the types of Notation?
A: Position, Named, Mixed and Restrictions.

Q: What all important parameters of the init.ora are supposed to be increased if you want to increase the SGA size?
A: In our case, db_block_buffers was changed from 60 to 1000 (std values are 60, 550 & 3500) shared_pool_size was changed from 3.5MB to 9MB (std values are 3.5, 5 & 9MB) open_cursors was changed from 200 to 300 (std values are 200 & 300) db_block_size was changed from 2048 (2K) to 4096 (4K) {at the time of database creation}.
The initial SGA was around 4MB when the server RAM was 32MB and The new SGA was around 13MB when the server RAM was increased to 128MB.

Q: If I have an execute privilege on a procedure in another users schema, can I execute his procedure even though I do not have privileges on the tables within the procedure?
A: Yes

Q: What are various types of joins?
A: Equijoins, Non-equijoins, self join, outer join

Q: What is a package cursor?
A: A package cursor is a cursor which you declare in the package specification without an SQL statement. The SQL statement for the cursor is attached dynamically at runtime from calling procedures.

Q: If you insert a row in a table, then create another table and then say Rollback. In this case will the row be inserted?
A: Yes. Because Create table is a DDL which commits automatically as soon as it is executed. The DDL commits the transaction even if the create statement fails internally (eg table already exists error) and not syntactically.


Q: What are the various types of queries?
A:

·         Normal Queries

·         Sub Queries

·         Co-related queries

·         Nested queries

·         Compound queries

Q: What is a transaction?
A: A transaction is a set of SQL statements between any two COMMIT and ROLLBACK statements.

Q: What is implicit cursor and how is it used by Oracle?
A: An implicit cursor is a cursor which is internally created by Oracle. It is created by Oracle for each individual SQL.

Q: Which of the following is not a schema object : Indexes, tables, public synonyms, triggers and packages ?
A: Public synonyms

Q: What is the difference between a view and a snapshot?

Q: What is PL/SQL?
A: PL/SQL is Oracle's Procedural Language extension to SQL. The language includes object oriented programming techniques such as encapsulation, function overloading, information hiding (all but inheritance), and so, brings state-of-the-art programming to the Oracle database server and a variety of Oracle tools.

Q: Is there a PL/SQL Engine in SQL*Plus?
A: No. Unlike Oracle Forms, SQL*Plus does not have a PL/SQL engine. Thus, all your PL/SQL are send directly to the database engine for execution. This makes it much more efficient as SQL statements are not stripped off and send to the database individually.

Q: Is there a limit on the size of a PL/SQL block?
A: Currently, the maximum parsed/compiled size of a PL/SQL block is 64K and the maximum code size is 100K. You can run the following select statement to query the size of an existing package or procedure.
SQL> select * from dba_object_size where name = 'procedure_name'

Q: Can one read/write files from PL/SQL?
A: Included in Oracle 7.3 is a UTL_FILE package that can read and write files. The directory you intend writing to has to be in your INIT.ORA file (see UTL_FILE_DIR=... parameter). Before Oracle 7.3 the only means of writing a file was to use DBMS_OUTPUT with the SQL*Plus SPOOL command.
DECLARE
fileHandler UTL_FILE.FILE_TYPE;
BEGIN
fileHandler := UTL_FILE.FOPEN('/home/oracle/tmp', 'myoutput','W');
UTL_FILE.PUTF(fileHandler, 'Value of func1 is %sn', func1(1));
UTL_FILE.FCLOSE(fileHandler);
END;

Q: How can I protect my PL/SQL source code?
A: PL/SQL V2.2, available with Oracle7.2, implements a binary wrapper for PL/SQL programs to protect the source code. This is done via a standalone utility that transforms the PL/SQL source code into portable binary object code (somewhat larger than the original). This way you can distribute software without having to worry about exposing your proprietary algorithms and methods. SQL*Plus and SQL*DBA will still understand and know how to execute such scripts. Just be careful, there is no "decode" command available.
The syntax is:
wrap iname=myscript.sql oname=xxxx.yyy

Q: Can one use dynamic SQL within PL/SQL? OR Can you use a DDL in a procedure? How?
A: From PL/SQL V2.1 one can use the DBMS_SQL package to execute dynamic SQL statements.

Eg: CREATE OR REPLACE PROCEDURE DYNSQL
AS
cur integer;
rc integer;
BEGIN
cur := DBMS_SQL.OPEN_CURSOR;
DBMS_SQL.PARSE(cur,'CREATE TABLE X (Y DATE)', DBMS_SQL.NATIVE);
rc := DBMS_SQL.EXECUTE(cur);
DBMS_SQL.CLOSE_CURSOR(cur);
END;

Read more...

Chitika

About This Blog

Followers

  © Blogger template The Professional Template II by Ourblogtemplates.com 2009

Back to TOP