You are on page 1of 50


Lovely Professional University


Submitted To Mr. Praveen Kumar

Submitted By Nitesh Daga Reg 11103 !" Ro##$ K1R%"B3& Se'$ K1R%"


Q1. a) Is there a way to increase the priority of a program to make it run Explain in detail. Ans.


The priority or importance of a job is defined by it's nice number. A program with a high nice number is friendly to other programs, other users and the system; it is not an important job. The lower the nice number, the more important a job is and the more resources it will take without sharing them. Making a job nicer by increasing its nice number is only useful for processes that use a lot of C ! time "compilers, math applications and the like#. rocesses that always use a lot of $%& time are automatically rewarded by the system and gi'en a higher priority "a lower nice number#, for e(ample keyboard input always gets highest priority on a system. )efining the priority of a program is done with the nice command. Most systems also pro'ide the *+) renice command, which allows you to change the niceness of a running command, a way to increase the priority of a program to make it run faster. $t is ,&T a good idea to nice or renice an interacti'e program or a job running in the foreground. !se of these commands is usually a task for the system administrator.

Changes the priority of an existing command. You may use the options -u to change the priorities of all processes for a particular user name and -g to change priorities for all processes of a particular group. The default is to change via the process id number.

renice +20 2222

This would change the priority of process 2222 to +20 (minimum priority .


) !ompare "#$%E and &'E. (rite key attri utes of an open source software. Ans.
!"# is the most outstanding$ offering a true consistent des%top$ flexible$ with an extremely elegant architecture$ using components (li%e &icrosoft's C(& and C(&+ $ intercommunication$ performance etc. )t is constantly evolving$ and is developed in C++. )ts applications have an familiar integrated loo%* and*feel$ is light and mature. +eople say that !"# , is shiny diamond$ ready to be used$ and is my first suggestion to you. -.(&# also brings the integrated des%top proposal$ but it is far from the maturity and ease*of*use of !"#. /rom the other side$ is very well supported by the comunity$ and good improvements are appearing.

!"# and -nome are complete des%top environments that consist of a large number of tightly integrated yet still separate pieces of software. -nome uses a window manager called metacity$ !"# uses %win. 0oth these des%tops can be used with any other window manager if you do not li%e the default choice. 1inux is li%e 1ego. You can build your own des%top environment. 0oth !"# and -nome are 2ust big pac%ages with software aimed to loo% and feel the same way$ wor% well together and generally give you a nice experience. )f you disli%e a component$ then replace it with something else. )t's that simple. 3pplication that are 4made for gnome4 or 4made for %de4 can be used with any des%top. This only means that that the program use a set of library functions found in their underlying gnome*libs or %delibs. You do not need to use the actual des%tops to use the applications$ software made for !"# and -nome can be used with any window manager 5 des%top as long as you got the proper libraries installed. There is no reason to use only applications made for the des%top you prefer$ the 4best software4 for one tas% is made for !"#$ the best for another tas% is made for -nome. 6se the best from both worlds. 0oth !"# and -nome can be customi7ed to behave exactly the way you want. 8hat des%top you prefer is your own choice and preference. 8hen in doubt$ try to learn both. (r experiment with other des%tops. 9emember$ :nix applications are not loc%ed to the des%top they are made for$ -nome applications can be used in !"# and vice versa. There is no 4best des%top4$ but there is a des%top that's best for you. )t's a matter of preference$ and hardware.


)enefits of *sing $pen +ource +oftware

o o o o o o

Reliability Stability Auditability ost !le"ibility and !reedom Support and Accountability

(pen ;ource's proponents often claim that it offers significant benefits when compared to typical commercial products. Commercial products typically favour visible features (giving mar%eting advantage over harder*to measure <ualities such as stability$ security and similar less glamorous attributes. 3s a shorthand$ we shall describe this phenomenon as quality vs features. (pen ;ource ;oftware developers are evidently motivated by many factors but favouring features over <uality is not noticeable amongst them. /or many developers$ peer review and acclaim is important$ so it's li%ely that they will prefer to build software that is admired by their peers. =ighly pri7ed factors are clean design$ reliability and maintainability$ with adherence to standards and shared community values preeminent. 4The (pen ;ource community attracts very bright$ very motivated developers$ who although fre<uently unpaid$ are often very disciplined. )n addition$ these developers are not part of corporate cultures where the best route to large salaries is to move into management$ hence some (pen ;ource developers are amongst the most experienced in the industry. )n addition all users of (pen ;ource products have access to the source code and debugging tools$ and hence often suggest both bug fixes and enhancements as actual changes to the source code. Conse<uently the <uality of software produced by the (pen ;ource community sometimes exceeds that produced by purely commercial organisations.4 4... This psychological effect is really important in explaining why so many pro2ects are started out of the blue$ with seemingly no reward. 3lthough it may seem surprising at first view$ it is not that rare if we put it in context. /or instance$ most of the history of information science and programming$ in fact$ started this way in academic circles. 3nd still many non*applied sciences advance than%s to the wor% of scientists who feel more rewarded by research in itself than by money. 3lthough this effect of self* reward is perhaps not so common in the world of proprietary software development$ it is today a strong force in the open source community. 3nd what is even more important$ it seems clear that it has an extremely good impact on developer's productivity$ an interesting effect in a discipline where differences in productivity from person to person are often a matter of orders of magnitude.4 There is abundant anecdotal evidence for truth in those claims but reliable and comparable statistical measures are not available to our %nowledge. There are a number of principal reasons adduced for this>

Authors are moti#ated by pride and peer recognition rather than a de#elopment plan supplied by the marketing department$ %ost want to use the software themsel#es and they prefer robustnesss before adding features$


Authors are likely to consider it a &win' if they can reduce the comple"ity and impro#e the maintainability of software$ (his rarely comes high on the product plan for commercial software$ )here se#eral authors work in parallel* the best+of+crop solution can be chosen in place of the only solution ,as would be typical for a commercial product-$ )here source code is freely published and widely distributed* the users of the product will often disco#er and correct defects themsel#es$ .f no commercial entity benefits from that work* the moti#ation to do so for the common good is much higher$

&any of the <ualities that are claimed for (pen ;ource ;oftware are exactly those that are wanted by those who have to use or deploy software$ yet run almost directly counter to the commercial needs of typical software development businesses$ where a continuous revenue stream (usually through the mechanism of upgrades or high*priced support is needed. addresses some of the economic drivers in more depth and provides models which can reverse this apparent conflict of interests. )n the following paragraphs we loo% at the claims$ outline why they are considered benefits and describe the ways that the (pen ;ource process provides substance to the claims.

,elia ility
9eliability is a loose term. 0roadly$ we can ta%e it to mean the absence of defects which cause incorrect operation$ data loss or sudden failures$ perhaps what many people would mean when they use the term ?bug'. ;trictly$ a bug would also mean failure to meet the specification$ but since most (pen ;ource pro2ects dispense with the concept of anything easily recognisable as a formal specification$ it's hard to point to that as good way of defining what is a bug and what is a feature. "etermining what constitutes a bug is usually by agreement amongst the developers and users of the software (an overlapping community in many cases . (bvious failure to perform is easily recognised as a bug$ as is failure to conform to appropriate published standards. ;ecurity related failings (exploits or vulnerabilities are clearly bugs too. #ach of these %inds of bugs is usually addressed with speedy fixes wherever possible and (pen ;ource advocates will claim very rapid time*to*fix characteristics for software. ;evere defects tend to be fixed within hours of their being detected$ a process wich is undoubtedly assisted by the availability of the source code. 3ble developers who discover a bug will commonly also fix it and then report it to the maintainers as well as issuing an updated version of the software on their own authority. 6sers of the software can choose whether to use the unofficial fix or wait for an ?official' version. 0y ?official' we mean a release blessed by the pro2ect team itself or a trusted authority such as one of the main distributors of (pen ;ource pac%ages. This mechanism clearly wor%s very well in practice. The pattern with closed*source software is typically that a defect report needs to be filed and then there will be a delay before the vendor determines when or whether to issue an updated release. 6sers of the software are much more at the mercy of the vendor's internal processes than with the (pen ;ource arrangement and the personal experience of the authors is that it can be extremely frustrating to move from the (pen ;ource to the closed model. 4The mar%et greatly values robustness$ and the (pen ;ource model$ particularly as practiced by 1inux$ encourages a large mar%et of early adopters (compared to the si7e of the early mar%et for commercial products who actively help debug the software. Conse<uently much (pen ;ource software becomes


highly robust at a surprisingly early stage of its development$ and mature (pen ;ource products are setting new industry standards for bulletproofness.4

+ta ility
)n a business environment software is mostly a necessary evil$ a tool to do a 2ob. 6nless the 2ob changes or more efficient processes are discovered then there is rarely pressure or need to alter the software that is being used to assist the tas%. This is more or less directly counter to what motivates software vendors who are in the unenviable position of supplying a commodity that does not wear out or age much. The vendors need a stable revenue stream to be able to %eep their business going whilst their customers have not the slightest desire to change or upgrade any product that is wor%ing well enough to suit their needs. )f a software supplier can establish a virtual monopoly and then force upgrades onto its audience (as has been the history of the software industry since the mid @AB0s then the profits can be very high. ;oftware vendors can apply a number of tactics to persuade their customers to upgrade more or less willingly. Typical tactics include moving to allegedly new and improved file formats (which re<uire the new and improved software to read them or to withdraw support and bug fixes for older versions after a short period. The problem for users of the software is that they rarely have much control over that process and are left isolated if they choose to remain with older versions that they consider to be acceptable. This has cost and control implications for the business. (pen ;ource ;oftware is not a panacea in the world of ever*changing software$ but the worst effects of vendor*push can be mitigated. The way that (pen ;ource products tend to conform closely to standards efforts has an inertial effect$ since standards change but slowly and interchange formats are often particularly stable. 3s a result$ incompatible file formats can be less of an issue. )f they are standards* based then they typically aren't an issue at all$ and if they are formats uni<ue to the software product C proprietary formats in a sense * then they cannot be undocumented since the source code that uses them is itself published. )n practice the trac% record of (pen ;ource pro2ects is usually goodD when incompatible formats are used it is commonplace for a +erl or similar converter program to be shipped with them which will upgrade data to the new format. )n the real world$ no business is static and software changes to meet new re<uirements. 3 choice to use (pen ;ource software can provide a counter to the pressures to upgrade for the vendor's commercial purposes but cannot shelter every user from any change. =aving access to the source code can allow a business to choose to support itself on an old version where necessary and we belive that in general it gives more options and choice to the users. .onetheless$ some upgrading and maintenance effort will always be needed. +utting the choice in the hands of the users rather than the suppliers is hard to criticise.

Audita ility
3 rarely*understood benefit of (pen ;ource software (any software where the source code is published is its auditability. Closed*source software forces its users to trust the vendor when claims are made for <ualities such as security$ freedom from bac%doors$ adherence to standards and flexibility in the face of future changes. )f the source code is not available those claims remain simply claims. 0y publishing the source code$ authors ma%e it possible for users of the software to have confidence that there is a basis for those claims. 8hether this ta%es the form of an cursory and informal inspection or

more rigorous auditing$ what's clear is that without access to the source$ third party inspection is impossible. 3t present the industry does not insist on third party inspection or certification$ but it's possible that as open source models become more popular then expectations of audits will rise. 3n often*<uoted example of this in real life is the )nterbase product from 0orland ()nprise . This C#9T advisory notice carries the following summary> 4)nterbase is an open source database pac%age that had previously been distributed in a closed source fashion by 0orland5)nprise. 0oth the open and closed source versions of the )nterbase server contain a compiled*in bac% door account with a %nown password.4 The bac% door account was discovered when 0orland released the source code of the software for public use. (ne is left wondering how many other software pro2ects contain similar features C and it's not possible to %now if the source code remains closed. 48e can easily see that open source software has a distinct advantage over proprietary systems$ since it is possible to easily and <uic%ly identify potential security problems and correct them. Eolunteers have created mailing lists and auditing groups to chec% for security issues in several important networ%ing programs and operating system %ernels$ and now the security of open source software can be considered e<ual or better than that of des%top operating systems. )t has also already been shown that the traditional approach of security through obscurity leaves too many open holes. #ven now that the )nternet reaches 2ust a part of the world$ viruses and crac%er attac%s can pose a significant privacy and monetary threat. This threat is one of the causes of the adoption of open source software by many networ%*oriented software systems.4 (ne example of third*party auditing is the 1inux ;ecurity 3udit pro2ect which performs by*eye auditing of open source software pac%ages and maintains a database of results. 3t present company auditors are not %nown to be as%ing about the suitability and auditability of %ey software pac%ages which support crucial business processes. 3 plausible reason is that they simply don't %now that it can be done. That situation is not guaranteed to continue.

&ost current (pen ;ource pro2ects are also available free of royalties and fees$ leading to the confusion around the commonly used term ?free software'. 9egrettably the #nglish language does not have separate concepts for free*of*charge and free as in unconstrainedD other languages are better e<uipped to describe the difference between ?freedom' and ?free of charge' (libre vs. gratis . +roponents of free software licences tend to emphasise liberty over cost although in practice the main open source pro2ects are free in both senses of the word. /rom a business perspective the purchase cost of software is only one factorD total cost of ownership (TC( is what really matters. (ther things being e<ual$ the solution with lowest TC( is usually the most desirable one. 3rguments in favour of low TC( for open source software include>

Possibly /ero purchase price Potentially no need to account for copies in use* reducing administrati#e o#erhead


laimed reduced need for regular upgrades ,gi#ing lower0nil upgrade fees* lower management costslaimed longer uptimes and reduced need for e"pensi#e systems administrators 1ear+/ero #ulnerability to #iruses eliminating need for #irus checking* data loss and downtime laimed lower #ulnerability to security breaches and hack attacks reducing systems administration load laimed ability to prolong life of older hardware while retaining performance

;ome longer*term claims are more difficult to substantiate yet they need to be ta%en into account>

2etter adherence to standards permits competition in the market* reducing #endor lock+in and conse3uent monopoly pricing A#ailability of source code pro#ides greater continuity and security against
o o

!inancial collapse of #endors of key products 4endors choosing to withdraw support for unprofitable products

Protection against being re3uired to fit your .( strategy to the cash needs of your software supplier

6nfortunately in this area there are numerous claims and counter claims. 9eliable TC( information is practically unobtainable$ although the case studies which form part of this guide provide a large amount of circumstantial evidence in favour of the argument. &ost businesses will have to chose the argument on on its merits and choose to bac% the use of (pen ;ource software where it seems most li%ely to provide either a clear cost win$ or valuable leverage over entrenched suppliers.

-lexi ility and -reedom

)n a business context$ software flexibility is about being able to choose solutions suitable for the needs of the users. &any commercial software products will claim flexibility as a built*in feature and some will undoubtedly be correct. (ur view is that that flexibility should really mean business flexibility$ so that as re<uirements in the business change$ solutions should not be unreasonably constrained by software. )n particular$ we view this as being especially important in the area of infrastructure components C the architecture of the )T solution rather than any one pac%age. To obtain flexibility at the architectural level$ experience shows that it is often best to pic% tried and trusted standards for interwor%ing. )f that is done$ then best*of breed solutions can be selected for particular components within the architecture. +rovided that the solutions can interwor% suitably$ the business should be able to avoid loc%*in to a particular supplier and over*dependency. This is notoriously hard to manage$ re<uiring a real act of will from management. 8hat happens most often is that a vendor will ma%e a ?feature sale'$ emphasising something which cannot be done through the standard infrastructure. )f they succeed then the business can become dependent on that particular solution and unable to choose alternatives at a later date. 3ny astute vendor will attempt to do this$ only vigilant managers can avoid the loc%*in that follows. +roprietary data formats are a particularly good tool for vendors to use. )f they can establish a bridgehead$ their competition will not only have to provide


competing functionality$ but also data conversion tools from a (typically undocumented or even protected format. (pen ;ource pro2ects have very little motivation to attempt this %ind of loc%*in strategy. ;ince there is no commercial benefit to be had$ adherence to de*2ure or de*facto standards (where they exist is typically high. 8here standards for interwor%ing do not exist$ the fact that the source code is published means that proprietary data formats can't be used to manipulate loc%*in. This at least partly explains the relative success of (pen ;ource software in infrastructure areas. &any vendors have tried to create web servers to compete with 3pache$ but because the networ% protocol used between browsers and the web server is well specified they have had to compete on <uality or features rather than through more insidious tactics. 3ny vendor that controlled the lions' share of the browser and the server mar%et would feel strongly tempted to exclude competitors by proprietary extensions to the HTTP protocol if they thought they could get away with it. .o single vendor has yet managed to control both ends of this e<uation to a great enough degree. 4(pen ;ource software tends to be free of dependency on related products. +urchasers often perceive that the product wor%s best with other products from the same manufacturer. (pen ;ource software offers its users greater freedom to purchase other products$ avoiding loc%*in to particular manufacturers.4 0usiness users are most li%ely to obtain long*term flexibility through the careful choice of standards for interwor%ing and data exchange$ followed by vigilance to ensure that freedom from proprietary loc%*in is maintained in critical areas. The drawbac% is that standards inevitably lag in terms of glamorous features$ ma%ing the feature*based ploy an easy one for proprietary vendors to use. (pen ;ource products are strong in this area$ not only from the point of view of adherence to standards but also by helping to mitigate against insidious loc%*in if they are chosen as core infrastructure components. 4)t is the use of proprietary standards and protocols that effectively mandates the purchase of further products from the same supplier. &andating the use of open internet standards (as in the e*-)/ rather than proprietary formats$ and developing F&1*based data definitions$ for intra*-overnment$ and -overnment*to*Citi7en interoperability$ is a practical approach to controlling the Gproprietary loc%*inH4. The choice is not easy. &any wea%er managements simply roll*over and buy from a single supplier$ but they pay a high price. (pen ;ource software provides further flexibility through freedom.
!reedom from a single #endor Software #endors can go out of business* and they can arbitrarily decide to cease de#elopment of a product$ 5ow would your business cope if it relied on such a product6 7pen+source software allows you to retain not 8ust the right to use the software you already ha#e* but the ability to continue to use it as your needs change$ !reedom to modify your software 9ou aren:t limited to what one company belie#es you need$ Proprietary software #endors must cater for many different companies* predominantly their own$ 7pen+source software can be tailored for the way you do business$ .t is usually within the resources of all but the smallest companies to modify 7pen Source software to suit their own needs ,and potentially then to LPU

make those enhancements a#ailable as a public good-$ .f in+house de#elopment skills don:t e"ist* a short email to the pro8ect:s mailing list will usually find a suitable consultant$

+upport and Accounta ility

)t may appear counter*intuitive at first$ especially to someone used only to dealing with proprietary software$ but whilst the models for obtaining support and accountability for (pen ;ource software are clearly different$ the (pen ;ource outcome is generally better than for all but unusual cases of user* vendor relationships. (ne of the most common counter*arguments to the use of (pen ;ource software is characterised as the Iwho do ) sueJK <uestionD in other words$ who is liable if the software doesn't wor%J This argument seems plausible in theory. 6nfortunately$ though$ that isn't what aplies in all but the rarest of circumstances. 3 moment's inspection of typical #613 (#nd 6ser 1icence 3greements will dispel that myth. 3ll usual software licences explicitly disclaim responsibility or liability for anything more serious than defects on the distribution medium$ with the responsibilities being a one*way street and resting on the user$ not the supplier. +roprietary software licences are intended to absolve the vendor of liability for almost any problem you may incur. &a2or vendors have large legal teams whose 2ob it is to prevent the vendor from being liable for anything. This does not seem unreasonable L the vendor wants to sell software$ not spend months or years at a time defending protracted tort and liability suits. (pen*source software does not differ from proprietary software in this respect. (pen*source licences typically disclaim all liabilities and warranties$ including such basic warranties as merchantability and fitness for purpose. Those in the %now$ who have adopted (pen ;ource ;oftware already$ will shrug their shoulders and choose the practical benefits of increased reliablility and security over illusory options to sue or pursue other remedies from a negligent vendor. "etractors of open*source software <uite rightly point out that the free licence to use the software includes no support contract. 0ut they neglect to mention the other side of that issue> many proprietary software licences have no support included either. )ndeed$ the ma2ority of mass*mar%et proprietary software support is aimed at hand*holding for inexperienced users. Must as proprietary vendors will sell support contracts with agreed service levels$ suppliers and third parties will provide support for open* source software. 3n example of this is the -nat translator for the 3da programming language$ as reported in GC(.#CT32000H and elsewhere. 43CT #urope was founded in @AAB to provide support for commercial$ industrial and military uses of the -.3T +rofessional 3da AN 2O development environment in #urope. )t was founded 2ointly by 3da Core Technologies )nc (3CT $ and by the #uropean members of the -.3T 3da AN pro2ect. 3CT is a privately held corporation and was founded in 3ugust @AAP by the principal authors of the -.3T 3da AN compiler system. 3CT was founded without any initial capital other than some small loans from the principles$ and has existed entirely from revenue from its inception. 3CT claims to be currently profitable. The people involved in both 3CT and 3CT #urope (from now on$ 3CT have been wor%ing with 3da for over twenty years$ starting with the development of a wor%ing 3da compiler for preliminary 3da in @AQA$ and the first validated 3da O, system in @AO,. This wor% was done at .ew Yor% 6niversity by a team dedicated to the technical success of the 3da language$ which moved to 3CT after its foundation. -.3T is the most widely used 3da AN development system$ available on many platforms$ from wor%stations and +Cs to bare boards. 3da solutions using -.3T encompass


conventional$ real*time$ embedded$ and distributed systems applications. The -.3T technology has always been based on free software$ and more specifically on the -.6 toolset. The -.3T compiler is integrated with the -CC (the -.6 C compiler bac%*end. The -.3T debugger is based on -"0 (the -.6 debugger that has been adapted for 3da AN. -1)"#$ the -.3T integrated development environment$ is based on #macs$ which has been adapted and complemented to create a friendlier and complete environment. The -T!3da -6) technology leverages on the -T! graphical tool%it and provides an advanced -6) builder. These are a few but significant examples of the technological offering of 3CT. 3ll the products being distributed by 3CT are free software$ usually under a -+1 or 1-+1*li%e licence. ;ince its foundation$ 3CT has established strategic partnerships with hardware and software manufacturers providing 3da AN capabilities. )n the former category is 3CT's relationship with ;ilicon -raphics$ )nc.$ whose new ;-) 3da AN product is based on -.3T. 3s of @AAA$ ;-) sold over a billion dollars of 3da related software and e<uipment. 3CT has relationships with several other hardware manufacturers such Compa< and =ewlett +ac%ard. Commercial customers of 3CT #urope include 3erospatiale$ 3lenia$ 0.+$ 0oeing$ 0ritish 3erospace$ Canal+$ C3;3$ "asa$ #ricsson$ =ughes$ 1oc%heed$ T98$ etc.4 To add some context to that <uote above$ 3da is a language designed specifically for military$ industrial and aerospace mission*critical and safety*critical systems where human life is routinely ris%ed if software systems do not function correctly. ;ome software vendors produce free software$ and obtain large parts of their revenue from service and support (e.g. Rope . )n other situations$ open*source consultants will provide training and5or support for software they recommend. =owever$ the fundamental advantage of open*source software when it comes to support is that it's always possible to retain a company to provide support. 0ecause the source code is freely available$ organisations are not limited to obtaining support from the authors. There is no restriction on other suppliers learning enough about the software to provide ade<uate support whenever demand exists. ;pea%ing from a personal perspective$ the authors feel obliged to point out that when software is as reliable as 3pache$ &y;S1 and similar pro2ects$ support dwindles as an issue. 8hen software wor%s reliably$ support for it ceases to be a frontline concern.

(hat is the purpose of . in/ .etc/ .li and .de0 directories?

Ans. . in : Essential user command inaries 1for use y all users)

contains commands that may be used by both the system administrator and by users$ but which are re<uired when no other filesystems are mounted (e.g. in single user mode . )t may also contain commands which are used indirectly by scripts. G@H



There must be no subdirectories in /bin. The following commands$ or symbolic lin%s to commands$ are re<uired in /bin.
Co""an # %at %'(r& %'"o# %'o)n %& #ate ## #f #"es( e%'o false $es%ri&tion Utility to concatenate files to standard output Utility to change file group ownership Utility to change file access permissions Utility to change file owner and group Utility to copy files and directories Utility to print or set the system data and time Utility to con#ert and copy a file Utility to report filesystem disk space usage Utility to print or control the kernel message buffer Utility to display a line of te"t Utility to do nothing* unsuccessfully

'ostna" Utility to show or set the system:s host name e *ill ln lo(in ls "*#ir "*no# "ore "o+nt "v &s LPU Utility to send signals to processes Utility to make links between files Utility to begin a session on the system Utility to list directory contents Utility to make directories Utility to make block or character special files Utility to page through te"t Utility to mount a filesystem Utility to mo#e0rename files Utility to report process status

Co""an #


&)# r" r"#ir se# s' stty s+ syn% tr+e

Utility to print name of current working directory Utility to remo#e files or directories Utility to remo#e empty directories (he ;sed: stream editor (he 2ourne command shell Utility to change and print terminal line settings Utility to change user .< Utility to flush filesystem buffers Utility to do nothing* successfully

+"o+nt Utility to unmount file systems +na"e Utility to print system information

)f /bin/sh is not a true 0ourne shell$ it must be a hard or symbolic lin% to the real shell command. The [ and test commands must be placed together in either /bin or /usr/bin.

/or example bash behaves differently when called as sh or bash. The use of a symbolic lin% also allows users to easily see that /bin/sh is not a true 0ourne shell. The re<uirement for the [ and test commands to be included as binaries (even if implemented internally by the shell is shared with the +(;)F.2 standard.
+pecific $ptions

The following programs$ or symbolic lin%s to programs$ must be in /bin if the corresponding subsystem is installed>
Co""an # %s' e# (he $es%ri&tion shell ,optional-

(he ;ed: editor ,optional-


Co""an # tar %&io (,i& (+n,i& ,%at netstat &in(

$es%ri&tion (he tar archi#ing utility ,optional(he cpio archi#ing utility ,optional(he =1U compression utility ,optional(he =1U uncompression utility ,optional(he =1U uncompression utility ,optional(he network statistics utility ,optional(he . %P network test utility ,optional-

)f the gunzip and zcat programs exist$ they must be symbolic or hard lin%s to g7ip. /bin/csh may be a symbolic lin% to /bin/tcsh or /usr/bin/tcsh.

The tar$ g7ip and cpio commands have been added to ma%e restoration of a system possible (provided that / is intact . Conversely$ if no restoration from the root partition is ever expected$ then these binaries might be omitted (e.g.$ a 9(& chip root$ mounting /usr through ./; . )f restoration of a system is planned through the networ%$ then ftp or tftp (along with everything necessary to get an ftp connection must be available on the root partition.

.de0 : 'e0ice files


The /dev directory is the location of special or device files.

+pecific $ptions

)f it is possible that devices in /dev will need to be manually created$ /dev must contain a command named MAKEDEV$ which can create devices as needed. )t may also contain a MAKEDEV.local for any local devices.


)f re<uired$ MAKEDEV must have provisions for creating any device that may be found on the system$ not 2ust those that a particular implementation installs.

.etc : 4ost5specific system configuration


The /etc hierarchy contains configuration files. 3 4configuration file4 is a local file used to control the operation of a programD it must be static and cannot be an executable binary. GPH

.o binaries may be located under /etc. GNH The following directories$ or symbolic lin%s to directories are re<uired in /etc>
$ire%tor y opt >11 sgml "ml $es%ri&tion onfiguration for 0opt onfiguration for the > )indow system ,optionalonfiguration for S=%L ,optionalonfiguration for >%L ,optional-

+pecific $ptions

The following directories$ or symbolic lin%s to directories must be in /etc$ if the corresponding subsystem is installed>
$ire%tor y opt $es%ri&tion onfiguration for 0opt

The following files$ or symbolic lin%s to files$ must be in /etc if the corresponding subsystem is installed> GBH

$es%ri&tion Systemwide initiali/ation file for shell logins ,optional-


e !orts "stab "t!users gate#a$s gett$de"s grou! host.con" hosts

$es%ri&tion 1!S filesystem access control list ,optionalStatic information about filesystems ,optional!(P daemon user access control list ,optional!ile which lists gateways for routed ,optionalSpeed and terminal settings used by getty ,optionalUser group file ,optionalResol#er configuration file ,optionalStatic information about host names ,optional-

hosts.allo# 5ost access file for ( P wrappers ,optionalhosts.den$ 5ost access file for ( P wrappers ,optionalhosts.e%uiv List of trusted hosts for rlogin* rsh* rcp ,optionalhosts.l!d inetd.con" inittab issue" &otd &tab &tools.con" net#or's !ass#d !rintca! !ro"ile !rotocols

List of trusted hosts for lpd ,optionalonfiguration file for inetd ,optionalonfiguration file for init ,optionalPre+login message and identification file ,optionalList of e"tra directories to search for shared libraries ,optionalPost+login message of the day file ,optional<ynamic information about filesystems ,optionalonfiguration file for mtools ,optionalStatic information about network names ,optional(he password file ,optional(he lpd printer capability database ,optionalSystemwide initiali/ation file for sh shell logins ,optional.P protocol listing ,optional-

resolv.con" Resol#er configuration file ,optionalr!c


protocol listing ,optional-


securett$ services shells s$slog.con"

$es%ri&tion ((9 access control for root login ,optionalPort names for network ser#ices ,optionalPathnames of #alid login shells ,optionalonfiguration file for syslogd ,optional-


does not fit the static nature of /etc> it is excepted for historical reasons.

.li : Essential shared li raries and kernel modules


The /lib directory contains those shared library images needed to boot the system and run the commands in the root filesystem$ ie. by binaries in /bin and /sbin. G@2H

3t least one of each of the following filename patterns are re<uired (they may be files$ or symbolic lin%s >

$es%ri&tion (he dynamically+linked ,optionallibrary


(he e"ecution time linker0loader ,optional-

)f a C preprocessor is installed$ /lib/cpp must be a reference to it$ for historical reasons. G@,H
+pecific $ptions

The following directories$ or symbolic lin%s to directories$ must be in /lib$ if the corresponding subsystem is installed>
$ire%tor y

$es%ri&tion Loadable kernel modules ,optional-


Q6. A) (hat is the difference in use of 7? and 78 when used with shell and with grep command?

Ans 1.(hen used (ith grep !ommand

+ )

> would match either the left hand side or the right hand side . (abc + def would match abc or def. > 8ill match the preceding symbol 0 or at most @ time. so ab)c would match 'ac' and 'abc' only.

6.(hen used (ith +hell


Plus. 3ddition arithmetic operator.


Option. (ption flag for a command or filter. Certain commands and builtins use the + to enable certain options and the * to disable them. )n parameter substitution$ the + prefixes an alternate value that a variable expands to.

test operator. 8ithin certain expressions$ the J indicates a test for a condition. )n a double*parentheses construct$ the J can serve as an element of a C*style trinary operator. G2H

++ var0 , var-./0)/12- 22 3 4 4 3 3 3 3 3 3 i" 5 67var-6 *lt /0 8 then var0,/ else var0,2"i

)n a parameter substitution expression$ the J tests whether a variable has been set.


) ) !an you explain how the directory structure of 9inux works?

Ans. :he directory tree. :5 ;;



)f youKre coming from 8indows$ the 1inux file system structure can seem particularly alien. The C>T drive and drive letters are gone$ replaced by a 5 and cryptic*sounding directories$ most of which have three letter names. The /ilesystem =ierarchy ;tandard (/=; defines the structure of file systems on 1inux and other 6.)F*li%e operating systems. =owever$ 1inux file systems also contain some directories that arenKt yet defined by the standard.
. < :he ,oot 'irectory

#verything on your 1inux system is located under the 5 directory$ %nown as the root directory. You can thin% of the 5 directory as being similar to the C>T directory on 8indows L but this isnKt strictly true$ as 1inux doesnKt have drive letters. 8hile another partition would be located at ">T on 8indows$ this other partition would appear in another folder under 5 on 1inux.


. in < Essential *ser )inaries

The 5bin directory contains the essential user binaries (programs that must be present when the system is mounted in single*user mode. 3pplications such as /irefox are stored in 5usr5bin$ while important system programs and utilities such as the bash shell are located in 5bin. The 5usr directory may be stored on another partition L placing these files in the 5bin directory ensures the system will have these important utilities even if no other file systems are mounted. The 5sbin directory is similar L it contains essential system administration binaries.


. oot < +tatic )oot -iles

The 5boot directory contains the files needed to boot the system L for example$ the -960 boot loaderKs files and your 1inux %ernels are stored here. The boot loaderKs configuration files arenKt located here$ though L theyKre in 5etc with the other configuration files.


.cdrom < 4istorical %ount 2oint for !'5,$%s

The 5cdrom directory isnKt part of the /=; standard$ but youKll still find it on 6buntu and other operating systems. )tKs a temporary location for C"*9(&s inserted in the system. =owever$ the standard location for temporary media is inside the 5media directory.
.de0 < 'e0ice -iles

1inux exposes devices as files$ and the 5dev directory contains a number of special files that represent devices. These are not actual files as we %now them$ but they appear as files L for example$ 5dev5sda represents the first ;3T3 drive in the system. )f you wanted to partition it$ you could start a partition editor and tell it to edit 5dev5sda. This directory also contains pseudo*devices$ which are virtual devices that donKt actually correspond to hardware. /or example$ 5dev5random produces random numbers. 5dev5null is a special device that produces no output and automatically discards all input L when you pipe the output of a command to 5dev5null$ you discard it.


.etc < !onfiguration -iles

The 5etc directory contains configuration files$ which can generally be edited by hand in a text editor. .ote that the 5etc5 directory contains system*wide configuration files L user*specific configuration files are located in each userKs home directory.
.home < 4ome -olders

The 5home directory contains a home folder for each user. /or example$ if your user name is bob$ you have a home folder located at 5home5bob. This home folder contains the userKs data files and user* specific configuration files. #ach user only has write access to their own home folder and must obtain elevated permissions (become the root user to modify other files on the system.


.li < Essential +hared 9i raries

The 5lib directory contains libraries needed by the essential binaries in the 5bin and 5sbin folder. 1ibraries needed by the binaries in the 5usr5bin folder are located in 5usr5lib.
.lost8found < ,eco0ered -iles

#ach 1inux file system has a lost+found directory. )f the file system crashes$ a file system chec% will be performed at next boot. 3ny corrupted files found will be placed in the lost+found directory$ so you can attempt to recover as much data as possible.


.media < ,emo0a le %edia

The 5media directory contains subdirectories where removable media devices inserted into the computer are mounted. /or example$ when you insert a C" into your 1inux system$ a directory will automatically be created inside the 5media directory. You can access the contents of the C" inside this directory.
.mnt < :emporary %ount 2oints

=istorically spea%ing$ the 5mnt directory is where system administrators mounted temporary file systems while using them. /or example$ if youKre mounting a 8indows partition to perform some file recovery operations$ you might mount it at 5mnt5windows. =owever$ you can mount other file systems anywhere on the system.
.opt < $ptional 2ackages

The 5opt directory contains subdirectories for optional software pac%ages. )tKs commonly used by proprietary software that doesnKt obey the standard file system hierarchy L for example$ a proprietary program might dump its files in 5opt5application when you install it.
.proc < &ernel = 2rocess -iles

The 5proc directory similar to the 5dev directory because it doesnKt contain standard files. )t contains special files that represent system and process information.


.root < ,oot 4ome 'irectory

The 5root directory is the home directory of the root user. )nstead of being located at 5home5root$ itKs located at 5root. This is distinct from 5$ which is the system root directory.
.run < Application +tate -iles

The 5run directory is fairly new$ and gives applications a standard place to store transient files they re<uire li%e soc%ets and process )"s. These files canKt be stored in 5tmp because files in 5tmp may be deleted.
.s in < +ystem Administration )inaries

The 5sbin directory is similar to the 5bin directory. )t contains essential binaries that are generally intended to be run by the root user for system administration.


.selinux < +E9inux >irtual -ile +ystem

)f your 1inux distribution uses ;#1inux for security (/edora and 9ed =at$ for example $ the 5selinux directory contains special files used by ;#1inux. )tKs similar to 5proc. 6buntu doesnKt use ;#1inux$ so the presence of this folder on 6buntu appears to be a bug.
.sr0 < +er0ice 'ata

The 5srv directory contains Udata for services provided by the system.V )f you were using the 3pache =TT+ server to serve a website$ youKd li%ely store your websiteKs files in a directory inside the 5srv directory.


.tmp < :emporary -iles

3pplications store temporary files in the 5tmp directory. These files are generally deleted whenever your system is restarted and may be deleted at any time by utilities such as tmpwatch.
.usr < *ser )inaries = ,ead5$nly 'ata

The 5usr directory contains applications and files used by users$ as opposed to applications and files used by the system. /or example$ non*essential applications are located inside the 5usr5bin directory instead of the 5bin directory and non*essential system administration binaries are located in the 5usr5sbin directory instead of the 5sbin directory. 1ibraries for each are located inside the 5usr5lib directory. The 5usr directory also contains other directories L for example$ architecture*independent files li%e graphics are located in 5usr5share. The 5usr5local directory is where locally compiled applications install to by default L this prevents them from muc%ing up the rest of the system.


.0ar < >aria le 'ata -iles

The 5var directory is the writable counterpart to the 5usr directory$ which must be read*only in normal operation. 1og files and everything else that would normally be written to 5usr during normal operation are written to the 5var directory. /or example$ youKll find log files in 5var5log.

c) I want to do a wildcard search on files with ? or ? in the names. 4ow do I do that? Ans
The UJU or U:V is a special character$ you cannot search with normal grep we have to use escape character (T in order to negate it. ;o use ITJI or IT:K to search for UJU or U:V. This is applicable for all the special characters


Q@. a) (hat is the difference etween 9inux and *#IA? Ans. That's a very broad <uestion and could be answered any number of ways. +robably the simplest
answer is that from a technical point of view there are no ma2or differences. &ost people aren't satisfied with believing that 1inux and 6.)F are very similar$ though. =ere's a list of the most obvious remaining differences. Origin: 6.)F originated in the laboratories of universities and large corporations$ as an initiative within the context of those organisations. 1inux was begun by a university student (1inus Torvalds without any initial support from any large organisation. 1inux also began as in mimic%ry of other well*%nown 6.)F* li%e implementations$ whereas the initial 6.)F implementations were original research. &ost commercial 6.)F versions are also derived from that early research. Service Model: &ost 6.)F versions operate on the basis that you can buy help (support and service contracts . 3lthough such things are increasingly available to 1inux technologists$ traditional arrangements consist of providing your own help$ with the assistance of a community of li%e*minded people. 1inux is big$ and access to communities is more important than$ say$ it is for )0& mainframes. Equip ent: 3lthough 1inux runs on many %inds of e<uipment$ it is best %nown for its support of commodity )0&*)ntel +C*based hardware. &ost of the more popular 6.)F flavours focus on high* performance hardware$ usually of a proprietory nature$ or using high*end standard computing architectures$ li%e ;+39C. 8ith ever*increasing gains in +C hardware$ li%e ;erial*3T3$ this distinction is not as large as it used to be$ especially for low performance uses$ li%e des%tops. !icensing: 1inux follows the /ree ;oftware /oundation's radical licensing model$ which provides a great deal of liberty to those that interact with 1inux technology. 6.)F versions provided by other vendors have profit strategies embedded in them. +eople who offer 1inux services might have a profit strategy$ but 1inux itself doesn't. This means that vendor loc%*in is less of an issue with 1inux than it is with other 6.)F offerings. )t also means that organisations big enough to have a center of computing competancy always have the choice of 4doing it themselves.4 "onest#: 1inux and related software is extremely visible. You can find out about flaws before you commit to the technology rather than afterwards. 0ecause of this$ a version number in 1inux is a more relable indicator of the <uality of the software than in 6.)F. /or example$ most 1inux software spends a long time being version 0 (7ero before it ever <ualifies for the label 4version @.4 )n terms of <uality$ performance and feature set$ there's little to separate 1inux from the other 6.)Fes. 1inux has yet to provide genuine real*time scheduling$ which some other 6.)F versions do well.


) (hat will e the output of the following commands? 1i) B ls 5 l C sort ; file1.txt <
(he 7utput of the command @ls Al @ )ill be sorted as the pipe Symbol is used and then the output will be redirected to the file @file1$t"tB$

1ii) B who C sort ;;file1.txt <

(he 7utput of the command @)ho @ )ill be sorted as the pipe Symbol is used and then the output will be redirected to the file @file1$t"tB$


QD. a)Illustrate the steps to write/ compile and execute a ! program in 9inux en0ironment using a program to find largest of @ num ers.

+tep 1 $ 7pen (erminal +tep 6 $ 7pen any Cditor to write your

!or instance type gedit largest$c programs $

+tep @ $ )rite the

programe code and sa#e it $


+tep D $

ompile your c progmace usin command gcc

!or instance type gcc largest$c

+tep E$ See the output by using command $0a$out


) (hat are 7sym olicF and hard links/ and how can I identify them? And how do I create links 1sym olic or hard)?
Ans $ .ar# lin* .t can only be used on files,not directories- and is basically a way of gi#ing multiple names to the same physical file$ hard links that point to that single physical file must be on the same partition as the orginal target file$ (he files are hard links if they ha#e the same inode number$


!reating sym olic links

The ln command ma%e lin%s between files. 0y default$ ln ma%es hard lin%s.
ln !ommand +yntax

The syntax is as follows for 6nix 5 1inux hard lin% command>

ln {source} {link}


so+r%e is an e"isting file$ lin* is the file to create ,a hard link-$

To create hard lin% for foo file$ enter>

echo 9This is a test9 : "oo ln "oo bar ls *li bar "oo

sy"/oli% lin* when you try to open a symbolic link which points to a file or change to one that points to a directory*the command you run acts on the file or directory that is the target of that link$the target has its own permissions and ownership that you cannot see from the symbolic link$ (he symbolic link can e"ist on a different disk partition than the target$

!reating sym olic links

The symbolic lin%s are needed for properly starting several F/ree instances$ as well for properly exiting an F session. This applies for both starting F from console and the automatic starting of F by the display manager (%dm$ gdm$ xdm . You need to create as many symbolic lin%s to the modified F server binary (or to the original F server in case you do not need a modified one $ as the number of your video cards5F sessions. ) assume that you will have to use a modified F server$ but in case you do not need it$ use the following commands to create the lin%s to your original F server>


cd ln ln ln

/usr/;--<=/bin/ *s ;>ree5&odi"ied8 ;0 *s ;>ree5&odi"ied8 ;*s ;>ree5&odi"ied8 ;2

)n case you use the provided rpm pac%ages$ you'll only need this if you want more than P parallel running F servers5F sessions$ as the rpm creates P symbolic lin%s to the F server binary. $inding Soft !in% lr**r**r** **W if it starts with l (then it means soft lin% To create soft lin% Code>
ln *s abc.t t e"g.t t

$inding hard lin% =ard lin% shares the same inode. Code>
7 ln abc.t t e"g.t t

do ls &li and chec% the first column value. both abc.txt and efg.txt have the same value


QE. a) (hat is the role of a oot loader? (hich one is etter/ installing windows o0er 9inux or installing 9inux o0er windows? -ind out the possi le errors for oth the scenarios.
,ole of a )ootloader

8hen power is first applied to a processor board$ many elements of hardware must be initiali7ed before even the simplest program can run. #ach architecture and processor has a set of predefined actions and configurations upon release of reset$ which includes fetching initiali7ation code from an onboard storage device (usually /lash memory . This early initiali7ation code is part of the bootloader and is responsible for breathing life into the processor and related hardware components. &ost processors have a default address from which the first bytes of code are fetched upon application of power and release of reset. =ardware designers use this information to arrange the layout of /lash memory on the board and to select which address range(s the /lash memory responds to. This way$ when power is first applied$ code is fetched from a well*%nown and predictable address$ and software control can be established. The bootloader provides this early initiali7ation code and is responsible for initiali7ing the board so that other programs can run. This early initiali7ation code is almost always written in the processorKs native assembly language. This fact alone presents many challenges$ some of which we examine here. (f course$ after the bootloader has performed this basic processor and platform initiali7ation$ its primary role is fetching and booting a full*blown operating system. )t is responsible for locating$ loading$ and passing control to the primary operating system. )n addition$ the bootloader might have advanced features$ such as the capability to validate an (; image$ upgrade itself or an (; image$ or choose from among several (; images based on a developer*defined policy. 6nli%e the traditional +C*0)(; model$ when the (; ta%es control$ the bootloader is overwritten and ceases to exist

1G fundamental differences etween 9inux and (indows

Before debating the relative merits and shortcomings of Linux and Windows, it helps to understand the real distinctions between them

H1: -ull access 0s. no access

=aving access to the source code is probably the single most significant difference between 1inux and 8indows. The fact that 1inux belongs to the -.6 +ublic 1icense ensures that users (of all sorts can access (and alter the code to the very %ernel that serves as the foundation of the 1inux operating system. You want to peer at the 8indows codeJ -ood luc%. 6nless you are a member of a very select (and elite$ to many group$ you will never lay eyes on code ma%ing up the 8indows operating system.


You can loo% at this from both sides of the fence. ;ome say giving the public access to the code opens the operating system (and the software that runs on top of it to malicious developers who will ta%e advantage of any wea%ness they find. (thers say that having full access to the code helps bring about faster improvements and bug fixes to %eep those malicious developers from being able to bring the system down. ) have$ on occasion$ dipped into the code of one 1inux application or another$ and when all was said and done$ was happy with the results. Could ) have done that with a closed*source 8indows applicationJ .o.

H6: 9icensing freedom 0s. licensing restrictions

3long with access comes the difference between the licenses. )Km sure that every )T professional could go on and on about licensing of +C software. 0ut letKs 2ust loo% at the %ey aspect of the licenses (without getting into legalese . 8ith a 1inux -+1*licensed operating system$ you are free to modify that software and use and even republish or sell it (so long as you ma%e the code available . 3lso$ with the -+1$ you can download a single copy of a 1inux distribution (or application and install it on as many machines as you li%e. 8ith the &icrosoft license$ you can do none of the above. You are bound to the number of licenses you purchase$ so if you purchase @0 licenses$ you can legally install that operating system (or application on only @0 machines.

H@: $nline peer support 0s. paid help5desk support

This is one issue where most companies turn their bac%s on 1inux. 0ut itKs really not necessary. 8ith 1inux$ you have the support of a huge community via forums$ online search$ and plenty of dedicated 8eb sites. 3nd of course$ if you feel the need$ you can purchase support contracts from some of the bigger 1inux companies (9ed =at and .ovell for instance . =owever$ when you use the peer support inherent in 1inux$ you do fall prey to time. You could have an issue with something$ send out e*mail to a mailing list or post on a forum$ and within @0 minutes be flooded with suggestions. (r these suggestions could ta%e hours of days to come in. )t seems all up to chance sometimes. ;till$ generally spea%ing$ most problems with 1inux have been encountered and documented. ;o chances are good youKll find your solution fairly <uic%ly. (n the other side of the coin is support for 8indows. Yes$ you can go the same route with &icrosoft and depend upon your peers for solutions. There are 2ust as many help sites5lists5forums for 8indows as there are for 1inux. 3nd you can purchase support from &icrosoft itself. &ost corporate higher*ups easily fall victim to the safety net that having a support contract brings. 0ut most higher*ups havenKt had to depend up on said support contract. (f the various people ) %now who have used either a 1inux paid support contract or a &icrosoft paid support contract$ ) canKt say one was more pleased than the other. This of course begs the <uestion U8hy do so many say that &icrosoft support is superior to 1inux paid supportJV

HD: -ull 0s. partial hardware support

(ne issue that is slowly becoming nonexistent is hardware support. Years ago$ if you wanted to install 1inux on a machine you had to ma%e sure you hand*pic%ed each piece of hardware or your installation would not wor% @00 percent. ) can remember$ bac% in @AAQ*ish$ trying to figure out why ) couldnKt get Caldera 1inux or 9ed =at 1inux to see my modem. 3fter much loo%ing around$ ) found ) was the proud


owner of a 8inmodem. ;o ) had to go out and purchase a 6; 9obotics external modem because that was the one modem ) knew would wor%. This is not so much the case now. You can grab a +C (or laptop and most li%ely get one or more 1inux distributions to install and wor% nearly @00 percent. 0ut there are still some exceptions. /or instance$ hibernate5suspend remains a problem with many laptops$ although it has come a long way. 8ith 8indows$ you %now that most every piece of hardware will wor% with the operating system. (f course$ there are times (and ) have experienced this over and over when you will wind up spending much of the day searching for the correct drivers for that piece of hardware you no longer have the install dis% for. 0ut you can go out and buy that @0*cent #thernet card and %now itKll wor% on your machine (so long as you have$ or can find$ the drivers . You also can rest assured that when you purchase that insanely powerful graphics card$ you will probably be able to ta%e full advantage of its power.

HE: !ommand line 0s. no command line

.o matter how far the 1inux operating system has come and how ama7ing the des%top environment becomes$ the command line will always be an invaluable tool for administration purposes. .othing will ever replace my favorite text*based editor$ ssh$ and any given command*line tool. ) canKt imagine administering a 1inux machine without the command line. 0ut for the end user C not so much. You could use a 1inux machine for years and never touch the command line. ;ame with 8indows. You can still use the command line with 8indows$ but not nearly to the extent as with 1inux. 3nd &icrosoft tends to obfuscate the command prompt from users. 8ithout going to 9un and entering cmd (or command$ or whichever it is these days $ the user wonKt even %now the command*line tool exists. 3nd if a user does get the 8indows command line up and running$ how useful is it reallyJ

HI: !entraliJed 0s. noncentraliJed application installation

The heading for this point might have thrown you for a loop. 0ut letKs thin% about this for a second. 8ith 1inux you have (with nearly every distribution a centrali7ed location where you can search for$ add$ or remove software. )Km tal%ing about pac%age management systems$ such as ;ynaptic. 8ith ;ynaptic$ you can open up one tool$ search for an application (or group of applications $ and install that application without having to do any 8eb searching (or purchasing . 8indows has nothing li%e this. 8ith 8indows$ you must %now where to find the software you want to install$ download the software (or put the C" into your machine $ and run setup.exe or install.exe with a simple double*clic%. /or many years$ it was thought that installing applications on 8indows was far easier than on 1inux. 3nd for many years$ that thought was right on target. .ot so much now. )nstallation under 1inux is simple$ painless$ and centrali7ed.

HK: -lexi ility 0s. rigidity

) always compare 1inux (especially the des%top and 8indows to a room where the floor and ceiling are either movable or not. 8ith 1inux$ you have a room where the floor and ceiling can be raised or lowered$ at will$ as high or low as you want to ma%e them. 8ith 8indows$ that floor and ceiling are immovable. You canKt go further than &icrosoft has deemed it necessary to go.


Ta%e$ for instance$ the des%top. 6nless you are willing to pay for and install a third*party application that can alter the des%top appearance$ with 8indows you are stuc% with what &icrosoft has declared is the ideal des%top for you. 8ith 1inux$ you can pretty much ma%e your des%top loo% and feel exactly how you want5need. You can have as much or as little on your des%top as you want. /rom simple flat /luxbox to a full*blown ," Compi7 experience$ the 1inux des%top is as flexible an environment as there is on a computer.

HL: -an oys 0s. corporate types

) wanted to add this because even though 1inux has reached well beyond its school*pro2ect roots$ 1inux users tend to be soapbox*dwelling fanatics who are <uic% to spout off about why you should be choosing 1inux over 8indows. ) am guilty of this on a daily basis () try hard to recruit new fanboys5girls $ and itKs a badge ) wear proudly. (f course$ this is seen as less than professional by some. 3fter all$ why would something worthy of a corporate environment have or need cheerleadersJ ;houldnKt the software sell itselfJ 0ecause of the open source nature of 1inux$ it has to ma%e do without the help of the mar%eting budgets and deep poc%ets of &icrosoft. 8ith that comes the need for fans to help spread the word. 3nd word of mouth is the best friend of 1inux. ;ome see the fanaticism as the same college*level hoorah that %eeps 1inux in the basements for 16meetings and science pro2ects. 0ut ) beg to differ. 3nother company$ than%s to the phenomenon of a simple music player and phone$ has fallen into the same fanboy fanaticism$ and yet that companyKs image has not been besmirched because of that fanaticism. 8indows does not have these same fans. )nstead$ 8indows has a league of paper*certified administrators who believe the hype when they hear the misrepresented mar%et share numbers reassuring them they will be employable until the end of time.

HM: Automated 0s. nonautomated remo0a le media

) remember the days of old when you had to mount your floppy to use it and unmount it to remove it. 8ell$ those times are drawing to a close C but not completely. (ne issue that plagues new 1inux users is how removable media is used. The idea of having to manually UmountV a C" drive to access the contents of a C" is completely foreign to new users. There is a reason this is the way it is. 0ecause 1inux has always been a multiuser platform$ it was thought that forcing a user to mount a media to use it would %eep the userKs files from being overwritten by another user. Thin% about it> (n a multiuser system$ if everyone had instant access to a dis% that had been inserted$ what would stop them from deleting or overwriting a file you had 2ust added to the mediaJ Things have now evolved to the point where 1inux subsystems are set up so that you can use a removable device in the same way you use them in 8indows. 0ut itKs not the norm. 3nd besides$ who doesnKt want to manually edit the /etc/fstab fleJ

H1G: %ultilayered run le0els 0s. a single5layered run le0el

) couldnKt figure out how best to title this point$ so ) went with a description. 8hat )Km tal%ing about is 1inuxK inherent ability to stop at different run levels. 8ith this$ you can wor% from either the command line (run level , or the -6) (run level N . This can really save your soc%s when F 8indows is fubared and you need to figure out the problem. You can do this by booting into run level ,$ logging in as root$ and finding5fixing the problem.


8ith 8indows$ youKre luc%y to get to a command line via safe mode C and then you may or may not have the tools you need to fix the problem. )n 1inux$ even in run level ,$ you can still get and install a tool to help you out (hello apt*get install 3++1)C3T)(. via the command line . =aving different run levels is helpful in another way. ;ay the machine in <uestion is a 8eb or mail server. You want to give it all the memory you have$ so you donKt want the machine to boot into run level N. =owever$ there are times when you do want the -6) for administrative purposes (even though you can fully administer a 1inux server from the command line . 0ecause you can run the startx command from the command line at run level ,$ you can still start up F 8indows and have your -6) as well. 8ith 8indows$ you are stuc% at the -raphical run level unless you hit a serious problem.

Nour callO
Those are @0 fundamental differences between 1inux and 8indows. You can decide for yourself whether you thin% those differences give the advantage to one operating system or the other. &eJ 8ell ) thin% my reputation (and opinion precedes me$ so ) probably donKt need to say ) feel strongly that the advantage leans toward 1inux.

) 4ow do I add or change personal information in an account and how do I add groups? Explain how can i add.delete users in a group?
6sers are members of a default group. 9ed =at 1inux (also /edora Core$ Cent(;$ etc. will add new users to a group of the same group name as the user name. The default group for a user is specified in the file /etc/!ass#d
user*na&e1 1user*nu&ber1grou!*nu&ber1co&&ent section1/ho&e*director$1de"ault*shell

user11 1?001?001@reg1/ho&e/user11/bin/bash

A new user may be created and assigned a group with the useradd commandD

Add a new user and assign them to be members of the group EaccountingED
useradd *& *g accounting user2

Add a new user and assign them to be members of the initial group EaccountingE and supplementary group EfloppyED
useradd *& *g accounting *@ "lo!!$ user-

ommand arguments for useraddD Ar(+"en t $es%ri&tion


+m +% +g += +s +e +f +u

reate a home directory in /ho&e/ 1o home directory created$ Specify the initial group for the user$ Specify the initial group for the user by using the group number$ Specify the default shell for the user$ .f not specified set to /bin/bash Specify the e"piration date$ !ormat 999+%%+<< 1umber of days after a password e"pires that an account is disabled$ 2y default this feature is disabled ,+1Specify the user id number to be used$

<efaults specified in /etc/"s 4iew group membership for a user with the command Egrou!sE$ C"ampleD grou!s user2

The user id has a user system number associated with it (uid and this is defined in /etc/!ass#d. The group has a group system number (gid associated with it and this is defined in /etc/grou!
grou!*na&e1 1grou!*nu&ber1user-Auser2

user-1 1?001 user21 1?0-1 "lo!!$1 1-/1useraccounting1 1=001user2 a!ache1 1B01

User Euser1E is a member of default group Euser1E and also a member of group EfloppyB

-roup Commands>
g!ass#dD administer the 0etc0group file grou!addD reate a new group !ormatD grou!add 5*g gid 5*o88 5*"8 5*K KEC,VADEE8 grou! C"ampleD grou!add accounting grou!&odD %odify a group !ormatD grou!&od 5*g gid 5*o 88 5*n ne#Fgrou!Fna&e8 grou! C"ample + hange name of a groupD grou!&od *n accounting nerd$gu$s


grou!delD <elete a group C"ampleD grou!del accounting vigrD Cdit the group file /etc/grou! with #i$ 1o arguments specified$

+witching your default group: newgrp

6se the command ne#gr! group-name to switch your default group used in file creation or directory access. This starts a new shell. #xit to return to the previous group id. 6se the ps command to see if more than one shell is active. This only wor%s if you are a member of multiple groups otherwise you have no group to switch to. /or example 4user24 would li%e to create a file in the accounting directory which can be read my members of his group. /irst switch the default group with the command> ne#gr! accounting To return to your default group issue the 4exit4 command. )f confused$ issue the 4ps4 command. There should only be one instance of bash$ else you are in the alternate group and not the default group. 6se the command ne#gr! group-name file-name to change the group associated with a file. You must be a member of the group to execute the command sucessfully. (or be root The newgrp command logs a user into a new group by changing a user's real and effective group )". The user remains logged in and the current directory is unchanged. The execution of newgrp always replaces the current shell with a new shell$ even if the command terminates with an error (un%nown group . 3ny variable that is not exported is reset to null or its default value. #xported variables retain their values. ;ystem variables (such as +;@$ 6;#9$ +3T= and =(&# $ are reset to default values unless they have been exported by the system or the user. 8ith no operands and options$ newgrp changes the user's group )"s (real and effective bac% to the group specified in the user's password file entry. This is a way to exit the effect of an earlier newgrp command. 3 password is demanded if the group has a password and the user is not listed in /etc/grou! as being a member of that group. The only way to create a password for a group is to use passwd(@ $ then cut and paste the password from 5etc5shadow to 5etc5group. -roup passwords are anti<uated and not often used. -ives new login as if logged in as group member> ne#gr! *


QI. a) (hat are En0ironment >aria les? 4ow a ! program can gain access to en0ironment 0aria les? "i0e examples.
Ans. En0ironment 0aria les

;ometimes it is useful to communicate with a program in a semi*permanent way$ so that you do not need to specify a command*line option every time you type the command to execute the program. (ne way to do this is to generate a configuration file$ in which you can store data that will be used by the program every time it is run. This approach is typically useful if you have a large amount of data that you want to pass to a program every time it runs$ or if you want the program itself to be able to change the data. =owever$ environment variables provide a more lightweight approach. #nvironment variables$ sometimes called shell variables$ are usually set with the e !ort command in the shell. (This section assumes you are using the -.6 0ash shell. ;tandard environment variables are used for information about your home directory$ terminal type$ and so onD you can define additional variables for other purposes. The set of all environment variables that have values is collectively %nown as the environment. .ames of environment variables are case*sensitive$ and it is good form to use all upper*case letters when defining a new variableD certainly this is the case for all system*defined environment variables. The value of an environment variable can be any string that does not contain a null character (since the null character is used to terminate the string value . #nvironment variables are stored in a special array that can be read by your &ain function. =ere is the s%eleton for a &ain function that can read environment variablesD notice we have added a third parameter to &ain$ called env!$ which comes after argc and argv.
3include .stdio.h: /( To shorten e a&!leA not using arg! (/ int &ain +int argcA char (argv58A char (env!582 G I return 0H

.otice that env! is an array of strings$ 2ust as argv is. )t consists of a list of the environment variables of your shell$ in the following format>

Must as you can manually process command*line options from argv$ so can you manually process environment variables from env!. =owever$ the simplest way to access the value of an environment variable is with the getenv function$ defined in the system header stdlib.h. )t ta%es a single argument$ a string containing the name of the variable whose value you wish to discover. )t returns that value$ or a null pointer if the variable is not defined.

3include .stdio.h: 3include .stdlib.h: /( To shorten e a&!leA not using arg! (/ int &ain +int argcA char (argv58A char (env!582 G char (ho&eA (hostH ho&e , getenv+6HJME62H host , getenv+6HJKTLAME62H !rint" +6Cour ho&e director$ is Ms on Ms.Nn6A ho&eA host2H return 0H I

8hen you run this code$ it will print out a line li%e the following one.
Cour ho&e director$ is /ho&e/r#he on linnaeus.

) !an you summariJe the differences etween sym olic and hard links and differentiate etween using links and simply duplicating a file?
Ans $

4ard links.
The ln command is used to create multiple lin%s for one file. /or example$ let's say that you have a file called "oo in a directory. 6sing ls *i$ you can loo% at the inode number for this file.

=ere$ "oo has an inode number of 22@A2 in the file system. You can create another lin% to "oo$ named bar$ as follows> 8ith ls *i$ you see that the two files have the same inode.

.ow$ specifying either "oo or bar will access the same file. )f you ma%e changes to "oo$ those changes appear in bar as well. /or all purposes$ "oo and bar are the same file.


These lin%s are %nown as hard lin%s because they create a direct lin% to an inode. .ote that you can hard*lin% files only when they're on the same file systemD symbolic lin%s (see below don't have this restriction. 8hen you delete a file with r&$ you are actually only deleting one lin% to a file. )f you use the command then only the lin% named "oo is deleted$ bar will still exist. 3 file is only truly deleted on the system when it has no lin%s to it. 6sually$ files have only one lin%$ so using the r& command deletes the file. =owever$ if a file has multiple lin%s to it$ using r& will delete only a single lin%D in order to delete the file$ you must delete all lin%s to the file. The command ls *l displays the number of lin%s to a file (among other information .

The second column in the listing$ ??2''$ specifies the number of lin%s to the file. 3s it turns out$ a directory is actually 2ust a file containing information about lin%*to*inode associations. 3lso$ every directory contains at least two hard lin%s> ??.'' (a lin% pointing to itself $ and ??..'' (a lin% pointing to the parent directory . The root directory (/ ??..'' lin% 2ust points bac% to /. ()n other words$ the parent of the root directory is the root directory itself.

+ym olic links.

;ymbolic lin%s$ or s# lin%s$ are another type of lin%$ which are different from hard lin%s. 3 symbolic lin% lets you give a file another name$ but doesn't lin% the file by inode. The command ln *s creates a symbolic lin% to a file. /or example$ if you use the command you will create a symbolic lin% named bar that points to the file "oo. )f you use ls *i$ you'll see that the two files have different inodes$ indeed.

=owever$ using ls *l$ we see that the file bar is a symlin% pointing to "oo.

The file permissions on a symbolic lin% are not used (they always appear as r# r# r# . )nstead$ the permissions on the symbolic lin% are determined by the permissions on the target of the symbolic lin% (in our example$ the file "oo . /unctionally$ hard lin%s and symbolic lin%s are similar$ but there are differences. /or one thing$ you can create a symbolic lin% to a file that doesn't existD the same is not true for hard lin%s. ;ymbolic lin%s are processed by the %ernel differently than are hard lin%s$ which is 2ust a technical difference but sometimes

an important one. ;ymbolic lin%s are helpful because they identify the file they point toD with hard lin%s$ there is no easy way to determine which files are lin%ed to the same inode.

'ifference etween using links and simply duplicating a file :

)f you change the content for both the original file or the hardlin%$ the content is changed in the original file (thus changed in the hardlin% . if you change the content in a copied file$ the original file doesn't change its content. 2ust the file you decided to edit. Code>
*bash*O.003 echo test :: orig."ile *bash*O.003 cat orig."ile test *bash*O.003 ln orig."ile hardlin'."ile *bash*O.003 cat orig."ile test *bash*O.003 cat hardlin'."ile test

both files have same content Code>

*bash*O.003 echo hard test :: hardlin'."ile *bash*O.003 cat hardlin'."ile test hard test *bash*O.003 cat orig."ile test hard test

edit hardlin%.file and all content changes


*bash*O.003 c! orig."ile co!ied."ile *bash*O.003 cat co!ied."ile test hard test *bash*O.003 echo co!$ test :: co!ied."ile *bash*O.003 cat co!ied."ile test hard test co!$ test *bash*O.003 cat orig."ile test hard test *bash*O.003 cat hardlin'."ile test hard test

change to copied file doesn't show same with original file but hardlin% and orig file show same content.