Friday, July 25, 2014

Linux/Unix Interview question set 1

1. Write command to list all the links from a directory? In this UNIX command interview questions interviewer is generally checking whether user knows basic use of "ls" "grep" and regular expression etc You can write command like:
ls -lrt | grep "^l"

You can read on ls and grep. lrt options give l for long view, r for reverse sort and t for time wise sort. grep will find anything starting with l.

2. Create a read-only file in your home directory? This is a simple UNIX command interview questions where you need to create a file and change its parameter to read-only by using chmod command you can also change your umask to create read only file.
touch file
chmod 400 file

read more about file and directory permission in unix and linux here.

 3. How will you find which operating system your system is running on in UNIX?
 By using command "uname -a" in UNIX

 4. How will you run a process in background? How will you bring that into foreground and how will you kill that process?

For running a process in background use "&" in command line.
For bringing it back in foreground use command "fg jobid" and for getting job id you use command "jobs", for killing that process find PID and use kill -9 PID command.
This is indeed a good Unix Command interview questions because many of programmer not familiar with background process in UNIX. More on process here.

 5. How do you know if a remote host is alive or not?
You can check these by using either ping or telnet command in UNIX. This question is most asked in various Unix command Interview because its most basic networking test anybody wants to do it. More on networks here.

6. How do you see command line history in UNIX?
Very useful indeed, use history command along with grep command in unix to find any relevant command you have already executed. Purpose of this Unix Command Interview Questions is probably to check how familiar candidate is from available tools in UNIX operation system.

 7. How do you copy file from one host to other?
Many options but you can say by using "scp" command. You can also use rsync command to answer this UNIX interview question or even sftp would be ok.  

8. How do you find which process is taking how much CPU?
By using "top" command in UNIX, there could be multiple follow-up UNIX command interview questions based upon response of this because “TOP” command has various interactive options to sort result based upon various parameter.  

9. How do you check how much space left in current drive ?
By using "df" command in UNIX. For example "df -h ." will list how full your current drive is. This is part of anyone day to day activity so I think this Unix Interview question will be to check anyone who claims to working in UNIX but not really working on it.  

10. What is the difference between Swapping and Paging? 
Swapping: Whole process is moved from the swap device to the main memory for execution. Process size must be less than or equal to the available main memory. It is easier to implementation and overhead to the system. Swapping systems does not handle the memory more flexibly as compared to the paging systems.
Paging: Only the required memory pages are moved to main memory from the swap device for execution. Process size does not matter. Gives the concept of the virtual memory. It provides greater flexibility in mapping the virtual address space into the physical memory of the machine. Allows more number of processes to fit in the main memory simultaneously. Allows the greater process size than the available physical memory. Demand paging systems handle the memory more flexibly.




Post a Comment