Unix commands : Top 10 frequently asked interview questions

In most of banks, the unix or linux is prefered application hosting platform, compare to the windows. It is always added advantage for candidate to be familiar with unix commands. These are basic unix commands which are sometime asked to candidate for checking his\her unix skills.  These questions are mainly related to log search, find commands and unix processes. These commands are very handy if we are investigating any issue in production\uat. As application developer we must have came across these unix commands. Mostly questions are not asked in depth and they just confirm your familiarity with unix commands. These are most frequently asked unix commands in interview.


1) How to find hidden files in current directory?

   $ ls -lrta

2) How to find current running processes in unix server?

  $ ps -ef

and if we want to find specific process we can use 'grep' with pipe
  $ ps -ef | grep -i 'application'

3) How to find process which is taking maximum memory in server?
  $ top
  top command tell us about cpu usage , process id and other details. below is output of top command



4) How to find Exception in log files available in current directory and how to find number of occurrence?
   
   $ grep 'Exception' log1.txt | wc -l

5) find all files in current and subdirectories which contains 'log' name?

   $ find . -name 'log'
 

6) How do you access command line arguments from within a shell script?

Arguments passed from the command line to a shell script can be accessed within the shell script by using a $ (dollar sign) immediately followed with the argument's numeric position on the command line.

7) How to tails last 200 lines of any log fine?
 
    $ tail -200f filename.txt

8) How to find remaining disk space in unix\linux server?

    $ df -kl

df -kl
Filesystem   1024-blocks      Used Available Capacity  iused    ifree %iused  Mounted on

/dev/disk0s2   244277768 153679844  90341924    63% 38483959 22585481   63%   /

9) How to make any script file executable?
    $chmod 755 *.sh

10) How to kill process in unix server?
    $ kill -9 #pid
these #pid can be found using ps -ef command.

BASIC Unix Command List
  • ls --- lists your files
    ls -l --- lists your files in 'long format', which contains lots of useful information, e.g. the exact size of the file, who owns the file and who has the right to look at it, and when it was last modified.
    ls -a --- lists all files, including the ones whose filenames begin in a dot, which you do not always want to see.
    There are many more options, for example to list files by size, by date, recursively etc.
  • more filename --- shows the first part of a file, just as much as will fit on one screen. Just hit the space bar to see more or q to quit. You can use /pattern to search for a pattern.
  • mv filename1 filename2 --- moves a file (i.e. gives it a different name, or moves it into a different directory (see below)
  • cp filename1 filename2 --- copies a file
  • rm filename --- removes a file. It is wise to use the option rm -i, which will ask you for confirmation before actually deleting anything. You can make this your default by making an alias in your .cshrc file.
  • diff filename1 filename2 --- compares files, and shows where they differ
  • wc filename --- tells you how many lines, words, and characters there are in a file
  • chmod options filename --- lets you change the read, write, and execute permissions on your files. The default is that only you can look at them and change them, but you may sometimes want to change these permissions. For example, chmod o+r filename will make the file readable for everyone, and chmod o-r filename will make it unreadable for others again. Note that for someone to be able to actually look at the file the directories it is in need to be at least executable. 
  • File Compression
    • gzip filename --- compresses files, so that they take up much less space. Usually text files compress to about half their original size, but it depends very much on the size of the file and the nature of the contents. There are other tools for this purpose, too (e.g. compress), but gzip usually gives the highest compression rate. Gzip produces files with the ending '.gz' appended to the original filename.
    • gunzip filename --- uncompresses files compressed by gzip.
    • gzcat filename --- lets you look at a gzipped file without actually having to gunzip it (same as gunzip -c). You can even print it directly, using gzcat filename | lpr
  • printing
    • lpr filename --- print. Use the -P option to specify the printer name if you want to use a printer other than your default printer. For example, if you want to print double-sided, use 'lpr -Pvalkyr-d', or if you're at CSLI, you may want to use 'lpr -Pcord115-d'. See 'help printers' for more information about printers and their locations.

Directories

Directories, like folders on a Macintosh, are used to group files together in a hierarchical structure.
  • mkdir dirname --- make a new directory
  • cd dirname --- change directory. You basically 'go' to another directory, and you will see the files in that directory when you do 'ls'. You always start out in your 'home directory', and you can get back there by typing 'cd' without arguments. 'cd ..' will get you one level up from your current position. You don't have to walk along step by step - you can make big leaps or avoid walking around by specifying pathnames.
  • pwd --- tells you where you currently are.


  • We are covering here -'Java garbage collection interview questions' or 'Java memory interview questions' in d...
  • Java util.collections is one of the most important package in java and the important of this package can be understand by...
  • Java Concurrency interview question - In year 2004 when technology gurus said innovation in Java is gone down and Sun Microsystems [Now Or...
  • 'Java investment bank interview' generally contains 'Java Design Pattern' questions. If you want to be a professional Java ...
  • 37 comments:

    1. Nice questions..This might be useful questions to you ...164 Core Java Interview Questions.

      ReplyDelete
    2. Excellent all questions are very use full and important one Thank you.

      ReplyDelete
    3. Latest Govt Bank Jobs Recruitment Notification 2016

      Thanks for writing such a good article, I stumbled onto your website and read a few articles. I like your way of writing......................

      ReplyDelete
    4. Most important command for developers. Every Developers must know these command

      http://www.javaproficiency.com/2015/04/basic-unix-commands-for-java-developers.html

      ReplyDelete
    5. Hi Nice Blog

      Before facing job interview we should prepare for it and best thing is that we should know type of question and frequently asked questions and after doing such small thing we can grab that job.

      ReplyDelete
    6. Your website is wonderful, let alone the content material
      interview preparation online

      ReplyDelete
    7. This information is stunning. I really inspired with your post writing style & how continuously you describe this topic. After reading your post, I feel very happy about it and I love learning more about this topic. Please keep update like this excellent post.
      Engineering Colleges, ECE Engineering Colleges in Chennai

      ReplyDelete
    8. This comment has been removed by the author.

      ReplyDelete
    9. Helpful article.. This article really useful to cracking the unix interviews easily.. thank you for sharing

      hadoop training institute in chennai | big data training institute in chennai

      ReplyDelete
    10. Very useful blog for java and Linux learners and this blog is used crack the interviews easily...
      Interior Designers in Chennai
      Interior Decorators in Chennai
      Interior Design in Chennai

      ReplyDelete
    11. Really something Grate in this article Thanks for sharing this. We are providing Online Training Classes. After reading this slightly I am changed my way of introduction about my training to people.

      Best Linux training in Noida
      Linux Training Institute in Noida
      Shell Scripting Training Institute in Noida

      ReplyDelete
    12. Really something Grate in this article Thanks for sharing this. We are providing Online Training Classes. After reading this slightly I am changed my way of introduction about my training to people.

      Best Linux training in Noida
      Linux Training Institute in Noida
      Shell Scripting Training Institute in Noida

      ReplyDelete
    13. Hello Buddy,



      I am shocked, that there is such article exist!! But I really think you did a great job highlighting some of the key Unix commands : Top 10 frequently asked interview questions in the entire space.


      Though the names and filesystem locations of the Unix components have changed substantially across the history of the system.

      Very useful article, if I run into challenges along the way, I will share them here.


      Obrigado,
      Ajeeth Kapoor

      ReplyDelete
    14. Nice and good article.I have suggested to my friends to go through this blog. Thanks for sharing this useful information. If you want to learn Linux course in online, please visit below site.
      Linux Online Training
      linux online course
      Linux Online Training in Hyderabad
      Linux Online Training in Bangalore
      Linux Online Training in Chennai

      ReplyDelete
    15. This comment has been removed by the author.

      ReplyDelete
    16. Thanks for posting this useful information, Keep sharing more posts like this.
      DevOps Online Training

      ReplyDelete
    17. A Computer Science portal for geeks. It contains well written, well thought and well explained computer science and programming articles, quizzes and practice/competitive programming/company interview Questions.
      website: geeksforgeeks.org

      ReplyDelete
    18. A Computer Science portal for geeks. It contains well written, well thought and well
      explained computer science and programming articles, quizzes and practice/competitive
      programming/company interview Questions.
      website: geeksforgeeks.org

      ReplyDelete
    19. A Computer Science portal for geeks. It contains well written, well thought and well
      explained computer science and programming articles, quizzes and practice/competitive
      programming/company interview Questions.
      website: geeksforgeeks.org

      ReplyDelete
    20. A Computer Science portal for geeks. It contains well written, well thought and well
      explained computer science and programming articles, quizzes and practice/competitive
      programming/company interview Questions.
      website: geeksforgeeks.org

      ReplyDelete
    21. Actually i found this blog and that is amazing thing I enjoy reading this easy to understand stuff. Keep it up.
      Interior Designers In Chennai
      <a

      ReplyDelete
    22. This is a nice article here with some useful tips for those who are not used-to comment that frequently. Thanks for this helpful information I agree with all points you have given to us. I will follow all of them.
      Office interior designers in chennai
      living room interior designers in chennai
      False ceiling interiors designers in chennai

      ReplyDelete
    23. Thank you for taking the time to provide us with your valuable information. We strive to provide our candidates with excellent care and we take your comments to heart.As always, we appreciate your confidence and trust in us
      best digital marketing company
      digital marketing agency in chennai
      digital marketing services
      website design company

      ReplyDelete
    24. It is for the first that I just visited your site and I find it really interesting! Congratulations! please visit for latesetnews

      ReplyDelete
    25. I really enjoyed your blog Thanks for sharing such an informative post.
      Mahaveer Interior Company by Mahaveer Interior Brings Affordable and Modern Interior Designing Solutions in Jajpur Get Expert Advice for Living Rooms, Bathroom and Kitchen.

      https://mahaveerinterior.com/

      ReplyDelete
    26. informative blog, keep posting java course in satara

      ReplyDelete