Monday 30 April 2012

What is Software Assurance (SA)? | Networking

Software Assurance (SA) is a way for Volume Licensing customers to keep up to date with the latest and most innovative Microsoft products. Customers acquire the right to install any new release of a product covered in the agreement during the term of the coverage.

What is the difference between a Device CAL and a User CAL? | Networking

A Windows Server Device CAL permits one device to access or use the server software; whereas, a Windows Server User CAL permits one user irrespective of a device to access or use the server software.

What is Volume Licensing? | Networking

When you acquire licenses from Microsoft and its partners in certain quantities or volumes, they offer discounts from their retail product prices. Volume Licensing programs offer companies of all sizes an economical way to buy and manage multiple software licenses for as few as five desktops.

Is Windows Server 2008 a prerequisite for Windows Server 2008 R2? | Networking

No, Windows Server 2008 or Windows Server 2003 R2 can be upgraded to Windows Server 2008 R2.

What is File Classification Infrastructure (FCI)? | Networking

FCI provides a built-in solution to classify and manage files to users and help them to save time and money. Administrators can automatically classify files based on content and location, generate reports, and schedule file management tasks to manage data.

Explain the difference between Windows Server 2008 R2 license and Windows Server 2008 CAL. | Networking

The Windows Server 2008 CAL grants the right to a device or user to access the server software; whereas, the Windows Server 2008 R2 license gives the license holder the right to create, copy, store, and run the server software.

What is the function of Hyper-V Processor Compatibility Mode for live migration? | Networking

Hyper-V Processor Compatibility Mode allows live migration across different CPU versions within the same processor family, such as Intel Core 2 to Intel Pentium 4 or AMD Opteron to AMD Athlon. It also enables migration across a broader range of server host hardware.

What is the role of live migration in Windows 2008 R2? | Networking

Live migration enables customers to move virtual machines from one host to another with no perceivable downtime. It facilitates hardware maintenance, and upgrades manual failover and the consolidation of workloads on fewer servers.

What is Netsh? | Networking

Netsh is a command-line scripting utility that is used to display or modify the network configuration of a computer that is currently running. Both remote computers and local computers can be configured by using the netsh command. Netsh also provides a scripting feature that allows you to run a group of commands in batch mode against a specified computer.

What is the role of multiple active firewall profiles? | Networking

Multiple active firewall profiles enable the firewall rules most appropriate for each network adapter based on the network to which it is connected.

What is the role of NDF, Network Tracing, and Netsh Trace? | Networking

NDF, Network Tracing, and Netsh Trace integrate the Network Diagnostics Framework with Network Tracing and a new Netsh context, Netsh Trace, to simplify and consolidate network connectivity troubleshooting processes.

What is the role of mobile broadband device support? | Networking

Mobile broadband device support provides a driver-based model for devices that are used to access a mobile broadband network.

Sunday 29 April 2012

What is the role of URL-based QoS? | Networking


URL-based QoS enables administrators to assign a priority level to traffic based on the Uniform Resource Locator (URL) from which the traffic originates.

What is the role of BranchCache? | Networking


BranchCache enables updated content from file and Web servers on a Wide Area Network (WAN) to be cached on computers at a local branch office, improving application response time and reducing WAN traffic.

What is the role of VPN Reconnect? | Networking


VPN Reconnect automatically re-establishes a VPN connection as soon as Internet connectivity is restored, saving users from re-entering their credentials and recreating the VPN connection.

What is the role of DirectAccess? | Networking


DirectAccess enables users to access an enterprise network without the extra step of initiating a Virtual Private Network (VPN) connection.

What are the new networking features in Windows 2008 R2? | Networking


Following are the new networking features in Windows 2008 R2:
1. DirectAccess
2. VPN Reconnect
3. BranchCache
4. URL-based Quality of Service (QoS)
5. Mobile broadband device support
6. Multiple active firewall profiles
7. NDF, Network Tracing, and Netsh Trace

What are the different service packs available for Windows 2003 and Windows 2008?


For both Windows 2003 and Windows 2008, available service packs are SP1 and SP2.

What do you mean by client and server? | Networking


Client and server are two different machines (physical or virtual) connected in such a manner that whenever a client posts some request to a server, the server provides an appropriate response to the client.

What is device driver? | Networking

Device driver Is a software component that provides an interface between the hardware of a computer and its operating system. Hardware, such as keyboards, controllers, and graphics cards, requires device drivers so that the operating system can detect the devices and handle them effectively and efficiently.

What is NetBIOS? | Networking

NetBIOS stands for Network Basic Input / Output System. It is an application interface, which operates at the session layer. It enables communication between applications with NetBIOS compliant protocol. NetBIOS applications can be supported over Transmission Control Protocol/Internet Protocol (TCP/IP) and IPX/SPX.

Where is IPX/SPX used? | Networking

IPX/SPX stands for Internetwork Packet Exchange/Sequenced Packet Exchange. It is used in the Netware environment. IPX runs at the network layer of the Open Systems Interconnection (OSI) model; whereas, SPX runs at the transport layer of the OSI model.

What is NetBIOS Extended User Interface (NetBEUI) and is it routable? | Networking

 NetBEUI is designed for peer-to-peer network and is a high speed protocol used on small networks. It provides a good recovery and error protection.
No, it is not routable.

What is network binding? | Networking

A network binding binds a protocol to an adapter to carry traffic using that protocol.
 

What is Fiber Distributed Data Interface (FDDI)? | Networking

FDDI is a token-passing dual ring fiber optic LAN specification. It supports higher transmission speeds across larger distances of around 2 km (1.3 miles) between two stations.
 

What is the maximum network length of 10Base2 and 10Base5? | Networking

The maximum network length of 10Base2 is 185 m for each segment and can be extended up to five segments.
The maximum network length of 10Base5 is 500m for each segment and can be extended up to five segments.

How many stations can be connected to 10Base2, lOBaseT, and 10Base5? | Networking

 Maximum stations that can be connected to 10Base2 are 30 stations.
Maximum stations that can be connected to lOBaseT are 1024 stations per network.
Maximum stations that can be connected to 10Base5 are 100 nodes per segment and maximum network length of 10Base5 is five segments, that is, approximately 2500 m or 8200 ft.

List the reasons of transmission failure. | Networking

Transmission failure can be caused by the following reasons:
1.    Bad cabling
2.    Improper termination
3.    Collisions
4.    Improper cable length.

What is token passing? | Networking

A token is a small frame, which is passed from one node to another in a token ring network. If a node has data to send, it must wait until it receives a token. After the token is received by the node, it seizes the token, marks it as used, and attaches the data. The frame is then addressed to the destination node and the node continues passing the data around the ring until it arrives at the destination node. The destination node copies the data and marks the frame as received. When the sender node receives the frame, it implies that the data is successfully delivered. The sender node then frees the token to be used by another node.

What is CSMA/CD? | Networking

 CSMA/CD is a layer 2 access method in which if a transmitting data station detects another signal while transmitting a frame, it stops transmitting the frame. Instead of the frame, it transmits a jam signal, and then waits for a random time interval before trying to send the frame again.

Multiple devices cannot communicate on the network simultaneously; therefore, what type of method must be used to allow one device to access network media at a time?

Carrier Sense Multiple Access / Collision Detection (CSMA/CD) and token passing.

What is hub? | Networking

A hub is a device that connects multiple user stations, each through a dedicated cable.

What is repeater? | Networking

A repeater is a device used to interconnect the media segments of an extended network. It enables a series of cable segments to be treated as a single cable. Repeaters receive signals from one network segment and amplify, retime, and retransmit those signals to another network segment to prevent signal deterioration caused by long cable lengths and large numbers of connected devices.
 

What devices are commonly used in LAN networks? Networking

The commonly used devices in a LAN network are repeaters, hubs, LAN extenders, bridges, LAN switches, and routers.

Explain tree topology. | Networking

A tree topology is a LAN architecture that is similar to the bus topology but with multiple nodes. It can also be defined as a combination of the bus and star topologies.

What types of topologies are commonly used for Local Area Network (LAN) and Wide Area Network (WAN)? | Networking

 Bus, ring, star, mesh, tree, and cellular topologies are used for LANs; whereas, point-to-point, multipoint, mesh, and cloud topologies are used for WANs.

What is the length of USB cable? | Networking

Normally, USB cables are limited to 5m; however, hubs can be used as an active USB repeater to extend the cable length for up to 5m at a time.

How many devices can be connected to one USB port? | Networking

USB hubs can generally extend a USB network to a maximum of 127 ports.

What type of connector is used to connect a modem to wall jack? | Networking

  RJ-11 is used to connect a modem to wall jack.

What is the use of USB connector? | Networking

 USB is an external hardware interface and communications standard that is utilized for connecting varied peripherals to a computer, such as mouse, external drive, digital cameras, memory sticks, and gaming peripherals.

What is the use of RJ-45 connector? | Networking

The FU-45 connector is an industry standard for Ethernet and Fast Ethernet networking. It is used to attach short cable (patch cable) to connect the computer to wall jack.

What is the use of RJ-11 connector? | Networking

The RJ-11 connector is generally used to connect standard telephone cord.
 

What are the different types of connectors? | Networking

The different types of connectors are DB-9, DB-25, RJ-11, RJ- 45, Bayonet Neill-Concelman (BNC), PS2/MINI-DIN, and Universal Serial Bus (USB).

What connectors are used in the Ethernet and wireless network cards? | Networking

   Ethernet network cards use the RJ-45 connector; whereas, wireless network cards usually have no external connections other than an antenna jack.

List the different types of network card. | Networking

   The different types of network card are as follows:
1.    Ethernet card
2.    Wireless network card
3.    Token Ring network card.

What is a network card? | Networking

  A network card Is an expansion card installed in a computer that enables the computer to be physically connected to a network.

Thursday 26 April 2012

Networking Interview Questions and Answers PDF free Download

Chapter 1: Network Cards

1. What is a network card?
2. List the different types of network card.
3. What connectors are used in the Ethernet and wirelessnetwork cards?
4. What are the different types of connectors?
5. What is the use of FU-11 connector?
6. What is the use of RJ-45 connector?
7. What is the use of USB connector?
8. What type of connector is used to connect a modem to wall jack?
9. How many devices can be connected to one USB port?
10. What is the length of USB cable?

Chapter 2: Topologies and Protocol Suites

1. What types of topologies are commonly used for Local Area Network (LAN) and Wide Area Network (WAN)?
2. Explain tree topology.
3. What devices are commonly used in LAN networks?
4. What is repeater?
5. What is hub?
6. Multiple devices cannot communicate on the network simultaneously; therefore, what type of method must be used to allow one device to access network media at a time?
7. What is CSMA/CD?
8. What is token passing?
9. List the reasons of transmission failure.
10. How many stations can be connected to 10Base2, lOBaseT, and 10Base5?
11. What is the maximum network length of 10Base2 and 10Base5?
12. What is Fiber Distributed Data Interface (FDDI)?
13. What is network binding?
14. What is NetBIOS Extended User Interface (NetBEUI) and is it routable?
15. Where is IPX/SPX used?
16. What is NetBIOS?

Chapter 3: Managing Client and Server Computers

1. What is device driver?
2. What do you mean by client and server?
3. What are the different service packs available for Windows 2003 and Windows 2008?
4. What are the new networking features in Windows 2008 R2?
5. What is the role of DirectAccess?
6. What is the role of VPN Reconnect?
7. What is the role of BranchCache?
8. What is the role of URL-based QoS?
9. What is the role of mobile broadband device support?
10. What is the role of multiple active firewall profiles?
11. What is the role of NDF, Network Tracing, and Netsh Trace?
12. What is Netsh?
13. What is the role of live migration in Windows 2008 R2?
14. What is the function of Hyper-V Processor Compatibility Mode for live migration?
15. What is File Classification Infrastructure (FCI)?
16. Explain the difference between Windows Server 2008 R2 license and Windows Server 2008 CAL.
17. Is Windows Server 2008 a prerequisite for Windows Server 2008 R2?
18. What is the difference between a Device CAL and a User CAL?
19. What is Volume Licensing?
20. What is Software Assurance (SA)?

Chapter 4: Sharing Drives and Printers

1. Name the groups you must be a member of to share a folder.
2. How do you share a folder causing it to remain hidden from users browsing the network?
3. What are the different ways in which a user can connect to a shared folder?
4. Where does the Administrators group share the folder?
5. Where does the Server Operator group share the folder?
6. Where does the Power Users group share the folder?
7. List the steps to share the host drive with virtual machines.
8. What is Virtual Hard Disk (VHD)?
9. What is the function of Access-based Enumeration?
10. What is a print server?
11. Name the groups you should be member of to manager remote print server.
12. What are the steps to deploy the printers to users or computers by using Group Policy?
13. What is Location-Aware Printing?
14. What is the role of Print and Document Services in Windows 2008 R2?

Chapter 5: Monitoring Server Health and Security

1. Which tool is used to monitor the performance in Windows Server 2008 R2?
2. List the new features of the Performance and Reliability Monitor tool.
3. What is the role of Reliability Monitor?
4. What is unified property configuration?
5. What is the benefit of using the Performance and Reliability Monitor tool?
6. Which feature of Performance and Reliability Monitor adds counters to log files and gives the ability to set the start, stop, and duration of those counters?
7. What is Authorization Manager?
8. What is role-based management model?
9. What are user authorization roles?
10. What are computer configuration roles?
11. What is Windows BitLocker Drive Encryption?
12. Which command is used to install the BitLocker in Windows 2008?
13. What is Encrypting File System (EFS)?
14. Give the full forms of KRA and DRA.
15. What is the use of Robocopy utility?
16. What new functionalities are added to EFS?
17. How and when smart card Single Sign-On (SSO) is triggered?
18. If the smart card used for the logon is removed from the smart card reader before any encryption operations are performed, will the user be prompted for a smart card and PIN at the first EFS operation?
19. What is the function of AppLocker?
20. What is the new feature of the smart cards used in Windows 2008 R2?
21. What is the use of User Account Control (UAC)?

Chapter 6: TCP/IP Administration

1. Name the drivers used for IPv4 and IPv6 protocol stacks.
2. Explain the architecture of Next Generation TCP/IP stack.
3. What is Teredo?
4. What is the structure of Teredo IPv6 addressing?
5. What is IPv6 address?
6. What is loopback address for IPv4 and IPv6?
7. Do you need subnet mask in IPv6?
8. How do you represent the sequential zeros in IPv6?
9. Is Domain Name System (DNS) used in IPv6?
10. Which domain is used for reverse hostname resolution in IPv6?
11. How do you make IPv6 compatible with IPv4 networks?
12. What is role special domain for IPv6 address translation in Microsoft?
13. What are the different types of IPv6 addresses?
14. Which command is used to check the IPv6 address?
15. Which commands are used to ping for IPv6 address?

Chapter 7: Dynamic Host Configuration Protocol and Managing IIS

1. What is Dynamic host Configuration Protocol (DHCP)?
2. How does Microsoft Windows 2008 support DHCP?
3. Does the Windows Server 2008 DHCP Server service support BOOTP?
4. What is DHCP for IPv6?
5. How does DHCP work?
6. What protocols and ports are used by DHCP traffic?
7. List the different kinds of DHCP messages.
8. How does the DHCP server determine the originating subnet of the DHCP client?
9. How is the DHCP Server service integrated with Active Directory?
10. How does the authorization process work for DHCP server computers?
11. How does remote access client uses DHCP to obtain an IP address configuration?
12. What is the use of Stateless Address Autoconfiguration?
13. What is the use of Stateful Address Autoconfiguration?
14. List the different types of DHCPv6 messages.
15. What are the tools used for troubleshooting DHCP servers?
16. What are the new features of Internet Information Services 7.0 (IIS 7.0)?
17. What are the enhanced Web security features with IIS 7.0?
18. Explain the IIS 7.0's new architecture.
19. Why Web administration has become easier?
20. List the different types of authentications in IIS.
21. What is the use of Windows PowerShell Provider for IIS 7.0?
22. What is the use of Appcmd.exe tool?
23. What is Windows Management Instrumentation (WMI) provider?
24. What are the two main layers of IIS architecture?
25. What is IIS Server Web farm?
26. What is the role of HTTP.sys?
27. What are the benefits of HTTP.sys?
28. At what level the procedure for configuring logging can be performed?

Chapter 8: Remote Client Access

1. What is DirectAccess?
2. What is the function of Unified Access Gateway (UAG)?
3. What is the benefit of UAG?
4. What is Remote Desktop?
5. List the steps to enable Remote Desktop Administration.

Chapter 9: LAN's Bridges and Switches and TCP/IP and IP Routing

1. What is the difference between a bridge and a switch?
2. Why is switching implementation preferred over bridging?
3. What is a switch?
4. Which technology is used by switches to build and maintain their filter table?
5. Give some examples of packet switching technology.
6. Which table is used by switches to determine the segment on which a datagram needs to be transmitted?
7. Why Layer 2 switches cannot replace the routers?
8. What is switching?
9. What is the difference between Layer 2 and Layer 3 switching?
10. What are the functions of Layer 2 switching?
11. What is Spanning Tree Protocol (STP)?
12. How does spanning tree works?
13. What is a root bridge?
14. How is root bridge selected?
15. List the different states of spanning tree port.
16. Name the LAN switch types.
17. What is cut-through (real time) mode?
18. What is store and forward mode?
19. How is interface represented?
20. What is collision domain?
21. What is the role of Cyclic Redundancy Check (CRC)?
22. What do you understand by CSMA/CD?
23. What is the difference between broadcast domain and collision domain?
24. What is broadcast storm?
25. What is Virtual Local Area Network (VLAN)?
26. What is frame filtering?
27. What is frame tagging?
28. What are the different types of VLAN implementation methods?
29. What is VLAN Trunking Protocol (VTP)?
30. What is Dynamic Trunking Protocol (DTP)?
31. Can you configure existing hubs in a company as part of the VLAN architecture?
32. Give the full forms of TCP, UDP, IP, and ICMP.
33. Is ICMP a Layer 2 or Layer 3 protocol?
34. Which layer of the OSI model does IP, TCP, and UDP work on?
35. What is the full form of FTP and TFTP? At which layer do they work on?
36. How many TCP segments are exchanged to establish and terminate TCP connection?
37. What is the purpose of trace command?
38. Name the parts of IP address.
39. What is subnet mask?
40. What are the classes of IPv4 address?

Chapter 10: Routing and Routing Protocol

1. What is routing?
2. What is the role of ARP?
3. What is the difference between static and dynamic routing?
4. When do you get the request timed out error?
5. When do you get the destination unreachable error?
6. What is Administrative Distance?
7. How does router share information in Distance Vector routing?
8. What is a hop count? What is the maximum hop count for RIP?
9. Explain split horizon.
10. Explain route poisoning.
11. Explain holddown timer.
12. What are the timers of RIP, Interior Gateway Routing Protocol (IGRP), Enhanced Interior Gateway Routing Protocol (EIGRP), and OSPF routing protocols?
13. What are the default Administrative Distances of RIP, IGRP, EIGRP, and OSPF routing protocols?
14. What is black hole?
15. What is the difference between RIPvl and RIPv2?
16. What packet formats are used in EIGRP?
17. What does RIPv2 uses to prevent routing loops?
18. When you use the debug ip rip command and get a metricl6, what does it mean?
19. What are the parameters used by IGRP for finding the best path?
20. Which route will the router choose by default when the table has static, RIP, and IGRP route?
21. Which EIGRP information is stored in RAM by using the hello and update packets?
22. What is the difference between EIGRP and IGRP?
23. What is the difference between classful and classless routing protocol?
24. Give some examples of classful and classless routing protocols.
25. Which protocols supports VLSM?
26. When do you use BGP, IGRP, OSPF, and static route?
27. Explain ISDN.
28. What types of services are associated with ISDN?
29. Explain the BRI service.
30. Explain PRI service.

Chapter 11: WAN Protocol and Security

1. What is the basic unit of T-carrier system?
2. What is Tl?
3. What is El?
4. What is four-wire circuit?
5. What is two-wire circuit?
6. How many B-channels and D-channels are available in BRI, PRI(Tl), and RI(E1)?
7. Which data link protocols are valid on ISDN B-channel?
8. Define the term PAP and CHAP.
9. What do ISDN, BRI, PRI stands for?
10. What is Multilink Point-to-Point Protocol (MLPP)?
11. What is the use of Data Service Unit/Channel Service Unit (DSU/CSU)?
12. What is clock source?
13. On which channel LDAP is used on ISDN?
14. What is SPID?
15. What EIA/TIA standard interface are used for serial cable with Cisco routers?

How do I interface to C++ objects from Python? | Python

Depending on your requirements, there are many approaches. To do this manually, begin by reading the "Extending and Embedding" document. Realize that for the Python run-time system, there isn't a whole lot of difference between C and C++ -- so the strategy of building a new Python type around a C structure (pointer) type will also work for C++ objects.

How do I access a module written in Python from C? | Python

You can get a pointer to the module object as follows:
module = PyImport_ImportModule("");
If the module hasn't been imported yet (i.e. it is not yet present in sys.modules), this initializes the module; otherwise it simply returns the value of sys.modules[""]. Note that it doesn't enter the module into any namespace -- it only ensures it has been initialized and is stored in sys.modules.
You can then access the module's attributes (i.e. any name defined in the module) as follows: attr = PyObject_GetAttrString(module, "");
Calling PyObject_SetAttrString() to assign to variables in the module also works.

How do I extract C values from a Python object? | Python

That depends on the object's type. If it's a tuple, PyTupleSize(o) returns its length and
PyTuple_GetItem(o, i) returns its i'th item. Lists have similar functions, PyListSize(o) and PyList_GetItem(o, i).
For strings, PyString_Size(o) returns its length and PyString_AsString(o) a pointer to its value. Note that Python strings may contain null bytes so C's strlen() should not be used.
To test the type of an object, first make sure it isn't NULL, and then use PyString_Check(o), PyTuple_Check(o), PyList_Check(o), etc.

There is also a high-level API to Python objects which is provided by the so-called 'abstract' interface -- read Include/abstract.h for further details. It allows interfacing with any kind of Python sequence using calls like PySequence_Length(), PySequence_GetItem(), etc.) as well as many other useful protocols.

How can I evaluate an arbitrary Python expression from C? | Python

Call the function PyRun_String() from the previous question with the start symbol Py_eval_input; it parses an expression, evaluates it and returns its value.

Can I create my own functions in C++? | Python

Yes, using the C compatibility features found in C++. Place extern "C" { ... } around the Python include files and put extern "C" before each function that is going to be called by the Python interpreter. Global or static C++ objects with constructors are probably not a good idea.

How can I execute arbitrary Python statements from C? | Python

The highest-level function to do this is PyRun_SimpleString() which takes a single string argument to be executed in the context of the module __main__ and returns 0 for success and -1 when an exception occurred (including SyntaxError). If you want more control, use PyRun_String(); see the source for PyRun_SimpleString() in Python/pythonrun.c.

Can I create my own functions in C? | Python

Yes, you can create built-in modules containing functions, variables, exceptions and even new types in C.

How do I generate random numbers in Python? | Python

The standard module random implements a random number generator. Usage is simple:
import random
random.random()
This returns a random floating point number in the range [0, 1).

How do I avoid blocking in the connect() method of a socket? | Python

The select module is commonly used to help with asynchronous I/O on sockets.

Are there any interfaces to database packages in Python? | Python

Yes.
Python 2.3 includes the bsddb package which provides an interface to the BerkeleyDB library.
Interfaces to disk-based hashes such as DBM and GDBM are also included with standard Python.

Why don't my signal handlers work? | Python

The most common problem is that the signal handler is declared with the wrong argument list. It is called as:
handler(signum, frame)
so it should be declared with two arguments: def handler(signum, frame).

How do I make a Python script executable on Unix? | Python

You need to do two things: the script file's mode must be executable and the first line must begin with #! followed by the path of the Python interpreter.
The first is done by executing chmod +x scriptfile or perhaps chmod 755 scriptfile.
The second can be done in a number of ways. The most straightforward way is to write
#!/usr/local/bin/python
as the very first line of your file, using the pathname for where the Python interpreter is installed on your platform.
If you would like the script to be independent of where the Python interpreter lives, you can use the "env" program. Almost all Unix variants support the following, assuming the python interpreter is in a directory on the user's $PATH:
#! /usr/bin/env python
Don't do this for CGI scripts. The $PATH variable for CGI scripts is often very minimal, so you need to use the actual absolute pathname of the interpreter.
Occasionally, a user's environment is so full that the /usr/bin/env program fails; or there's no env program at all. In that case, you can try the following hack (due to Alex Rezinsky):
#! /bin/sh
""":"
exec python $0 ${1+"$@"}
"""
The minor disadvantage is that this defines the script's __doc__ string. However, you can fix that by adding
__doc__ = """...Whatever..."""

Where is the math.py (socket.py, regex.py, etc.) source file? | Python

There are (at least) three kinds of modules in Python:
1. modules written in Python (.py);
2. modules written in C and dynamically loaded (.dll, .pyd, .so, .sl, etc);
3. modules written in C and linked with the interpreter; to get a list of these, type: import sys print sys.builtin_module_names

How do I find the current module name? | Python

A module can find out its own module name by looking at the predefined global variable __name__. If this has the value '__main__', the program is running as a script. Many modules that are usually used by importing them also provide a command-line interface or a self-test, and only execute this code after checking __name__:
def main():
print 'Running test...'
if __name__ == '__main__':
main()
__import__('x.y.z') returns
Try:
__import__('x.y.z').y.z
For more realistic situations, you may have to do something like m = __import__(s)
for i in s.split(".")[1:]: m = getattr(m, i)

How can I overload constructors (or methods) in Python? | Python

This answer actually applies to all methods, but the question usually comes up first in the context of constructors.
In C++ you'd write
class C {
C() { cout << "No arguments\n"; }
C(int i) { cout << "Argument is " << i << "\n"; }
}
in Python you have to write a single constructor that catches all cases using default arguments. For example:
class C:
def __init__(self, i=None): if i is None:
print "No arguments"
else:
print "Argument is", i
This is not entirely equivalent, but close enough in practice. You could also try a variable-length argument list, e.g.
def __init__(self, *args):
The same approach works for all method definitions.

How do I create static class data and static class methods? | Python

Static data (in the sense of C++ or Java) is easy; static methods (again in the sense of C++ or Java) are not supported directly.
For static data, simply define a class attribute. To assign a new value to the attribute, you have to explicitly use the class name in the assignment:
class C:
count = 0 # number of times C.__init__ called
def __init__(self):
C.count = C.count + 1
def getcount(self):
return C.count # or return self.count
c.count also refers to C.count for any c such that isinstance(c, C) holds, unless overridden by c itself or by some class on the base-class search path from c.__class__ back to C.
Caution: within a method of C, an assignment like self.count = 42 creates a new and unrelated instance vrbl named "count" in self's own dict. Rebinding of a class-static data name must always specify the class whether inside a method or not:
C.count = 314
Static methods are possible when you're using new-style classes:
class C:
def static(arg1, arg2, arg3): # No 'self' parameter!
static = staticmethod(static)
However, a far more straightforward way to get the effect of a static method is via a simple modulelevel function:
def getcount():
return C.count
If your code is structured so as to define one class (or tightly related class hierarchy) per module, this supplies the desired encapsulation.

How do I call a method defined in a base class from a derived class that overrides it? | Python

If you're using new-style classes, use the built-in super() function:
class Derived(Base):
def meth (self):
super(Derived, self).meth()
If you're using classic classes: For a class definition such as class Derived(Base): ... you can call method meth() defined in Base (or one of Base's base classes) as Base.meth(self, arguments...). Here, Base.meth is an unbound method, so you need to provide the self argument.

What is delegation? | Python

Delegation is an object oriented technique (also called a design pattern). Let's say you have an object x and want to change the behavior of just one of its methods. You can create a new class that provides a new implementation of the method you're interested in changing and delegates all other methods to the corresponding method of x.
Python programmers can easily implement delegation. For example, the following class implements a class that behaves like a file but converts all written data to uppercase:
class UpperOut:
def __init__(self, outfile): self.__outfile = outfile def write(self, s):
self.__outfile.write(s.upper())
def __getattr__(self, name):
return getattr(self.__outfile, name)
Here the UpperOut class redefines the write() method to convert the argument string to uppercase before calling the underlying self.__outfile.write() method. All other methods are delegated to the underlying self.__outfile object. The delegation is accomplished via the __getattr__ method; consult the language reference for more information about controlling attribute access.
Note that for more general cases delegation can get trickier. When attributes must be set as well as retrieved, the class must define a __settattr__ method too, and it must do so carefully. The basic implementation of __setattr__ is roughly equivalent to the following:
class X:
def __setattr__(self, name, value): self.__dict__[name] = value
Most __setattr__ implementations must modify self.__dict__ to store local state for self without causing an infinite recursion.

What is a method? | Python

A method is a function on some object x that you normally call as x.name(arguments...). Methods are defined as functions inside the class definition:
class C:
def meth (self, arg):
return arg*2 + self.attribute.

What is a class? | Python

A class is the particular object type created by executing a class statement. Class objects are used as templates to create instance objects, which embody both the data (attributes) and code (methods) specific to a datatype.
A class can be based on one or more other classes, called its base class(es). It then inherits the attributes and methods of its base classes. This allows an object model to be successively refined by inheritance.
You might have a generic Mailbox class that provides basic accessor methods for a mailbox, and subclasses such as MboxMailbox, MaildirMailbox, OutlookMailbox that handle various specific mailbox formats.

I want to do a complicated sort: can you do a Schwartzman Transform in Python? | Python

Yes, it's quite simple with list comprehensions.
The technique, attributed to Randal Schwartz of the Perl community, sorts the elements of a list by a metric which maps each element to its "sort value". To sort a list of strings by their uppercase values:
tmp1 = [ (x.upper(), x) for x in L ] # Schwartzman transform
tmp1.sort()
Usorted = [ x[1] for x in tmp1 ]
To sort by the integer value of a subfield extending from positions 10-15 in each string:
tmp2 = [ (int(s[10:15]), s) for s in L ] # Schwartzman transform tmp2.sort()
Isorted = [ x[1] for x in tmp2 ]
Note that Isorted may also be computed by
def intfield(s):
return int(s[10:15])
def Icmp(s1, s2):
return cmp(intfield(s1), intfield(s2))
Isorted = L[:]
Isorted.sort(Icmp)
but since this method calls intfield() many times for each element of L, it is slower than the Schwartzman Transform.

How do I apply a method to a sequence of objects? | Python

Use a list comprehension:
result = [obj.method() for obj in List]
More generically, you can try the following function:
def method_map(objects, method, arguments):
"""method_map([a,b], "meth", (1,2)) gives [a.meth(1,2), b.meth(1,2)]""" nobjects = len(objects)
methods = map(getattr, objects, [method]*nobjects)
return map(apply, methods, [arguments]*nobjects)

How do I create a multidimensional list? | Python

You probably tried to make a multidimensional array like this:
A = [[None] * 2] * 3
This looks correct if you print it:
>>> A
[[None, None], [None, None], [None, None]]
But when you assign a value, it shows up in multiple places:
>>> A[0][0] = 5
>>> A
[[5, None], [5, None], [5, None]]
The reason is that replicating a list with * doesn't create copies, it only creates references to the existing objects. The *3 creates a list containing 3 references to the same list of length two. Changes to one row will show in all rows, which is almost certainly not what you want.
The suggested approach is to create a list of the desired length first and then fill in each element with a newly created list:
A = [None]*3
for i in range(3):
A[i] = [None] * 2
This generates a list containing 3 different lists of length two. You can also use a list comprehension:
w,h = 2,3
A = [ [None]*w for i in range(h) ]
Or, you can use an extension that provides a matrix datatype; Numeric Python is the best known.

How do you remove duplicates from a list? | Python

If you don't mind reordering the list, sort it and then scan from the end of the list, deleting duplicates as
you go:
if List:
List.sort()
last = List[-1]
for i in range(len(List)-2, -1, -1): if last==List[i]: del List[i]
else: last=List[i]
If all elements of the list may be used as dictionary keys (i.e. they are all hash able) this is often faster
d = {}
for x in List: d[x]=x
List = d.values()
How do you make an array in Python?
Use a list:
["this", 1, "is", "an", "array"]
Lists are equivalent to C or Pascal arrays in their time complexity; the primary difference is that a Python list can contain objects of many different types.
The array module also provides methods for creating arrays of fixed types with compact representations, but they are slower to index than lists. Also note that the Numeric extensions and others define array-like structures with various characteristics as well.
To get Lisp-style linked lists, you can emulate cons cells using tuples: lisp_list = ("like", ("this", ("example", None) ) )
If mutability is desired, you could use lists instead of tuples. Here the analogue of lisp car is lisp_list[0] and the analogue of cdr is lisp_list[1]. Only do this if you're sure you really need to, because it's usually a lot slower than using Python lists.

Wednesday 25 April 2012

How do I iterate over a sequence in reverse order? | Python

If it is a list, the fastest solution is
list.reverse()
try:
for x in list:
"do something with x"
finally:
list.reverse()
This has the disadvantage that while you are in the loop, the list is temporarily reversed. If you don't like this, you can make a copy. This appears expensive but is actually faster than other solutions:
rev = list[:]
rev.reverse()
for x in rev:

If it's not a list, a more general but slower solution is:
for i in range(len(sequence)-1, -1, -1): x = sequence[i]

A more elegant solution, is to define a class which acts as a sequence and yields the elements in reverse order (solution due to Steve Majewski):
class Rev:
def __init__(self, seq): self.forw = seq
def __len__(self):
return len(self.forw)
def __getitem__(self, i):
return self.forw[-(i + 1)]
You can now simply write:
for x in Rev(list):

Unfortunately, this solution is slowest of all, due to the method call overhead. With Python 2.3, you can use an extended slice syntax:
for x in sequence[::-1]:

What's a negative index? | Python

Python sequences are indexed with positive numbers and negative numbers. For positive numbers 0 is the first index 1 is the second index and so forth. For negative indices -1 is the last index and -2 is the penultimate (next to last) index and so forth. Think of seq[-n] as the same as seq[len(seq)-n].
Using negative indices can be very convenient. For example S[:-1] is all of the string except for its last character, which is useful for removing the trailing newline from a string.

How do I convert between tuples and lists? | Python

The function tuple(seq) converts any sequence (actually, any iterable) into a tuple with the same items in the same order.
For example, tuple([1, 2, 3]) yields (1, 2, 3) and tuple('abc') yields ('a', 'b', 'c'). If the argument is a tuple, it does not make a copy but returns the same object, so it is cheap to call tuple() when you aren't sure that an object is already a tuple.
The function list(seq) converts any sequence or iterable into a list with the same items in the same order. For example, list((1, 2, 3)) yields [1, 2, 3] and list('abc') yields ['a', 'b', 'c']. If the argument is a list, it makes a copy just like seq[:] would.

Is there a scanf() or sscanf() equivalent? | Python

Not as such.
For simple input parsing, the easiest approach is usually to split the line into whitespace-delimited words using the split() method of string objects and then convert decimal strings to numeric values using int() or float(). split() supports an optional "sep" parameter which is useful if the line uses something other than whitespace as a separator.
For more complicated input parsing, regular expressions more powerful than C's sscanf() and better suited for the task. 1.3.9 What does 'UnicodeError: ASCII [decoding,encoding] error: ordinal not in range(128)' mean?
This error indicates that your Python installation can handle only 7-bit ASCII strings. There are a couple ways to fix or work around the problem.
If your programs must handle data in arbitrary character set encodings, the environment the application runs in will generally identify the encoding of the data it is handing you. You need to convert the input to Unicode data using that encoding. For example, a program that handles email or web input will typically find character set encoding information in Content-Type headers. This can then be used to properly convert input data to Unicode. Assuming the string referred to by value is encoded as UTF-8:
value = unicode(value, "utf-8")
will return a Unicode object. If the data is not correctly encoded as UTF-8, the above call will raise a UnicodeError exception.
If you only want strings converted to Unicode which have non-ASCII data, you can try converting them first assuming an ASCII encoding, and then generate Unicode objects if that fails:
try:
x = unicode(value, "ascii") except UnicodeError:
value = unicode(value, "utf-8")
else:
# value was valid ASCII data
pass
It's possible to set a default encoding in a file called sitecustomize.py that's part of the Python library. However, this isn't recommended because changing the Python-wide default encoding may cause thirdparty extension modules to fail.
Note that on Windows, there is an encoding known as "mbcs", which uses an encoding specific to your current locale. In many cases, and particularly when working with COM, this may be an appropriate default encoding to use.

How do I use strings to call functions/methods? | Python

There are various techniques.
* The best is to use a dictionary that maps strings to functions. The primary advantage of this technique is that the strings do not need to match the names of the functions. This is also the primary technique used to emulate a case construct:
def a():
pass
def b():
pass
dispatch = {'go': a, 'stop': b} # Note lack of parens for funcs
dispatch[get_input()]() # Note trailing parens to call function
*
Use the built-in function getattr():
import foo
getattr(foo, 'bar')()
Note that getattr() works on any object, including classes, class instances, modules, and so on. This is used in several places in the standard library, like this:
class Foo:
def do_foo(self):
def do_bar(self):
f = getattr(foo_instance, 'do_' + opname)
f()
*
Use locals() or eval() to resolve the function name:
def myFunc():
print "hello"
fname = "myFunc"
f = locals()[fname]
f()
f = eval(fname)
f()
Note: Using eval() is slow and dangerous. If you don't have absolute control over the contents of the string, someone could pass a string that resulted in an arbitrary function being executed.
Is there an equivalent to Perl's chomp() for removing trailing newlines from strings?
Starting with Python 2.2, you can use S.rstrip("\r\n") to remove all occurences of any line terminator
from the end of the string S without removing other trailing whitespace. If the string S represents more
than one line, with several empty lines at the end, the line terminators for all the blank lines will be
removed:
>>> lines = ("line 1 \r\n"
... "\r\n"
... "\r\n")
>>> lines.rstrip("\n\r")
"line 1 "
Since this is typically only desired when reading text one line at a time, using S.rstrip() this way works
well.
For older versions of Python, There are two partial substitutes:
* If you want to remove all trailing whitespace, use the rstrip() method of string objects. This removes all trailing whitespace, not just a single newline.
* Otherwise, if there is only one line in the string S, use S.splitlines()[0].
Is there a scanf() or sscanf() equivalent?
Not as such.
For simple input parsing, the easiest approach is usually to split the line into whitespace-delimited words using the split() method of string objects and then convert decimal strings to numeric values using int() or float(). split() supports an optional "sep" parameter which is useful if the line uses something other than whitespace as a separator.
For more complicated input parsing, regular expressions more powerful than C's sscanf() and better suited for the task.

How do I modify a string in place? | Python

You can't, because strings are immutable. If you need an object with this ability, try converting the string to a list or use the array module:
>>> s = "Hello, world" >>> a = list(s)
>>>print a
['H', 'e', 'l', 'l', 'o', ',', ' ', 'w', 'o', 'r', 'l', 'd'] >>> a[7:] = list("there!")
>>>''.join(a)
'Hello, there!'
>>> import array
>>> a = array.array('c', s) >>> print a
array('c', 'Hello, world')
>>> a[0] = 'y' ; print a
array('c', 'yello world')
>>> a.tostring()
'yello, world'

How do I convert a number to a string? | Python

To convert, e.g., the number 144 to the string '144', use the built-in function str(). If you want a hexadecimal or octal representation, use the built-in functions hex() or oct(). For fancy formatting, use the % operator on strings, e.g. "%04d" % 144 yields '0144' and "%.3f" % (1/3.0) yields '0.333'. See the library reference manual for details.

How can my code discover the name of an object? | Python

Generally speaking, it can't, because objects don't really have names. Essentially, assignment always binds a name to a value; The same is true of def and class statements, but in that case the value is a callable. Consider the following code:
class A:
pass
B = A
a = B()
b = a
print b
<__main__.A instance at 016D07CC>
print a
<__main__.A instance at 016D07CC>
Arguably the class has a name: even though it is bound to two names and invoked through the name B the created instance is still reported as an instance of class A. However, it is impossible to say whether the instance's name is a or b, since both names are bound to the same value.
Generally speaking it should not be necessary for your code to "know the names" of particular values. Unless you are deliberately writing introspective programs, this is usually an indication that a change of approach might be beneficial.
In comp.lang.python, Fredrik Lundh once gave an excellent analogy in answer to this question:
The same way as you get the name of that cat you found on your porch: the cat (object) itself cannot tell you its name, and it doesn't really care -- so the only way to find out what it's called is to ask all your neighbours (namespaces) if it's their cat (object)
....and don't be surprised if you'll find that it's known by many names, or no name at all!

Is there an equivalent of C's "?:" ternary operator? | Python

No.

How do I convert a string to a number? | Python

For integers, use the built-in int() type constructor, e.g. int('144') == 144. Similarly, float() converts to floating-point, e.g. float('144') == 144.0.
By default, these interpret the number as decimal, so that int('0144') == 144 and int('0x144') raises ValueError. int(string, base) takes the base to convert from as a second optional argument, so int('0x144', 16) == 324. If the base is specified as 0, the number is interpreted using Python's rules: a leading '0' indicates octal, and '0x' indicates a hex number.
Do not use the built-in function eval() if all you need is to convert strings to numbers. eval() will be significantly slower and it presents a security risk: someone could pass you a Python expression that might have unwanted side effects. For example, someone could pass __import__('os').system("rm -rf $HOME") which would erase your home directory.
eval() also has the effect of interpreting numbers as Python expressions, so that e.g. eval('09') gives a syntax error because Python regards numbers starting with '0' as octal (base 8).

How can I find the methods or attributes of an object? | Python

For an instance x of a user-defined class, dir(x) returns an alphabetized list of the names containing the instance attributes and methods and attributes defined by its class.

How do I copy an object in Python? | Python

In general, try copy.copy() or copy.deepcopy() for the general case. Not all objects can be copied, but most can.
Some objects can be copied more easily. Dictionaries have a copy() method: newdict = olddict.copy()
Sequences can be copied by slicing: new_l = l[:]

How do you make a higher order function in Python? | Python

You have two choices: you can use nested scopes or you can use callable objects. For example,
suppose you wanted to define linear(a,b) which returns a function f(x) that computes the value a*x+b. Using nested scopes:
def linear(a,b):
def result(x):
return a*x + b
return result
Or using a callable object:
class linear:
def __init__(self, a, b):
self.a, self.b = a,b
def __call__(self, x):
return self.a * x + self.b
In both cases:
taxes = linear(0.3,2)
gives a callable object where taxes(10e6) == 0.3 * 10e6 + 2.
The callable object approach has the disadvantage that it is a bit slower and results in slightly longer code. However, note that a collection of callables can share their signature via inheritance:
class exponential(linear):
# __init__ inherited
def __call__(self, x):
return self.a * (x ** self.b)
Object can encapsulate state for several methods:
class counter:
value = 0
def set(self, x): self.value = x
def up(self): self.value=self.value+1
def down(self): self.value=self.value-1
count = counter()
inc, dec, reset = count.up, count.down, count.set
Here inc(), dec() and reset() act like functions which share the same counting variable.

How can I pass optional or keyword parameters from one function to another? | Python

Collect the arguments using the * and ** specifier in the function's parameter list; this gives you the positional arguments as a tuple and the keyword arguments as a dictionary. You can then pass these arguments when calling another function by using * and **:
def f(x, *tup, **kwargs):
kwargs['width']='14.3c'
g(x, *tup, **kwargs)
In the unlikely case that you care about Python versions older than 2.0, use 'apply': def f(x, *tup, **kwargs):
kwargs['width']='14.3c'
apply(g, (x,)+tup, kwargs)

How do I share global variables across modules? |

The canonical way to share information across modules within a single program is to create a special module (often called config or cfg). Just import the config module in all modules of your application; the module then becomes available as a global name. Because there is only one instance of each module, any changes made to the module object get reflected everywhere.
For example:
config.py:
x = 0 # Default value of the 'x' configuration setting
mod.py:
import config
config.x = 1
main.py:
import config
import mod
print config.x
Note that using a module is also the basis for implementing the Singleton design pattern, for the same reason.

What are the rules for local and global variables in Python? | Python

In Python, variables that are only referenced inside a function are implicitly global. If a variable is assigned a new value anywhere within the function's body, it's assumed to be a local. If a variable is ever assigned a new value inside the function, the variable is implicitly local, and you need to explicitly declare it as 'global'.
Though a bit surprising at first, a moment's consideration explains this. On one hand, requiring global for assigned variables provides a bar against unintended side-effects. On the other hand, if global was required for all global references, you'd be using global all the time. You'd have to declare as global every reference to a builtin function or to a component of an imported module. This clutter would defeat the usefulness of the global declaration for identifying side-effects.

How do you set a global variable in a function?

x = 1 # make a global
def f():
print x # try to print the global
for j in range(100):
if q>3:
x=4
Any variable assigned in a function is local to that function. unless it is specifically declared global. Since a value is bound to x as the last statement of the function body, the compiler assumes that x is local. Consequently the print x attempts to print an uninitialized local variable and will trigger a NameError.
The solution is to insert an explicit global declaration at the start of the function:
def f():
global x
print x # try to print the global
for j in range(100):
if q>3:
x=4
In this case, all references to x are interpreted as references to the x from the module namespace.

Is there a tool to help find bugs or perform static analysis? | Python

Yes.
PyChecker is a static analysis tool that finds bugs in Python source code and warns about code complexity and style.
Pylint is another tool that checks if a module satisfies a coding standard, and also makes it possible to write plug-ins to add a custom feature.

Why can't I use an assignment in an expression? | Python

Many people used to C or Perl complain that they want to use this C idiom:

while (line = readline(f)) {
...do something with line...
}
where in Python you're forced to write this:
while True:
line = f.readline() if not line:
break
...do something with line...

The reason for not allowing assignment in Python expressions is a common, hard-to-find bug in those other languages, caused by this construct:
if (x = 0) {
...error handling...
}
else {
...code that only works for nonzero x...
}
The error is a simple typo: x = 0, which assigns 0 to the variable x, was written while the comparison x == 0 is certainly what was intended.
Many alternatives have been proposed. Most are hacks that save some typing but use arbitrary or cryptic syntax or keywords, and fail the simple criterion for language change proposals: it should intuitively suggest the proper meaning to a human reader who has not yet been introduced to theconstruct.
An interesting phenomenon is that most experienced Python programmers recognize the "while True" idiom and don't seem to be missing the assignment in expression construct much; it's only newcomers who express a strong desire to add this to the language.
There's an alternative way of spelling this that seems attractive but is generally less robust than the "while True" solution:
line = f.readline() while line:
...do something with line... line = f.readline()
The problem with this is that if you change your mind about exactly how you get the next line (e.g. you
want to change it into sys.stdin.readline()) you have to remember to change two places in your program
-- the second occurrence is hidden at the bottom of the loop.
The best approach is to use iterators, making it possible to loop through objects using the for statement. For example, in the current version of Python file objects support the iterator protocol, so you can now write simply:
for line in f:
... do something with line...

What is Python? | Python

Python is an interpreted, interactive, object-oriented programming language. It incorporates modules, exceptions, dynamic typing, very high level dynamic data types, and classes. Python combines remarkable power with very clear syntax. It has interfaces to many system calls and libraries, as well as to various window systems, and is extensible in C or C++. It is also usable as an extension language for applications that need a programmable interface. Finally, Python is portable: it runs on many Unix variants, on the Mac, and on PCs under MS-DOS, Windows, Windows NT, and OS/2.

Python Interview Questions and Answers pdf free download

2. Why can't I use an assignment in an expression? 
3. Is there a tool to help find bugs or perform static analysis? 
4. How do you set a global variable in a function? 
5. What are the rules for local and global variables in Python? 
6. How do I share global variables across modules? 
7. How can I pass optional or keyword parameters from one function to another? 
8. How do you make a higher order function in Python? 
9. How do I copy an object in Python? 
10. How can I find the methods or attributes of an object? 
11.How do I convert a string to a number? 
12. How can my code discover the name of an object? 
13. Is there an equivalent of C's "?:" ternary operator? 
14.How do I convert a number to a string? 
15.How do I modify a string in place? 
16. How do I use strings to call functions/methods? 
17. Is there a scanf() or sscanf() equivalent? 
18. How do I convert between tuples and lists? 
19. What's a negative index? 
20. How do I iterate over a sequence in reverse order? 
21. How do you remove duplicates from a list? 
22. How do I create a multidimensional list? 
23. How do I apply a method to a sequence of objects? 
24. I want to do a complicated sort: can you do a Schwartzman Transform in Python? 
25. What is a class? 
26. What is a method? 
27. What is delegation? 
28. How do I call a method defined in a base class from a derived class that overrides it? 
29. How do I create static class data and static class methods? 
30. How can I overload constructors (or methods) in Python? 
31. How do I find the current module name? 
32. Where is the math.py (socket.py, regex.py, etc.) source file? 
33. How do I make a Python script executable on Unix? 
34. Why don't my signal handlers work? 
35.  How do I avoid blocking in the connect() method of a socket? 
36. Are there any interfaces to database packages in Python? 
37. How do I generate random numbers in Python? 
38. Can I create my own functions in C? 
39. Can I create my own functions in C++? 
40. How can I execute arbitrary Python statements from C? 
41. How can I evaluate an arbitrary Python expression from C? 
42. How do I extract C values from a Python object? 
43. How do I access a module written in Python from C? 
44. How do I interface to C++ objects from Python? 




How do you view virtual memory statistics in Linux? | Oracle DBA

Virtual memory statistics are available through the vmstat command.

What is OERR? | Oracle DBA

OERR is a utility provided on the UNIX platform. It can be used to retrieve more information about an error message. This utility cannot work on Windows because it needs awk command to function; however, some workarounds are available to use this utility on Windows. It is a shell script that is saved in the $ORACLE_HOME/bin directory.
The syntax of the OERR utility is given as follows:
oerr <facility> <error> In the preceding syntax, the facility is the prefix to the error number that includes ORA, PLS, and EXP and the error is the actual error number returned by Oracle.
For example, if the database returns the ORA-12544 error, the following OERR utility would be executed to gain more information:

How do you automate starting and shutting down of databases in UNIX? | Oracle DBA

The /etc/oratab file contains an entry for each instance running on the server. The last character of that entry indicates whether the instance should be started and shut down automatically. You can set the value to Y for the SID to automatically start and shutdown the specific instance.

How do you find out the number of instances that are running on a server? | Oracle DBA

You can check the /etc/oratab file on a server to find out all the Oracle instances running on that server.

Give two UNIX kernel parameters that affect installation of Oracle. | Oracle DBA

The SHMMAX & SHMMNI UNIX kernel parameters affect the installation of Oracle.

List the major steps in installation of Oracle software on UNIX in brief. | Oracle DBA

Following are the steps in installation of Oracle software on UNIX:
i. Set up disk
ii. Set up kernel parameters
iii. Run the orainst command

How can you replace a string in a file in the vi editor? | Oracle DBA

A string in a file can be replaced by using the %s/<old string>/<new string>/g command.

What privileges are available on a UNIX directory? | Oracle DBA

Following privileges are available on the UNIX directory or file:
 Read —Allows you to view and list the directory or file contents.
 Write —Allows you to create, edit, and delete files and subdirectories in the directory.
 Execute —Gives you the previous read or write permissions. It also allows you to change into the directory and execute programs or shells from the directory.

What is the difference between a soft link and a hard link? | Oracle DBA

In the UNIX operating system, a filename can point either to the data of the file or another file. A soft link or symbolic link refers to a filename which points to another file while hard link refers to a filename that point to a file, which actually contains data. Note that UNIX considers directories as files only.

How do you execute a UNIX command that will continue running even after you log out? | Oracle DBA

You can use the nohup command to execute a UNIX command that will continue running even after you log out.
Normally when you log out, or your session terminates unexpectedly, the system kills all the processes you have started. In this case, you can use the nohup command, which allows you to run the command, process, or shell script that can continue running in the background after you log out from a shell.