Showing posts with label script. Show all posts
Showing posts with label script. Show all posts

January 04, 2022

Top 20 Apache Ant Interview Questions and Answers

 

                        According to James Duncan Davidson, the ANT stands for "Another Neat Tool." Ants are tiny, but they can carry a lot of weight. As with the Apache ant's job. Apache Ant is a command-line program and Java library for automating software construction processes. In the early 2000s, it arose from the Apache Tomcat project. It was built as a replacement for Unix's Make build tool due to a number of issues with Unix's make. It is responsible for driving the processes or instructions provided in build files as targets and extension points that are interdependent. Ant's most well-known application is the creation of Java applications. Ant comes with a number of built-in jobs for compiling, assembling, testing, and running Java programs.

                        Ant can also be used to create non-Java applications, such as those written in C or C++. Ant can be used to pilot any process that can be specified in terms of targets and tasks in general. For developers looking for Apache Ant Interview questions and answers, we've compiled a list of possible Apache Ant Interview questions and answers.

Apache Tomcat Interview Questions and Answers

Ques: 1): What does the acronym ANT stand for?

Answer:

The ant, according to James Duncan Davidson, is an acronym for "Another Neat Tool." Ants are little but strong. The Apache ant's job is similar. For automating software build processes, Apache Ant is a Java library and command-line programme. It was developed in the early 2000s as part of the Apache Tomcat project. It was developed to replace Unix's Make build tool, which had a number of flaws. It controls the processes or instructions provided as targets and extension points in build files.

Apache Kafka Interview Questions and Answers

Ques. 2): What Are The Ant Concepts?

Answer:

Ant is a build tool that is based on Java. The following are the functions of a build tool:

Open: Ant is an open source project available under the Apache license. Therefore, its source code can be downloaded and modified.

Additionally, Ant uses XML build files which make its development easy.

Cross Platform: Use of XML along with Java makes Ant makes it the perfect solution for developing programs designed to run or be built across a range of different operating systems.

Extensible: New tasks are used to extend the capabilities of the build process, while build listeners are used to help hook into the build process to add extra error tracking functionality.

Integration: As Ant is extensible and open, it can be integrated with any editor or development environment easily.

Apache Tapestry Interview Questions and Answers

Ques. 3): Why Is Ant A Fantastic Construction Tool?

Answer:

Ant is a fantastic build tool for the following reasons:

  • Ant is a cross-platform, user-friendly, extensible, and scalable Java-based build tool.
  • Ant can be utilised in a small personal project as well as a large, multi-team software development effort.
  • Ant syntax is simple to grasp.
  • The XML format was utilised in the Ant syntax.
  • We only need to provide our task in the build.xml file.
  • Ant is simple to use.
  • On large Make-based software projects, eliminating the full-time make file engineer is usual.

Apache Ambari interview Questions & Answers

Ques. 4):  Explain Ant Functionality?

Answer :

Ant is an open source project available under the Apache license. Therefore, its source code can be downloaded and modified.

Additionally, Ant uses XML build files which make its development easy.

Cross Platform: Use of XML along with Java makes Ant makes it the perfect solution for developing programs designed to run or be built across a range of different operating systems.

Extensible: New tasks are used to extend the capabilities of the build process, while build listeners are used to help hook into the build process to add extra error tracking functionality.

As Ant is extensible and open, it can be integrated with any editor or development environment easily.

Apache Hive Interview Questions & Answers

 Ques. 5):  How Do You Make An Ant User Interactive?

Answer:

org.apache.tools.ant.input is the correct answer.

The user input is implemented using the InputHandler interface. The programme creates an InputRequest object, which is sent to InputHandler to perform user input. If the user input is invalid, it will be denied.

handleInput is the only method on the InputHandler interface (InputRequest request). If the input is invalid, this function throws an org.apache.tools.ant.BuildException.

Apache Spark Interview Questions & Answers

Ques. 6):  Explain with the help of Ant and a small example?

Answer: Before we begin using ANT, we must be certain of the project name, the.java files, and, most crucially, the location of the.class files.

For example, we want to use the HelloWorld programme with ant. The Java source files should be placed in the Dirhelloworld subdirectory, and the.class files should be placed in the Helloworldclassfiles subdirectory.

1. The build file by name build.xml is to be written. The script is as follows

<project name=”HelloWorld” default=”compiler” basedir=”.”>

<target name=”compiler”>

<mkdir dir = “Helloworldclassfiles”>

<javac srcdir=”Dirhelloworld” destdir=”Helloworldclassfiles”>

</target>

</project>

2. Now run the ant script to perform the compilation:

C :\> ant

Buildfile: build.xml

and see the results in the extra files and directory created:

c:\>dir Dirhelloworld

c:\>dir Helloworldclassfiles

All the .java files are in Dirhelloworld directory and all the corresponding .class are in Helloworldclassfiles directory.

Apache NiFi Interview Questions & Answers

Ques. 7):  Explain How To Use Runtime In Ant?

Answer :

There is no need to use Runtime in ant. Because ant has Runtime counterpart by name ExecTask. ExecTask is in the package org.apache.tools.ant.taskdefs. The Task is created by using the code in the customized ant Task. The code snippet is as follows:

ExecTask execTask = (ExecTask)project.createTask (“exec”);

 

Ques. 8):  How to do conditional statement in ant?

There are many ways to solve the problem.

Since target if/unless all depend on some property is defined or not, you can use condition to define different NEW properties, which

in turn depends on your ant property values. This makes your ant script very flexible, but a little hard to read.

Ant-contrib has <if> <switch> tasks for you to use.

Ant-contrib also has <propertyregex> which can make very complicate decisions.

 

Ques. 9):  How many different ways are there to set properties in a Build Ant file?

Answer:

There are six different ways to set properties:

Both the name and value attributes must be provided.

/>src.dir/>src.dir/>src.dir/>src.dir/>src.dir/>src.dir/>src.dir/

Both the name and the refid property must be provided.

Setting the filename of the property file to load as the file attribute.

Setting the url property to the url from which the properties should be loaded.

Setting the resource attribute to the property file's resource name to load.

Setting a prefix for the environment attribute.

All of the above can be combined in our build files.

However, only one should be used at any given moment.

 

Ques. 10):  How Can We Make A Jar With Ant?

Answer:

To make a jar of classes, change the target to jar. This target requires the creation of a directory in which the jar will be kept. To finish the jar, we'll need a jar tag. We have passed two attributes in this tag: the first is the name of the destination directory, and the second is the name of the base directory, which contains all of our class files. To make a jar file, we'll need a manifest. We have two attributes in the manifest tag: the first is the name of the manifest file and the second is its value.

 

Ques. 11): What Exactly Is Ivy?

Answer:

Ivy is a well-known dependency manager. IVY is primarily concerned with adaptability and simplicity.

Ivy 2.1.0 is the most recent version.

The following are some of the highlights of the 2.1.0 release:

Ivy's main feature is improved Maven2 compatibility, which includes various bug fixes and more pom functionality.

several bug fixes and improvements as stated in Jira and the release notes additional options for the Ivy Ant jobs and commandline configuration intersections and configuration groups

 

Ques. 12): What method does ant use to read properties? How do I set up my property management system?

Answer:

Ant sets properties in a sequential order, thus once something is set, later properties with the same name cannot replace the prior ones. This is the polar opposite of the Java setters. This allows us to preset all properties in one location and just overwrite the ones that are needed. Let me give you an example. You need a password for a task but don't want to disclose it with anyone on your team, even outside engineers.

Store your password in your ${user.home}/prj.properties

pswd=yourrealpassword

In your include directory master prj.properties

pswd=password

In your build-common.xml read properties files in this order

The commandline will prevail, if you use it: ant -Dpswd=newpassword

${user.home}/prj.properties (personal)

yourprojectdir/prj.properties (project team wise)

your_master_include_directory/prj.properties (universal)

[code lang=”java”]<cvsnttask password="${pswd} … />[/code]

 

Ques. 13): How can I use ant to perform a command from the command line? How can I get the outcome of a perl script running?

Answer:

Use the exec ant task to solve the problem.

Don't forget that ant is a Java programme. That is why the ant is so useful, strong, and adaptable. You must consider Unix if you want ant to get unix commands and results. In MS-Windows, it's the same. Ant just assists you in automating the procedure.

 

Ques. 14): How to copy files without extention?

Answer:

If files are in the directory:

[code lang=”xml”]<include name="a,b,c"/>[/code]

If files are in the directory or subdirectories:

[code lang=”xml”]<include name="**/a,**/b,**/c"/>[/code]

If you want all files without extension are in the directory or subdirectories:

[code lang=”xml”]<exclude name="**/*.*"/>[/code]

 

Ques. 15): How can I troubleshoot my Ant script?

Answer:

There are a variety of options.

Do an echo on the areas where you are unsure. You'll quickly figure out what the issue is. Like the classic printf() function in C or the Java System. println()

In your javascript or custom ant task, use project.log("msg"). Run Ant with -verbose or -debug to learn more about what it's doing and where it's doing it. However, you may grow tired of it quickly because it provides you with too much information.

 

Ques. 16). Why did I get such warning in ant?

Answer:

compile:

[javac] Warning: commons-logging.properties modified in the future.

[javac] Warning: dao\\DAO.java modified in the future.

[javac] Warning: dao\\DBDao2.java modified in the future.

[javac] Warning: dao\\HibernateBase.java modified in the future.

Possible causes of the system time problem include:

You altered the system's clock.

I encountered the same issue before, when I checked out files from cvs to windows and transferred them to a unix machine, I received a large number of these warnings due to a system timing issue.

You'll have the same trouble transferring files from Australia, China, or India to the United States. True, I've done it before and encountered the issue.

 

Ques. 17): How can I dynamically add pieces to an existing path?

Answer:

Yes, this is conceivable. You must, however, create a custom ant job, obtain the path, add/modify it, and use it. What I'm doing is defining a path reference to lib.classpath, then using my own task to add/modify the lib.classpath.

 

Ques. 18): How can I reorganize my jar/war/ear/zip file's directory structure? Is it necessary for me to unarchive them first?

No, you are not required to unarchive them first. To put the files into your destination jar/ear/war files, you don't need to unzip them from the archive.

To extract files from an old archive to a separate directory in your new archive, utilise zipfileset in your jar/war/ear task.

You can also use zipfileset in your jar/war/ear operation to send files from a local directory to a new archive location.

See the follow example:

[code lang=”java”] <jar destfile="${dest}/my.jar">

<zipfileset src="old_archive.zip" includes="**/*.properties" prefix="dir_in_new_archive/prop"/>

<zipfileset dir="curr_dir/abc" prefix="new_dir_in_archive/xyz"/>

</jar>[/code]

 

Ques. 19): How to exclude multi directories in copy or delete task?

Answer:

Here is an example.

[code lang=”xml”]<copy todir="${to.dir}" >

<fileset dir="${from.dir}" >

<exclude name="dirname1" />

<exclude name="dirname2" />

<exclude name="abc/whatever/dirname3" />

<exclude name="**/dirname4" />

</fileset>

</copy>[/code]

  

Ques. 20): How do I get started to use ant? Can you give me a “Hello World” ant script?

Answer:

Download the most recent version of ant from Apache; unzip it somewhere on your machine.

Install j2sdk 1.4 or above.

Set JAVA_HOME and ANT_HOME to the directory your installed them respectively.

Put %JAVA_HOME%/bin;%ANT_HOME%/bin on your Path. Use ${JAVA_HOME}/bin:${ANT_HOME}/bin on UNIX. Yes, you can use forward slash on windows.

Write a “Hello world” build.xml

[code lang=”xml”]

<project name="hello" default="say.hello" basedir="." >

<property name="hello.msg" value="Hello, World!" />

<target name="say.hello" >

<echo>${hello.msg}</echo>

</target>

</project>[/code]

* Type ant in the directory your build.xml located.




December 30, 2021

Top 20 Apache Tapestry Interview Questions and Answers

 

                Do you want to succeed in the Apache Tapestry and advance your career? Then, on this page, we will offer you with the complete set of Apache Tapestry job Interview Questions and Answers. Apache Tapestry is a Java-based open source web framework. It's a web framework that's built around components. Apache Tapestry is a framework for building extremely scalable web applications. Many top firms offer Apache Tapestry jobs in a variety of positions. In the Java programming language, there are more opportunities for experienced workers. Job hunting may be difficult and exhausting, especially if you don't know how to apply, where to look, or how to prepare for job interviews. To minimise any misunderstanding, we've framed Apache tapestry job interview questions and answers to help you prepare for your interview.

 Apache Hive Interview Questions & Answers

Ques. 1): How do I run multiple Tapestry applications in the same web application?

Answer:

Multiple Tapestry 5 apps are not supported; there is only one place to identify the application root package, therefore configuring multiple filters into multiple directories isn't an option.

Tapestry 5 did not include support for numerous Tapestry applications in the same web application (it needlessly complicated Tapestry 4). Given how disjointed Tapestry 5 pages are, there doesn't appear to be a benefit to doing so... and, if it were possible, there would be a considerable drawback in terms of memory use.

You can run Tapestry 4 and Tapestry 5 apps side by side (the package names are different for this reason), but they have no knowledge of each other and are unable to interact directly. This is just like the way you could have a single WAR with multiple servlets; the different applications can only communicate via URLs, or shared state in the HttpSession.

 Apache Ambari interview Questions & Answers

Ques. 2): Tapestry focuses on the wrong field in my form, how do I fix that?

Answer:

Tapestry usually determines which field in your form should receive initial emphasis by giving a FieldFocusPriority to each field as it renders, which translates to the following logic:

There is an error in the first field.

Alternatively, the first mandatory field

Alternatively, the first field

Due to a variety of reasons beyond Tapestry's control, its choices may not always be exactly what you desire, necessitating the use of an override. The data is kept track of in the JavaScriptSupport environment. It's simply a matter of injecting the component to get its client id, then notifying JavaScriptSupport of your override.

Here's an example

 <t:textfield t:id="email" t:mixins="OverrideFieldFocus" .../>

The OverrideFieldFocus mixin forces the email field to be the focus field, regardless.

 Apache NiFi Interview Questions & Answers

Ques. 3): Is Tapestry A Jsp Tag Library?

Answer :

Tapestry is not a JSP tag library; it is based on the servlet API but does not make use of JSPs. It has its own rendering engine and HTML template format. Tapestry now offers a simple JSP tag library in release 3.0, allowing JSP pages to link to Tapestry pages.

Apache Spark Interview Questions & Answers

Ques. 4): I Have A Form With A Submit Button. On The Form And The Submit Button Are Two Separate Listeners. Which Is Invoked First?

Answer :

While the shape encounters your button at some time throughout the rewind, the button's listener must be called. The form's submitListener must be called after the shape has completed its rewind, therefore different listeners were called in either scenario. Note that this could mean that the listener for a button can be called before the form has'submitted' all of its values; it all depends on where your input fields are in relation to your button.

 

Ques. 5): Is There A Wysiwyg Editor For Tapestry, Or An Ide Plugin?

Answer :

Tapestry currently lacks a WYSIWYG editor; nonetheless, the nature of Tapestry allows existing editors to function reasonably well (Tapestry additions to the HTML markup are virtually invisible to a WYSIWYG editor). Spindle is a Tapestry plugin for the Eclipse IDE, which is free and open-source. Tapestry apps, pages, and components may now be created using wizards and editors.

 

Ques. 6): How Is The Performance Of Tapestry?

Answer :

Other testing (recorded in the Tapestry discussion boards) coincides with my own testing, which was published in the September 2001 issue of the Java Report: Although plain JSPs have a minor advantage in demo applications, performance curves for equal Tapestry and JSP applications with a database or application server backend are identical. Consider the performance of your Java developers rather than the performance of Tapestry.

 

Ques. 7): What’s The Lifecycle Of A Form Submit?

Answer :

Events will trigger in the following order:

initialize()

pageBeginRender()

formListenerMethod()

pageBeginRender()

The form "rewind" cycle is simply a render cycle with the output buffered and scraped instead of being written to the servlet output stream. The second pageBeginRender() is called while the page is being rendered. To distinguish between these two render cycles, use requestCycle.isRewinding().

 

Ques. 8): Does Tapestry Work With Other Other Application Servers Besides Jboss?

Answer :

Yes, of course! For the turn-key demonstrations, JBoss is free and convenient. In less than a minute, you can download Tapestry and JBoss and have a real J2EE application running! JBoss configuration scripts are specific to a specific release of JBoss, which must be 3.0.6. Tapestry apps, on the other hand, are completely container agnostic... Tapestry is unconcerned with the servlet container it's in, and it doesn't even require an EJB container.

 

Ques. 9): Can I Use The Same Component Multiple Times In One Template?

Answer:

No – but you can copy the definition of a component pretty easily.

<component id=”valueInsert” type=”Insert” >

 <binding name=”value” expression=”getValueAt( rowIndex, columnIndex )” />

 </component>

<component id=”valueInsert1″ copy-of=”valueInsert”/>

 <component id=”valueInsert2″ copy-of=”valueInsert”/>

 <component id=”valueInsert3″ copy-of=”valueInsert”/>

 <component id=”valueInsert4″ copy-of=”valueInsert”/>

 

Ques. 10): Why is @script required in Apache Tapestry?

Answer:

The script framework is a useful tool for grouping scripts into components. It delivers the benefits of components to scripts. It may now be utilised as a component without having to bother about renaming field names or rewiring the fields and scripts. All you have to do now is declare the component and you're ready to go. It is true that another layer of abstraction must be acquired, but once learned, it is extremely powerful. And, to tell you the truth, there isn't much to it.

The script framework is required since form element/field names are produced automatically by the framework. As a result, you write your script in XML, assigning these names to variables, and relying on the framework to deliver the correct names at runtime. Further, you can request that the framework include extra objects that will aid in the creation of your script.

 

Ques. 11): When a form is submitted, why does Tapestry send a redirect?

Answer:

This is a variant of the Post/Redirect/Get strategy. It ensures that if a user resubmits the resultant page after an operation that alters server-side state, such as a form submission, the operation is not repeated; instead, only the results of the operation, reflecting the updated server-side state, are re-rendered.

This has the unwelcome consequence of requiring any data required to produce the answer to persist between the event request (the form submission) and the render request; this frequently necessitates the use of @Persist annotations on fields.

 

Ques. 12): When I utilise an HTML object like &nbsp; in my template, why do I get a SAXParseException?

Answer:

Tapestry reads your templates using a regular SAX parser. This means that your templates must be well-formed, with balanced open and close tags, quoted attribute values, and defined entities. The simplest method to do this is to include a DOCTYPE at the top of your template:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"

   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

Part of the DOCTYPE is the declaration of entities such as &nbsp;.

You can also use the numeric version: &#160; This is the exact same character and will render in the browser identically. When no doctype is present, Tapestry adds an XHTML doctype; this ensures that common HTML entities behave properly.

 

Ques. 13): When I submit a form, I get an error message that says "Tapestry is undefined." Why?

Answer:

This client-side mistake is obvious, yet it can be difficult to resolve. It implies your browser was unable to correctly load the tapestry.js file. Why, exactly, is the question? It could be for a variety of causes, some of which are listed below:

Check to see if 'tapestry.js' is present in the head section of your HTML page.

Tapestry generates a single URL to get all the JS files if the tapestry.combine-scripts configuration parameter is set to true. This can sometimes result in long URLs that browsers are unable to get. Set the sign to false and see what happens.

If you use jQuery in conjunction with Tapestry's prototype, the '$' selection used by both will clash. Put jQuery on top of the stack and enable the jQuery.noConflict mode in this scenario.

Also, if you've added a custom or third-party JS library to the stack and it's causing the JavaScript parsing to fail, look at the JavaScript syntax in that library.

If you used a programme to compress your JavaScript libraries, it's possible that you'll get JavaScript syntax issues, so make sure it works with all of the JavaScript files unpacked.

 

Ques. 14): Do I have to specify both id and t:id for Zone components?

Answer:

The Zone component's examples (in the Component Reference) always give both id and t:id, which is definitely a good thing.

In general, the client-side id (the id attribute) will be the same as the Tapestry component id if you don't define it (t:id).

There are, however, numerous exceptions to this rule. It's possible that the Zone is rendering inside a Loop (in which case, each rendering will have a unique client side id). A random unique id is added into the id if the Zone is rendering as part of a partial page render. Tapestry component ids in nested components can potentially clash in other situations.

 

Ques. 15): When rendering an empty Zone, why do I get the exception "The produced content did not include any components that allow for the positioning of the concealed form field's element."?

Answer:

Tapestry must write a hidden input element with information needed when the form is submitted as part of its form processing. Because the content of a Zone can be altered or erased, a hidden field separate from the rest of the enclosing form is established solely for the Zone.

At the same time, Tapestry wants to position the <input> field in a valid location, and HTML defines some constraints for that; an input field must appear inside a <p> or <div> element. If your zone is initially empty, there's no place to put the hidden element, and Tapestry will complain.

The solution is simple: just add a <div> element to the body of the zone. This ensures that there's a place for the hidden input field.  An empty <div> element (even one containing a hidden form field) will not affect page layout.

 

Ques. 16): Why is it necessary for me to provide an interface for my services? Why can't I simply use the class?

Answer:

To begin with, you can do just this, but you will lose some of the functionality provided by Tapestry's IoC container.

Tapestry will be able to provide functionality for your service around the core service implementation as a result of the split. This is accomplished by using proxies, which are Java classes that implement the service interface. The proxy's methods will eventually call the methods of your service implementation.

One of the most important functions of proxies is to encapsulate the life cycle of a service: most services are singletons that are built just once. Just in time refers to the moment you call a method. What's going on is that the life cycle proxy (the object that gets injected into pages, components or other service implementations) checks on each method invocation to see if the actual service exists yet. If not, it instantiates and configures it (using proper locking to ensure thread safety), then delegates the method invocation to the service.

If you bind a service class (not a service interface and class), then the service is fully instantiated the first time it is injected, rather than at that first method invocation. Further, you can't use decorations or method advice on such a service. The life cycle proxy (the object injected into pages, components, and other service implementations) examines each method invocation to determine if the actual service has been created yet. If it isn't already instantiated and configured (with suitable locking to ensure thread safety), it delegated method invocation to the service.

When you bind a service class (rather than a service interface and class), the service is fully instantiated the first time it is injected, rather than when the first method is invoked. Furthermore, such a service does not allow for the use of decorations or technique suggestions.

The final reason for the service interface / implementation split is to nudge you towards always coding to an interface, which has manifest benefits for code structure, robustness, and testability.

 

Ques. 17): How do I make my service startup with the rest of the application, rather than lazily?

Answer:

Tapestry services are designed to be lazy; they are only fully realized when needed: when the first method on the service interface is invoked.

Sometimes a service does extra work that is desirable at application startup: examples may be registering message handlers with a JMS implementation, or setting up indexing. Since the service's constructor (or @PostInjection methods) are not invoked until the service is realized.

The solution is the @EagerLoad annotation; service implementation classes marked with this annotation are loaded when the Registry is first startup, rather than lazily.

 

Ques. 18): How can I dynamically add new components to an existing page?

Answer:

You don't, to put it succinctly. The long answer is that you don't have to in order to achieve the desired behaviour.

High scalability is one of Tapestry's core values; it can be expressed in a variety of ways, reflecting scalability concerns both within a single server and across a cluster of servers.

Although you code Tapestry pages and components as if they were ordinary POJOs (Plain Old Java Objects — Tapestry doesn't require you to extend any base classes or implement any special interfaces), they behave more like a traditional servlet when deployed by Tapestry: a single instance of each page serves requests from multiple threads. In the background,

 

Ques. 19): What this means is that any incoming request must be handled by a single page instance. Therefore, Tapestry enforces the concept of static structure, dynamic behavior.

Answer:

 Beyond simple conditionals and loops, Tapestry offers a variety of options for varying what content is presented. When rendering a page, you can "drag in" components from other pages (other FAQs will expand on this concept). The idea is that, while the structure of a Tapestry page is quite strict, the order in which the page's components render does not have to be top to bottom.

 

Ques. 20): Why do my images and stylesheets end up with a weird URLs like /assets/meta/zeea17aee26bc0cae/layout/layout.css?

Answer:

The servlet container isn't used by Tapestry to serve static assets (images, stylesheets, flash movies, etc.). Tapestry, on the other hand, handles the requests and streams assets to the browser.

The content of the assets will be compressed using GZIP (if the client supports compression, and the content is compressible). Tapestry will also add an expires header to the content in the future. This means the browser will not ask for the file again, resulting in a significant reduction in network traffic.

The strange hex string is a fingerprint; it's a hash code calculated from the asset's real content. If the asset changes, a new fingerprint will be created, as well as a new path and (immutable) resource. This approach, combined with a far-future expires header also provided by Tapestry, ensures that clients aggressively cache assets as they navigate your site, or even between visits.



February 11, 2021

Top 20 Linux Interview Questions and Answers

 
Ques. 1): How can Linux be differentiated from other Operating Systems?
Answer: 
Linux is somewhat like other operating systems you might have used before, such as OS X, iOS or the Windows. Like other operating systems, Linux too has a graphical user interface. The types of software just like other operating systems have, such as the word processing applications.
 But Linux is different from other operating systems in many ways. First and foremost, Linux is open source software. The code used to create the OS is always free and available to the public to view, contribute and edit. Secondly, although the core pieces of the Linux OS are generally common, there are quite many distributions of Linux, which include different software options, which implies Linux is incredibly customizable. Linux users can also choose core components, such as the system displays graphics and other UI components.

 
Ques. 2): What is the basic difference between UNIX and Linux Operating System.
Answer: 
Linux Operating System is Free and Open Source Software, the kernel of which is created by Linus Torvalds and community. Well you cannot say UNIX Operating System doesn’t comes under the category of Free and Open Source Software, BSD, is a variant of UNIX which comes under the category of FOSS. Moreover Big companies like Apple, IBM, Oracle, HP, etc. are contributing to UNIX Kernel.
 

Ques. 3): What Is Shell Script?
Answer: 
A shell script, as the name suggests, is a script written for the shell. Script here means a programming language used to control the application. The shell script allows different commands entered in the shell to be executed. Shell script is easy to debug, quicker as compared to writing big programs. However, the execution speed is slow because it launches a new process for every shell command executed. Examples of commands are cp, cn, cd.
 

Ques. 4): What Are Pipes?
Answer: 
A pipe is a chain of processes so that output of one process (stdout) is fed an input (stdin) to another. UNIX shell has a special syntax for creation of pipelines. The commands are written in sequence separated by |. Different filters are used for Pipes like AWK, GREP.
e.g. sort file | lpr ( sort the file and send it to printer)
 

Ques. 5): What Stateless Linux Server? What Feature It Offers?
Answer: 
A stateless Linux server is a centralized server in which no state exists on the single workstations. There may be scenarios when a state of a partilcuar system is meaningful (A snap shot is taken then) and the user wants all the other machines to be in that state. This is where the stateless Linux server comes into picture.

Features:
·       It stores the prototypes of every machine.
·       It stores snapshots taken for those systems.
·       It stores home directories for those system.

Uses LDAP containing information of all systems to assist in finding out which snapshot (of state) should be running on which system.
 

Ques. 6): What Is Bash Shell?
Answer: 
Bash is a free shell for UNIX. It is the default shell for most UNIX systems. It has a combination of the C and Korn shell features. Bash shell is not portable. any Bash-specific feature will not function on a system using the Bourne shell or one of its replacements, unless bash is installed as a secondary shell and the script begins with #!/bin/bash. It supports regular and expressions. When bash script starts, it executes commands of different scripts.
 

Ques. 7): What Is A Zombie?
Answer: 
Zombie is a process state when the child dies before the parent process. In this case the structural information of the process is still in the process table. Since this process is not alive, it cannot react to signals. Zombie state can finish when the parent dies. All resources of the zombie state process are cleared by the kernel.
 

Ques. 8): Explain Each System Calls Used For Process Management In Linux.
Answer: 
System calls used for Process management:
·       Fork () :- Used to create a new process
·       Exec() :- Execute a new program
·       Wait():- wait until the process finishes execution
·       Exit():- Exit from the process
·       Getpid():- get the unique process id of the process
·       Getppid():- get the parent process unique id
·       Nice():- to bias the existing property of process
 

Ques. 9): How Do You Kill A Process?
Answer: 
kill -9 8 (process_id 8) or kill -9 %7 (job number 7)
kill -9 -1 (Kill all processes you can kill.)
killall - kill processes by name most (useful - killall java)
 

Ques. 10): What Is A Filesystem?
Answer: 
Sum of all directories called file system. A file system is the primary means of file storage in UNIX. File systems are made of inodes and superblocks.
 

Ques. 11): What Are Two Subtle Differences In Using The More And The Pg Commands?
Answer: 
With the more command you display another screenful by pressing the spacebar, with pg you press the return key. The more command returns you automatically to the UNIX shell when completed, while pg waits until you press return.
 

Ques. 12): We Saw the Mention On The Linux Bios Website About One Million Devices Shipped With Linux Bios. Could You Tell Us More About These Devices?
Answer: 
Yes, these are internet terminals that were built in India, based on the [x86 system-on-chip] STPC chip, I am told; also, there evidently is a Turkish-built digital TV that runs Linux BIOS. I have also heard that there are routers and many other embedded devices running Linux BIOS. I think at this point that 1 million is a low number. I am in contact with other set-top box vendors that are talking about numbers in the lOs of millions for their products. These numbers actually make the OLPC numbers seem small, which is in it amazing.
 

Ques. 13): What's Your Goal For Your Talk At Fosdem?
Answer: 
I’d like to communicate the basic ideas — that Linux is a good BIOS, and why; why Linux BIOS is built the way it is; where we are going; and how people can help. Most importantly, why it all matters — and it really matters a lot. We’re on the verge of losing control of the systems we buy, and we need to make a conscious effort, as a community, to ensure this loss of control does not happen. That effort will not be without some sacrifice, but if we are to maintain our ability to use and program our machines, and have fun with them, we have to act now. Because, if the computing business stops being fun, what’s the point$
 

Ques. 14): What Command Would You Use To Create An Empty File Without Opening It To Edit It?
Answer: 
You use the touch command to create an empty file without needing to open it. Answers a and e point to invalid commands, though either of these might actually be aliased to point to a real command. Answers b and c utilize editors, and so do not satisfy the requirements of the question. actually touch is used to change the timestamps of a file if its exits, otherwise a new file with current timestamps will be created.
 

Ques. 15): What Do You Type To Stop A Hung Process That Resists The Standard Attempts To Shut It Down?
Answer: 
The kill command by itself tries to allow a process to exit cleanly. You type kill -9 PID, on the other hand, to abruptly stop a process that will not quit by any other means. Also, pressing CtrI+C works for many programs. Answers b and d are only valid in some contexts, and even in those contexts will not work on a hung process.
 

Ques. 16): What Are The Techniques That You Use To Handle The Collisions In Hash Tables?
Answer: 
We can use two major techniques to handle the collisions. They are open addressing and separate chaining. In open addressing, data items that hash to a full array cell are placed in another cell in the array. In separate chaining, each array element consists of a linked list. All data items hashing to a given array index are inserted in that list.
 

Ques. 17): Why You Shouldn't Use The Root Login?
Answer: 
The root login does not restrict you in any way. When you log in as root, you become the system. The root login is also sometimes called the super user login. With one simple command, issued either on purpose or by accident, you can destroy your entire Linux installation. For this reason, use the root login only when necessary. Avoid experimenting with commands when you do log in as root.
 

Ques. 18): What Can You Type At A Command Line To Determine Which Shell You Are Using?
Answer: 
echo $SHELL-The name and path to the shell you are using is saved to the SHELL environment variable. You can then use the echo command to print out the value of any variable by preceding the variable’s name with $. Therefore, typing echo $SHELL will display the name of your shell.
 

Ques. 19): Is Linux Operating system Virus free?
Answer: 
No! There doesn’t exist any Operating System on this earth that is virus free. However Linux is known to have least number of Viruses, till date, yes even less than UNIX OS. Linux has had about 60-100 viruses listed till date. None of them actively spreading nowadays. A rough estimate of UNIX viruses is between 85 -120 viruses reported till date.
 

Ques. 20): How do you change permissions under Linux?
Answer: 
Assuming you are the system administrator or the owner of a file or directory, you can grant permission using the chmod command. Use + symbol to add permission or – symbol to deny permission, along with any of the following letters: u (user), g (group), o (others), a (all), r (read), w (write) and x (execute). For example, the command chmod go+rw FILE1.TXT grants read and write access to the file FILE1.TXT, which is assigned to groups and others.