http://www.devbistro.com/tech-interview-questions/Unix.jsp

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html lang="en" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <link rel="stylesheet" type="text/css" href="/common.css" />
    <title>
      Unix Interview Questions and Jobs 
    </title>
    </head>
  <body>
    <div class="outer-box notpadded">
	<div class="top-box">
<a href="/index.jsp"><img class="logo" src="/images/db.gif" alt="devBistro logo"/></a></div>
<div id="menu">
<ul>
<li><a href="http://www.devbistro.com/jobs" title="browse tech jobs">search jobs</a></li>
<li><a href="http://www.devbistro.com/resumes" title="browse tech resumes">search resumes</a></li>
<li><a href="http://www.devbistro.com/articles/" title="browse tech articles">tech articles</a></li>
<li><a href="http://www.devbistro.com/tech-interview-questions/" title="tech interview questions">tech interviews</a></li>
<li class="withbg"><a href="http://www.devbistro.com/job-seekers.jsp" title="manage your resume and more">job seekers</a></li>
<li class="withbg"><a href="http://www.devbistro.com/employers.jsp" title="manage your jobs, search resumes">employers</a></li>
</ul>
</div>	
<div id="leftsidebar">
<script language="JavaScript">
<!--
function google_ad_request_done(google_ads) { var i;
document.write('<br/>');

// Display each ad in turn
for(i = 0; i < 11; ++i) { document.write('<div class="googleAdItem"><a class="googleTitleLink" href=' +
google_ads[i].url +'>' + '<b>' + google_ads[i].line1 + '</b><br/><a class="googleTextLink" href=' + google_ads[i].url +'>' + google_ads[i].line2 + ' ' + google_ads[i].line3 + '</a></div>'); } }

// -->
</script>

<script type="text/javascript"><!--
google_ad_client = "pub-4488293523066848";
google_ad_width = 728;
google_ad_height = 90;
google_ad_format = "728x90_as";
google_ad_output = "js";
google_alternate_ad_url = "http://www.devbistro.com/firefox.html"
google_ad_channel = "2563368646";

//--></script> <script type="text/javascript"
src=" http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>

<script language="JavaScript">
<!--
document.write('<span style="color:#333333;font-size:.9em">Ads by Google</span>');
// -->
</script>

</div>
      <div class="content withleftsidebar grey-link">
        <h1>
        	Unix/Linux Interview Questions 
        </h1>
<p>
<script type="text/javascript"><!--
google_ad_client = "pub-4488293523066848";

google_ad_width = 200;
google_ad_height = 90;
google_ad_format = "200x90_0ads_al";

google_color_border = "FFFFFF";
google_color_bg = "FFFFFF";
google_color_link = "000000";

google_alternate_ad_url = "http://www.devbistro.com/cleardot.html"
google_ad_channel ="4576990497";

//--></script>
<script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</p>
	<a name="top"></a>
<h2>Linux admin interview questions</h2>
			<ol>

<li>How do you take a single line of input from the user in a shell script?</li>
	<li>Write a script to convert all DOS style backslashes to UNIX style slashes in a list of files.</li>
	<li>Write a regular expression (or sed script) to replace all occurrences of the letter &#8216;f&#8217;, followed by any number of characters, followed by the letter &#8216;a&#8217;, followed by one or more numeric characters, followed by the letter &#8216;n&#8217;, and replace what&#8217;s found with the string &#8220;UNIX&#8221;.</li>

	<li>Write a script to list all the differences between two directories.</li>
	<li>Write a program in any language you choose, to reverse a file.</li>
	<li>What are the fields of the password file?</li>
	<li>What does a plus at the beginning of a line in the password file signify?</li>
	<li>Using the man pages, find the correct ioctl to send console output to an arbitrary pty.</li>
	<li>What is an MX record?</li>

	<li>What is the prom command on a Sun that shows the SCSI devices?</li>
	<li>What is the factory default SCSI target for /dev/sd0?</li>
	<li>Where is that value controlled?</li>
	<li>What happens to a child process that dies and has no parent process to wait for it and what&#8217;s bad about this?</li>
	<li>What&#8217;s wrong with sendmail? What would you fix?</li>

	<li>What command do you run to check file system consistency?</li>
	<li>What&#8217;s wrong with running shutdown on a network?</li>
	<li>What can be wrong with setuid scripts?</li>
	<li>What value does spawn return?</li>
	<li>Write a script to send mail from three other machines on the network to root at the machine you&#8217;re on. Use a &#8216;here doc&#8217;, but include in the mail message the name of the machine the mail is sent from and the disk utilization statistics on each machine?</li>

	<li>Why can&#8217;t root just cd to someone&#8217;s home directory and run a program called a.out sitting there by typing &#8220;a.out&#8221;, and why is this good?</li>
	<li>What is the difference between UDP and TCP?</li>
	<li>What is DNS?</li>
	<li>What does nslookup do?</li>
	<li>How do you create a swapfile?</li>

	<li>How would you check the route table on a workstation/server?</li>
	<li>How do you find which ypmaster you are bound to?</li>
	<li>How do you fix a problem where a printer will cutoff anything over 1MB?</li>
	<li>What is the largest file system size in solaris? SunOS?</li>
	<li>What are the different RAID levels?</li>
</ol>
<br/><a href="#top">^Back to Top</a><br/>
<h2>
Interview questions for Linux admin
</h2>
			<ol>

<li>Advantages/disadvantages of script vs compiled program.</li>
	<li>Name a replacement for PHP/Perl/MySQL/Linux/Apache and show main differences.</li>
	<li>Why have you choosen such a combination of products?</li>
	<li>Differences between two last MySQL versions. Which one would you choose and when/why?</li>
	<li>Main differences between Apache 1.x and 2.x. Why is 2.x not so popular? Which one would you choose and when/why?</li>
	<li>Which Linux distros do you have experience with?</li>

	<li>Which distro you prefer? Why?</li>
	<li>Which tool would you use to update Debian / Slackware / RedHat / Mandrake / SuSE ?</li>
	<li>You&#8217;re asked to write an Apache module. What would you do?</li>
	<li>Which tool do you prefer for Apache log reports?</li>
	<li>Your portfolio. (even a PHP guest book may work well)</li>
	<li>What does &#8216;route&#8217; command do?</li>

	<li>Differences between ipchains and iptables.</li>
	<li>What&#8217;s eth0, ppp0, wlan0, ttyS0, etc.</li>
	<li>What are different directories in <b>/</b> for?</li>
	<li>Partitioning scheme for new webserver. Why?</li>
	</ol>
<br/><a href="#top">^Back to Top</a><br/>
<p>
<a href="http://www.techinterviews.com">Read more at TechInterviews.com</a>
</p>

<h2>Unix/Linux programming interview questions</h2>
			<p><b>Question 1: What is the major advantage of a hash table? (Asked by Silicon Magic Corp. people) </b></p>

	<p>Answer: The major advantage of a hash table is its speed. Because the hash function is to take a range of key values and transform them into index values in such a way that the key values are distributed randomly across all the indices of a hash table.</p>
<p><b>Question 2: What are the techniques that you use to handle the collisions in hash tables?(Asked by Silicon Magic Corp. people)</b></p>
	<p>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 consist of a linked list. All data items hashing to a given array index are inserted in that list.</p>
	<p><b>Question 3: In Unix OS, what is the file server? (Asked by Silicon Magic Corp. people) </b></p>
	<p>Answer: The file server is a machine that shares its disk storage and files with other machines on the network.</p>
	</p>

	<p><b>Question 4: What is NFS? What is its job?(Asked by Silicon Magic Corp. people) </b></p>
	<p>Answer: NFS stands for Network File System. NFS enables filesystems physically residing on one computer system to be used by other computers in the network, appearing to users on the remote host as just another local disk.</p>
	</p>
	<p><b>Question 5: What is CVS? List some useful CVS commands.(Asked by Silicon Magic Corp.people) </b></p>
	<p>Anser: CVS is Concurrent Version System. It is the front end to the RCS revision control system which extends the notion of revision control from a collection of files in a single directory to a hierarchical collection of directories consisting of revision controlled files. These directories and files can be combined together to form a software release. <br />There are some useful commands that are being used very often. They are </p>
	<p>cvs checkout <br />cvs update <br />cvs add <br />cvs remove <br />cvs commit </p>
<br/><a href="#top">^Back to Top</a><br/>
<h2>Unix/Linux administration interview questions</h2>
			<p><b>What is LILO?</b></p>

	<p>LILO stands for Linux boot loader. It will load the MBR, master boot record, into the memory, and tell the system which partition and hard drive to boot from.</p>
	<p><b>What is the main advantage of creating links to a file instead of copies of the file?</b></p>
	<p>A: The main advantage is not really that it saves disk space (though it does that too) but, rather, that a change of permissions on the file is applied to all the link access points. The link will show permissions of lrwxrwxrwx but that is for the link itself and not the access to the file to which the link points. Thus if you want to change the permissions for a command, such as su, you only have to do it on the original. With copies you have to find all of the copies and change permission on each of the copies.</p>
	<p><b>Write a command to find all of the files which have been accessed within the last 30 days.</b></p>
	<blockquote><p>find / -type f -atime -30 &gt; December.files</p></blockquote>

	<p>This command will find all the files under root, which is &#8216;/&#8217;, with file type is file. &#8216;-atime -30&#8242; will give all the files accessed less than 30 days ago. And the output will put into a file call December.files.</p>
	<p><b>What is the most graceful way to get to run level single user mode?</b></p>
	<p>A: The most graceful way is to use the command init s.<br />If you want to shut everything down before going to single user mode then do init 0 first and from the ok prompt do a boot -s.</p>
	<p><b>What does the following command line produce? Explain each aspect of this line.</b></p>

	<blockquote><p>$ (date ; ps -ef | awk &#8216;{print $1}&#8217; | sort | uniq | wc -l ) &gt;&gt; Activity.log </p></blockquote>
	<p>A: First let&#8217;s dissect the line: The date gives the date and time as the first command of the line, this is followed by the a list of all running processes in long form with UIDs listed first, this is the ps -ef. These are fed into the awk which filters out all but the UIDs; these UIDs are piped into sort for no discernible reason and then onto uniq (now we see the reason for the sort - uniq only works on sorted data - if the list is A, B, A, then A, B, A will be the output of uniq, but if it&#8217;s A, A, B then A, B is the output) which produces only one copy of each UID.
<p>These UIDs are fed into wc -l which counts the lines - in this case the number of distinct UIDs running processes on the system. Finally the results of these two commands, the date and the wc -l, are appended to the file &quot;Activity.log&quot;. Now to answer the question as to what this command line produces. This writes the date and time into the file Activity.log together with the number of distinct users who have processes running on the system at that time. If the file already exists, then these items are appended to the file, otherwise the file is created.</p>
<br/><a href="#top">^Back to Top</a><br/>
<p>
<a href="http://www.techinterviews.com">Read more at TechInterviews.com</a>
</p>
<h2>Solaris interview questions</h2>
			<ol>

	<li><b>List the files in current directory sorted by size ? -</b> ls -l | grep ^- | sort -nr </li>
	<li><b>List the hidden files in current directory ? - </b>ls -a1 | grep &quot;^\.&quot;</li>
	<li><b>Delete blank lines in a file ? - </b>cat sample.txt | grep -v &#8216;^$&#8217; &gt; new_sample.txt</li>

	<li><b>Search for a sample string in particular files ? - </b>grep .Debug. *.confHere <b>grep</b> uses the string .Debug. to search in all files with extension..conf. under current directory.</li>
	<li><b>Display the last newly appending lines of a file during appendingdata to the same file by some processes ? - </b>tail .f Debug.logHere <b>tail</b> shows the newly appended data into Debug.log by some processes/user.</li>
	<li><b>Display the Disk Usage of file sizes under each directory in currentDirectory ? - </b>du -k * | sort .nr (or) du .k . | sort -nr</li>

	<li><b>Change to a directory, which is having very long name ? - </b>cd CDMA_3X_GEN*Here original directory name is . .CDMA_3X_GENERATION_DATA..</li>
	<li><b>Display the all files recursively with path under current directory ? - </b>find . -depth -print</li>
	<li><b>Set the Display automatically for the current new user ? - </b>export DISPLAY=`eval &#8216;who am i | cut -d&quot;(&quot; -f2 | cut -d&quot;)&quot; -f1&#8242;`Here in above command, see single quote, double quote, grave ascent is used. Observe carefully.</li>

	<li><b>Display the processes, which are running under yourusername ? - </b>ps .aef | grep MaheshvjHere, Maheshvj is the username.</li>
	<li><b>List some Hot Keys for bash shell ? - Ctrl+l . </b>Clears the Screen.<b> Ctrl+r . </b>Does a search in previously given commands in shell.<b> Ctrl+u </b>- Clears the typing before the hotkey.<b> Ctrl+a </b>. Places cursor at the beginning of the command at shell.<b> Ctrl+e </b>. Places cursor at the end of the command at shell.<b> Ctrl+d</b> . Kills the shell.<b> Ctrl+z . </b>Places the currently running process into background.</li>

	<li><b>&nbsp;Display the files in the directory by file size ? - </b>ls .ltr | sort .nr .k 5</li>
	<li><b>How to save man pages to a file ? - </b>man &lt;command&gt; | col .b &gt; &lt;output-file&gt;Example : man top | col .b &gt; top_help.txt</li>
	<li><b>How to know the date &amp; time for . when script is executed ? - </b>Add the following script line in shell script.eval echo &quot;Script is executed at `date`&quot; &gt;&gt; timeinfo.infHere, .timeinfo.inf. contains date &amp; time details ie., when script is executed and history related to execution.</li>

	<li><b>How do you find out drive statistics ? - </b>iostat -E</li>
	<li><b>Display disk usage in Kilobytes ? - </b>du -k</li>
	<li><b>Display top ten largest files/directories ? - </b>du -sk * | sort -nr | head</li>
	<li><b>How much space is used for users in kilobytes ? - </b>quot -af</li>
	<li><b>How to create null file ? - </b>cat /dev/null &gt; filename1</li>

	<li><b>Access common commands quicker ? - </b>ps -ef | grep -i $@</li>
	<li><b>Display the page size of memory ? - </b>pagesize -a</li>
	<li><b>Display Ethernet Address arp table ? - </b>arp -a</li>
	<li><b>Display the no.of active established connections to localhost ? - </b>netstat -a | grep EST</li>
	<li><b>Display the state of interfaces used for TCP/IP traffice ? - </b>netstat -i</li>

	<li><b>Display the parent/child tree of a process ? - </b>ptree &lt;pid&gt; <i>Example:</i> ptree 1267</li>
	<li><b>Show the working directory of a process ? - </b>pwdx &lt;pid&gt; <i>Example:</i> pwdx 1267</li>

	<li><b>Display the processes current open files ? - </b>pfiles &lt;pid&gt; <i>Example:</i> pfiles 1267</li>
	<li><b>Display the inter-process communication facility status ? - </b>ipcs</li>
	<li><b>Display the top most process utilizing most CPU ? - </b>top .b 1</li>

	<li><b>Alternative for top command ? - </b>prstat -a</li>
	</ol>
<br/>
<b><a href="http://www.techinterviews.com">Read more at TechInterviews.com</a></b>
<p>
<br/>
<h2>Looking for Unix/Linux jobs?</h2>
</p>
<ul>
<li class="sq-gr"> <a href="http://www.devbistro.com/jobs/keywords/Linux">Browse Linux jobs &#187;</a></li> 
<li class="sq-gr"> <a href="http://www.devbistro.com/jobs/keywords/Linux/telecommute">Browse telecommute Linux jobs &#187;</a></li> 
<li class="sq-gr"> <a href="http://www.devbistro.com/job-seekers.jsp#job-alerts">Get Linux jobs by email &#187;</a></li> 
</ul>
</div>
      <div class="bottom-box link-footer">
	<!-- google_ad_section_start(weight=ignore) -->
&copy;2003-2007 Dev Bistro 
&#183;
<a href="/about.jsp">About Us</a> 
&#183;
 <a href="/privacyPolicy.jsp">Privacy Policy</a> 
<!-- google_ad_section_end(weight=ignore) -->
     
      </div>
    </div>
</body>
</html>
