UNIX Shell Scripting Interview Questions and Answers

UNIX Shell Scripting Interview Questions and Answers
  1. How do you find out what’s your shell? – echo $SHELL
  2. What’s the command to find out today’s date? – date
  3. What’s the command to find out users on the system? – who
  4. How do you find out the current directory you’re in? – pwd
  5. How do you remove a file? – rm
  6. How do you remove a - rm -rf
  7. How do you find out your own username? – whoami
  8. How do you send a mail message to somebody? – mail somebody@wikiconsole.com -s ‘Your subject’ -c ‘cc@wikiconsole.com‘
  9. How do you count words, lines and characters in a file? – wc
  10. How do you search for a string inside a given file? – grep string filename
  11. How do you search for a string inside a directory? – grep string *
  12. How do you search for a string in a directory with the subdirectories recursed? – grep -r string *
  13. What are PIDs? – They are process IDs given to processes. A PID can vary from 0 to 65535.
  14. How do you list currently running process? – ps
  15. How do you stop a process? – kill pid
  16. How do you find out about all running processes? – ps -ag
  17. How do you stop all the processes, except the shell window? – kill 0
  18. How do you fire a process in the background? – ./process-name &
  19. How do you refer to the arguments passed to a shell script? – $1, $2 and so on. $0 is your script name.
  20. What’s the conditional statement in shell scripting? – if {condition} then … fi
  21. How do you do number comparison in shell scripts? – -eq, -ne, -lt, -le, -gt, -ge
  22. How do you test for file properties in shell scripts? – -s filename tells you if the file is not empty, -f filename tells you whether the argument is a file, and not a directory, -d filename tests if the argument is a directory, and not a file, -w filename tests for writeability, -r filename tests for readability, -x filename tests for executability
  23. How do you do Boolean logic operators in shell scripting? – ! tests for logical not, -a tests for logical and, and -o tests for logical or.
  24. How do you find out the number of arguments passed to the shell script? – $#
  25. What’s a way to do multilevel if-else’s in shell scripting? – if {condition} then {statement} elif {condition} {statement} fi
  26. How do you write a for loop in shell? – for {variable name} in {list} do {statement} done
  27. How do you write a while loop in shell? – while {condition} do {statement} done
  28. How does a case statement look in shell scripts? – case {variable} in {possible-value-1}) {statement};; {possible-value-2}) {statement};; esac
  29. How do you read keyboard input in shell scripts? – read {variable-name}
  30. How do you define a function in a shell script? – function-name() { #some code here return }
  31. How does getopts command work? – The parameters to your script can be passed as -n 15 -x 20. Inside the script, you can iterate through the getopts array as while getopts n:x option, and the variable $option contains the value of the entered option.

Solaris Interview Questions And Answers

Solaris Interview Questions And Answers

  • List the files in current directory sorted by size ? - ls -l | grep ^- | sort -nr
  • List the hidden files in current directory ? – ls -a1 | grep “^\.”
  • Delete blank lines in a file ? – cat sample.txt | grep -v ‘^$’ > new_sample.txt
  • Search for a sample string in particular files ? – grep “Debug” *.confHere grep uses the string “Debug” to search in all files with extension“.conf” under current directory.
  • Display the last newly appending lines of a file during appendingdata to the same file by some processes ? – tail –f Debug.logHere tail shows the newly appended data into Debug.log by some processes/user.
  • Display the Disk Usage of file sizes under each directory in currentDirectory ? – du -k * | sort –nr (or) du –k . | sort -nr
  • Change to a directory, which is having very long name ? – cd CDMA_3X_GEN*Here original directory name is – “CDMA_3X_GENERATION_DATA”.
  • Display the all files recursively with path under current directory ? – find . -depth -print
  • Set the Display automatically for the current new user ? – export DISPLAY=`eval ‘who am i | cut -d”(” -f2 | cut -d”)” -f1′`Here in above command, see single quote, double quote, grave ascent is used. Observe carefully.
  • Display the processes, which are running under yourusername ? – ps –aef | grep MaheshvjHere, Maheshvj is the username.
  • List some Hot Keys for bash shell ? – Ctrl+l – Clears the Screen. Ctrl+r – Does a search in previously given commands in shell. Ctrl+u - Clears the typing before the hotkey. Ctrl+a – Places cursor at the beginning of the command at shell. Ctrl+e – Places cursor at the end of the command at shell. Ctrl+d – Kills the shell. Ctrl+z – Places the currently running process into background.
  •  Display the files in the directory by file size ? – ls –ltr | sort –nr –k 5
  • How to save man pages to a file ? – man | col –b > Example : man top | col –b > top_help.txt
  • How to know the date & time for – when script is executed ? – Add the following script line in shell script.eval echo “Script is executed at `date`” >> timeinfo.infHere, “timeinfo.inf” contains date & time details ie., when script is executed and history related to execution.
  • How do you find out drive statistics ? – iostat -E
  • Display disk usage in Kilobytes ? – du -k
  • Display top ten largest files/directories ? – du -sk * | sort -nr | head
  • How much space is used for users in kilobytes ? – quot -af
  • How to create null file ? – cat /dev/null > filename1
  • Access common commands quicker ? – ps -ef | grep -i $@
  • Display the page size of memory ? – pagesize -a
  • Display Ethernet Address arp table ? – arp -a
  • Display the no.of active established connections to localhost ? – netstat -a | grep EST
  • Display the state of interfaces used for TCP/IP traffice ? – netstat -i
  • Display the parent/child tree of a process ? – ptree  Example: ptree 1267
  • Show the working directory of a process ? – pwdx  Example: pwdx 1267
  • Display the processes current open files ? – pfiles  Example: pfiles 1267
  • Display the inter-process communication facility status ? – ipcs
  • Display the top most process utilizing most CPU ? – top –b 1
  • Alternative for top command ? – prstat –a

  • Basic Linux Interview Questions And Answers

    Basic Linux Interview Questions And Answers


    1. You need to see the last fifteen lines of the files dog, cat and horse. What command should you use?tail -15 dog cat horse 
      The tail utility displays the end of a file. The -15 tells tail to display the last fifteen lines of each specified file.
    2. Who owns the data dictionary? 
      The SYS user owns the data dictionary. The SYS and SYSTEM users are created when the database is created.
    3. You routinely compress old log files. You now need to examine a log from two months ago. In order to view its contents without first having to decompress it, use the _________ utility. 
      zcat 
      The zcat utility allows you to examine the contents of a compressed file much the same way that cat displays a file.
    4. You suspect that you have two commands with the same name as the command is not producing the expected results. What command can you use to determine the location of the command being run? 
      which 
      The which command searches your path until it finds a command that matches the command you are looking for and displays its full path.
    5. You locate a command in the /bin directory but do not know what it does. What command can you use to determine its purpose. 
      whatis 
      The whatis command displays a summary line from the man page for the specified command.
    6. You wish to create a link to the /data directory in bob’s home directory so you issue the command ln /data /home/bob/datalink but the command fails. What option should you use in this command line to be successful. 
      Use the -F option 
      In order to create a link to a directory you must use the -F option.
    7. When you issue the command ls -l, the first character of the resulting display represents the file’s ___________. 
      type 
      The first character of the permission block designates the type of file that is being displayed.
    8. What utility can you use to show a dynamic listing of running processes? __________ 
      top 
      The top utility shows a listing of all running processes that is dynamically updated.
    9. Where is standard output usually directed? 
      to the screen or display 
      By default, your shell directs standard output to your screen or display.
    10. You wish to restore the file memo.ben which was backed up in the tarfile MyBackup.tar. What command should you type? 
      tar xf MyBackup.tar memo.ben 
      This command uses the x switch to extract a file. Here the file memo.ben will be restored from the tarfile MyBackup.tar.
    11. You need to view the contents of the tarfile called MyBackup.tar. What command would you use? 
      tar tf MyBackup.tar 
      The t switch tells tar to display the contents and the f modifier specifies which file to examine.
    12. You want to create a compressed backup of the users’ home directories. What utility should you use? 
      tar 
      You can use the z modifier with tar to compress your archive at the same time as creating it.
    13. What daemon is responsible for tracking events on your system? 
      syslogd 
      The syslogd daemon is responsible for tracking system information and saving it to specified log files.
    14. You have a file called phonenos that is almost 4,000 lines long. What text filter can you use to split it into four pieces each 1,000 lines long? 
      split 
      The split text filter will divide files into equally sized pieces. The default length of each piece is 1,000 lines.
    15. You would like to temporarily change your command line editor to be vi. What command should you type to change it? 
      set -o vi 
      The set command is used to assign environment variables. In this case, you are instructing your shell to assign vi as your command line editor. However, once you log off and log back in you will return to the previously defined command line editor.
    16. What account is created when you install Linux? 
      root 
      Whenever you install Linux, only one user account is created. This is the superuser account also known as root.
    17. What command should you use to check the number of files and disk space used and each user’s defined quotas? 
      repquota 
      The repquota command is used to get a report on the status of the quotas you have set including the amount of allocated space and amount of used space.

    Error 1001. The specified service has been marked for deletion

    Error 1001. The specified service has been marked for deletion

    • If you are creating Windows Services you may run into this annoying little error from time to time,
                  Error 1001. The specified service has been marked for deletion
    • At first I used to restart my machine to get rid of it, but there is a (much) simpler way.
    • Simply closing the Services Manager (services.msc or the mmc.exe tool) will solve it

    Manual Testing Interview Questions and Answers| Testing Interview Questions

    Manual Testing Interview Questions and Answers| Testing Interview Questions
    1. What are the components of an SRS?
    An SRS contains the following basic components:
    Introduction
    Overall Description
    External Interface Requirements
    System Requirements
    System Features
    2. What is the difference between a test plan and a QA plan?
    A test plan lays out what is to be done to test the product and includes how quality control will work to identify errors and defects.  A QA plan on the other hand is more concerned with prevention of errors and defects rather than testing and fixing them.
    3. How do you test an application if the requirements are not available?
    If requirements documentation is not available for an application, a test plan can be written based on assumptions made about the application.  Assumptions that are made should be well documented in the test plan.
    4. What is a peer review?
    Peer reviews are reviews conducted among people that work on the same team.  For example, a test case that was written by one QA engineer may be reviewed by a developer and/or another QA engineer.
    5. How can you tell when enough test cases have been created to adequately test a system or module?
    You can tell that enough test cases have been created when there is at least one test case to cover every requirement.  This ensures that all designed features of the application are being tested.
    6. Who approves test cases?
    The approver of test cases varies from one organization to the next. In some organizations, the QA lead may approve the test cases while another approves them as part of peer reviews.
    7. Give an example of what can be done when a bug is found.
    When a bug is found, it is a good idea to run more tests to be sure that the problem witnessed can be clearly detailed. For example, let say a test case fails when Animal=Cat and.  A tester should run more tests to be sure that the same problem doesn’t exist with Animal=dog.  Once the tester is sure of the full scope of the bug can be documented and the bug adequately reported.
    8. Who writes test plans and test cases?
    Test plans are typically written by the quality assurance lead while testers usually write test cases.
    9. Is quality assurance and testing the same?
    Quality assurance and testing is not the same.  Testing is considered to be a subset of QA. QA is should be incorporated throughout the software development life cycle while testing is the phase that occurs after the coding phase.


    Typical Manual Testing Interview Questions:


    10. What is a negative test case?
    Negative test cases are created based on the idea of testing in a destructive manner.  For example, testing what will happen if inappropriate inputs are entered into the application.
    11. If an application is in production, and one module of code is modified, is it necessary to retest just that module or should all of the other modules be tested as well?
    It is a good idea to perform regression testing and to check all of the other modules as well.  At the least, system testing should be performed.
    12. What should be included in a test strategy?
    The test strategy includes a plan for how to test the application and exactly what will be tested (user interface, modules, processes, etc.).  It establishes limits for testing and indicates whether manual or automated testing will be used.
    13. What can be done to develop a test for a system if there are no functional specifications or any system and development documents?
    When there are no functional specifications or system development documents, the tester should familiarize themselves with the product and the code.  It may also be helpful to perform research to find similar products on the market.
    14. What are the functional testing types?
    The following are the types of functional testing:
    Compatibility
    Configuration
    Error handling
    Functionality
    Input domain
    Installation
    Inter-systems
    Recovery
    15. What is the difference between sanity testing and smoke testing?
    When sanity testing is conducted, the product is sent through a preliminary round of testing with the test group in order to check the basic functionality such as button functionality.  Smoke testing, on the other hand is conducted by developers based on the requirements of the client.
    16. Explain random testing.
    Random testing involves checking how the application handles input data that is generated at random. Data types are typically ignored and a random sequence of letter, numbers, and other characters are inputted into the data field.
    17. Define smoke testing.
    Smoke testing is a form of software testing that is not exhaustive and checks only the most crucial components of the software but does not check in more detail.


    Advanced Manual Testing Interview Questions


    18. What steps are involved in sanity testing?
    Sanity testing is very similar to smoke testing. It is the initial testing of a component or application that is done to make sure that it is functioning at the most basic level and it is stable enough to continue more detailed testing.
    19. What is the difference between WinRunner and Rational Robot?
    WinRunner is a functional test tool but Rational Robot is capable of both functional and performance testing. Also, WinRunner has 4 verification points and Rational Robot has 13 verification points.
    20. What is the purpose of the testing process?
    The purpose of the testing process is to verifying that input data produces the anticipated output.

    21. What is the difference between QA and testing?
    The goals of QA are very different from the goals of testing.  The purpose of QA is to prevent errors is the application while the purpose of testing is to find errors. 
    22. What is the difference between Quality Control and Quality Assurance?
    Quality control (QC) and quality assurance (QA) are closely linked but are very different concepts. While QC evaluates a developed product, the purpose of QA is to ensure that the development process is at a level that makes certain that the system or application will meet the requirements.
    23. What is the difference between regression testing and retesting?
    Regression testing is performing tests to ensure that modifications to a module or system do not have a negative effect on previous releases.  Retesting is merely running the same testing again.
    24. Explain the difference between bug severity and bug priority.
    Bug severity refers to the level of impact that the bug has on the application or system while bug priority refers to the level of urgency in the need for a fix.
    25. What is the difference between system testing and integration testing?
    For system testing, the entire system as a whole is checked, whereas for integration testing, the interaction between the individual modules are tested.
    26. Explain the term bug.
    A bug is an error found while running a program. Bug fall into two categories: logical and syntax.

    Senior Tester Interview Questions


    27. Explain the difference between functional and structural testing.
    Functional testing is considered to be behavioral or black box testing in which the tester verifies that the system or application functions according to specification.  Structural testing on the other hand is based on the code or algorithms and is considered to be white box testing.
    28. Define defect density.
    Defect density is the total number of defects per lines of code.
    29. When is a test considered to be successful?
    The purpose of testing is to ensure that the application operates according to the requirements and to discover as many errors and bugs as possible.  This means that tests that cover more functionality and expose more errors are considered to be the most successful.
    30. What good bug tracking systems have you used?
    This is a simple interview question about your experience with bug tracking.  Provide the system/systems that you are most familiar with if any at all.   It would also be good to provide a comparison of the pros and cons of several if you have experience.
    31. In which phase should testing begin – requirements, planning, design, or coding?
    Testing should begin as early as the requirements phase.
    32. Can you test a program and find 100% of the errors?
    It is impossible to fine all errors in an application mostly because there is no way to calculate how many errors exist.  There are many factors involved in such a calculation such as the complexity of the program, the experience of the programmer, and so on.

    33. What is the difference between debugging and testing?
    The main difference between debugging and testing is that debugging is typically conducted by a developer who also fixes errors during the debugging phase.  Testing on the other hand, finds errors rather than fixes them.  When a tester finds a bug, they usually report it so that a developer can fix it.
    34. How should testing be conducted?
    Testing should be conducted based on the technical requirements of the application.
    35. What is considered to be a good test?
    Testing that covers most of the functionality of an object or system is considered to be a good test.
    36. What is the difference between top-down and bottom-up testing?
    Top-Down testing begins with the system and works its way down to the unit level.  Bottom-up testing checks in the opposite direction, unit level to interface to overall system. Both have value but bottom-up testing usually aids in discovering defects earlier in the development cycle, when the cost to fix errors is lower.
    37. Explain how to develop a test plan and a test case.
    A test plan consists of a set of test cases. Test cases are developed based on requirement and design documents for the application or system. Once these documents are thoroughly reviewed, the test cases that will make up the test plan can be created.
    38. What is the role of quality assurance in a product development lifecycle?
    Quality assurance should be involved very early on in the development life cycle so that they can have a better understanding of the system and create sufficient test cases. However, QA should be separated from the development team so that the team is not able to build influence on the QA engineers.
    39. What is the average size of executables that you have created?
    This is a simple interview question about our experience with executables.  If you know the size of any that you’ve created, simply provide this info.
    40. What version of the Oracle are you familiar with?
    This is an interview question about experience.  Simply provide the versions of the software that you have experience with.
    41. How is an SQL query executed in Oracle 8?
    This is an interview question to check your experience with Oracle and you can simply provide the answer “from the command prompt.”  If you do not have Oracle experience, do not pretend and simply state that you have not worked on an Oracle database.
    42. Have you performed tests on the front-end and the back-end?
    This is an interview question in which you should explain whether you performed testing on the GUI or the server portion of previous applications.
    43. What is the most difficult problem you’ve found during testing?
    This is a simple interview question in which you should provide an example.
    44. What were your testing responsibilities at your previous employer?
    This interview question is very likely being asked to verify your knowledge of your resume. Make sure that you know what is on your resume and that it is the truth.
    45. What do you like the most about testing?
    There are several answers that you can give for this question.  Here are a few examples:
    You enjoy the process of hunting down bugs
    Your experience and background have been focused on enhancing testing techniques
    You like being in the last phase of work before the product reaches the customer
    You consider your contribution to the whole development process to be very important.