Unix Testing Interview Questions
What is UNIX?
Ans: It is a portable operating system that is designed for both efficient multi-tasking and multi-user functions. Its portability allows it to run on different hardware platforms.
It was written in C and let the user do processing and control under a shell.
What are the filters?
Ans: The term Filter is often used to refer to any program that can take input from standard input, perform some operation on that input, and write the results to standard output.
A Filter is also any program that can be used between two other applications in a pipeline.
What is a typical syntax being followed when issuing commands in the shell?
Ans: Typical command syntax under the UNIX shell follows the format:
Command [-argument] [-argument] [–argument] [file]
Is there a way to erase all files in the current directory, including all its sub-directories, using only one command?
Ans: Yes, that is possible. Use “rm –r *” for this purpose. The rm command is for deleting files. The –r option will erase directories and subdirectories, including files within. The asterisk represents all entries.
What is the chief difference between the –v and –x option s to set?
Ans: The –v option echoes each command before arguments and variables have been substituted for; the –x option echoes the commands after the substitution has taken place.
Unix Interview Questions For Production Support
What is a Kernel?
Ans: Kernel is the UNIX operating system. It is the master program that controls the computer’s resources, allotting them to different users and different tasks.
However, the kernel doesn’t deal directly with a user. Instead, it starts up a separate, interactive program, called a shell, for each user when he/she logs on.
What is Shell?
Ans: A shell acts as an interface between the user and the system. As a command interpreter, the shell takes commands and sets them up for execution.
What are the key features of the Korn Shell?
Ans: – history mechanism with the built-in editor that simulates emacs or vi
– built-in integer arithmetic
– string manipulation capabilities
– command aliasing
– job control
What are some common shells, and what are their indicators?
Ans: sh – Bourne shell
csh – C SHell
bash – Bourne Again Shell
tcsh – enhanced C Shell
zsh – Z SHell
ksh – Korn SHell
Differentiate multiuser from multitasking.
Ans: Multiuser means that more than one person can use the computer at the same time. Multitask means that even a single user can have the computer work on more than one task or program at the same time.
What is command substitution?
Ans: Command substitution is the shell processes one of the steps being performed every time commands. The shell executes commands that are enclosed in backquotes.
This will then replace the standard output of the command and displayed it on the command line.
What is a directory?
Ans: Every file is assigned to a directory. A directory is a specialized form of a file that maintains a list of all files in it.
What is inode?
Ans: An inode is an entry created on a section of the disk set aside for a file system. The inode contains nearly all there is to know about a file, which includes the location on the drive where the file starts.
the size of the file, when the file was last used when the file was last changed, what the various read, write and execute permissions are, who owns the file, and other information.
Unix Interview Questions For Testers
You have a file called tonky in the directory honky. Later you add new material to tonky. What changes take place in the directory, inode, and file?
Ans: The directory entry is unchanged since the name, and inode number remain unchanged. In the inode file, the file size, time of last access, and time of last modification are updated. In the file itself, the new material is added.
Describe file systems in UNIX
Ans: Understanding file systems in UNIX has to do with knowing how files and inodes are stored on a system. What happens is that a disk or portion of a disc is set aside to store files and the inode entries. The entire functional unit is referred to as a file system.
Differentiate the relative path from the absolute path.
Ans: Relative path refers to the path relative to the current path. The absolute path, on the other hand, refers to the exact path as referenced from the root directory.
Explain the importance of directories in a UNIX system
Ans: Files in a directory can be a directory itself; it would be called a subdirectory of the original. This capability makes it possible to develop a tree-like structure of directories and files, which is crucial in maintaining an organizational scheme.
Briefly describe Shell’s responsibilities
Ans: – program execution
– variable and filename substitution
– I/O redirection
– pipeline hookup
– environment control
– interpreted programming language
What are shell variables?
Ans: Shell variables are a combination of a name ( identifier), and an assigned value, which exists within the shell. These variables may have default values, or whose values can be manually set using the appropriate assignment command. Examples of shell variables are PATH, TERM, and HOME.
Read Also: Different Stages Of QA LifeCycle
What are the differences between a system call, a library function, and a UNIX command?
Ans: A system call is part of the programming for the kernel. A library function is a program that is not part of the kernel but which is available to users of the system. UNIX commands, however, are stand-alone programs; they may incorporate both system calls and library functions in their programming.
What is Bash Shell?
Ans: It is a free shell designed to work on the UNIX system. Being the default shell for most UNIX-based systems, it combines features that are available both in the C and Korn Shell.
Enumerate some of the most commonly used network commands in UNIX
– telnet – used for remote login
– ping – an echo request for testing connectivity
– su – user switching command
– FTP – file transfer protocol used for copying files
– finger – information gathering command
Differentiate CMP command from diff command.
Ans: The CMP command is used mainly to compare two files byte by byte, after which the first encountered mismatch is shown. On the other hand, the diff command is used to indicate the changes that are to be made to make the two files identical to each other.
What is the use of -l when listing a directory?
Ans: -l, which is usually used in listing command like ls, is used to show files in an extended format, one file per line. Long-form refers to additional information that is associated with the file, such as ownership, permissions, data, and file size.
What is the piping?
Ans: Piping, represented by the pipe character “|,” is used to combine two or more commands. The output of the first command serves as input the next command, and so on.
Check Also: svn interview questions
What is a superuser?
Ans: A superuser is a particular type of user who has open access to all files and commands on a system. Note that the superuser’s login is usually root, and is protected by a so-called root password.
How do you determine and set the path in UNIX?
Ans: Each time you enter a command, a variable named PATH or path will define in which directory the shell will search for that command. In cases wherein an error message was returned, the reason may be that the command was not in your path, or that the command itself does not exist. You can also manually set the path using the “set path = [directory path]” command.
Is it possible to see information about a process while it is being executed?
Ans: A process identifier uniquely identifies every process. It is possible to view details and status regarding a process by using the ps command.
What is the standard convention being followed when naming files in UNIX?
Ans: One important rule when naming files is that characters that have special meaning are not allowed, such as * / & and %. A directory, being a particular type of file, follows the same naming convention as that of files. Letters and numbers are used, along with characters like underscore and dot characters.
Why is it that it is not advisable to use root as the default login?
Ans: The root account is essential, and with abusive usage, it can easily lead to system damage. That’s because safeguards that generally apply to user accounts do not apply to the root account.
What is the use of the tee command?
Ans: The tee command does two things: one is to get data from the standard input and send it to standard output; the second is that it redirects a copy of that input data into a file that was specified.
Differentiate cat command from more command.
Ans: When using the cat command to display file contents, extensive data that does not fit on the screen would scroll off without pausing, therefore making it difficult to view. On the other hand, using the more command is more appropriate in such cases because it will display file contents one screen page at a time.
What is parsing?
Ans: Parsing is the process of breaking up a command line into words. This is made possible by using delimiters and spaces. If tabs or multiple areas are part of the command, these are eventually replaced by a single space.
What is PID?
Ans: Pid is short for Process ID. It is used primarily to identify every process that runs on the UNIX system, whether it runs on the foreground or runs in the background. Every PID is considered unique.
How does the system know where one command ends and another begins?
Ans: Normally, the newline character, which is generated by the ENTER or RETURN key, acts as the signpost. However, the semicolon and the ampersand characters can also serve as command terminators.
What is a wild-card interpretation?
Ans: When a command line contains wild-card characters such as ‘*’ or ‘?’, these are replaced by the shell with a sorted list of files whose pattern matches the input command. Wild-card characters are used to set up a list of files for processing, instead of having it specified one at a time.
What is the output of this command? $who | sort –logfile > new file
Ans: In this command, the output from the command “who” becomes the input to the “sort” command. At the same time, “sort” opens logfile, arranges it together with the output from the command “who,” and places the final sorted output to the file new file.
How do you switch from any user type to a superuser type?
Ans: To switch from any user type to a superuser, you use the su command. However, you will be asked to key in the correct superuser password before full access privileges are granted to you.
What would be the effect of changing the value of PATH to:
Ans: .:/usr/Della/bin: /bin: /usr/bin
This would cause the shell to look in the /usr/della/bin directory after looking in the current directory and before looking in the /bin directory when searching for a command file.
Write a command that will display files in the current directory, in a colored, long format.
Ans: ls -l –color
Write a command that will find all text files in a directory such that it does not contain the word “amazing” in any form (that is, it must include the words Amazing, AMAZING, or aMAZINg)
grep –vi amazing *.txt
Write a command that will output the sorted contents of a file named IN.TXT and place the output in another file named OUT.TXT, while at the same time excluding duplicate entries.
sort IN.TXT | uniq > OUT.TXT
Write a command that will allow a UNIX system to shut down in 15 minutes, after which it will perform a reboot.
/sbin/shutdown –r +15
What command will change your prompt to MY PROMPT:?
Ans: To change a prompt, we use the PS1 command, such as this:
PS1 = ‘MYPROMPT:’
What does this command do? cat food 1 > kitty
Ans: it redirects the output of cat food into the file kitty; the command is the same as:
cat food > kitty
What is wrong with this interactive shell script?
echo What month is this?
echo $month is as good a month as any.
Ans: Initially, the question mark should be escaped (\?) so that it is not interpreted as a shell metacharacter. Second, it should be read a month, not read a $month.
Write a shell script that requests the user’s age and then echoes it, along with some suitable comments.
Echo Hello! What\’s your age\?
echo $age! I\’ll be obsolete by that age!
Write a script that prints outdate information in this order: time, the day of the week, day number, month, year
(sample output: 17:34:51 PDT Sun 12 Feb 2012)
echo $4 $5 $1 $3 $2 $6
Write a script that will show the following as output:
Give me a U!
Give me an N!
Give me an I!
Give me an X!
for I in U N I X
echo Give me a $ I!
echo $ I!