FreeJobAlert.Com

Government Jobs | Results | Admit Cards

unix interview questions | Part9

If you would like to view All operating system interview questions only at one place visit below link

All UNIX Interview Questions

88. What is the difference between cat and more command?
Ans: Cat displays file contents. If the file is large the contents scroll off the screen before we view it. So command ‘more’ is like a pager which displays the contents page by page.

89. Write a command to kill the last background job?
Ans: Kill $!

90. Which command is used to delete all files in the current directory and all its sub-directories?
Ans: rm -r *

91. Write a command to display a file’s contents in various formats?
Ans: $od -cbd file_name c – character, b – binary (octal), d-decimal, od=Octal Dump.

92. What will the following command do?
Ans: $ echo *
It is similar to ‘ls’ command and displays all the files in the current directory.

93. Is it possible to create new a file system in UNIX?
Ans: Yes, ‘mkfs’ is used to create a new file system.

94. Is it possible to restrict incoming message?
Ans: Yes, using the ‘mesg’ command.

95. What is the use of the command “ls -x chapter[1-5]”
Ans: ls stands for list; so it displays the list of the files that starts with ‘chapter’ with suffix ‘1’ to ‘5’, chapter1, chapter2, and so on.

96. Is ‘du’ a command? If so, what is its use?
Ans: Yes, it stands for ‘disk usage’. With the help of this command you can find the disk capacity and free space of the disk.

97. Is it possible to count number char, line in a file; if so, How?
Ans: Yes, wc-stands for word count.
wc -c for counting number of characters in a file.
wc -l for counting lines in a file.

98. Name the data structure used to maintain file identification?
Ans: ‘inode’, each file has a separate inode and a unique inode number.

99. How many prompts are available in a UNIX system?
Ans: Two prompts, PS1 (Primary Prompt), PS2 (Secondary Prompt).

100. How does the kernel differentiate device files and ordinary files?
Ans: Kernel checks ‘type’ field in the file’s inode structure.

101. How to switch to a super user status to gain privileges?
Ans: Use ‘su’ command. The system asks for password and when valid entry is made the user gains super user (admin) privileges.

102. What are shell variables?
Ans: Shell variables are special variables, a name-value pair created and maintained by the shell.
Example: PATH, HOME, MAIL and TERM

103. What is redirection?
Ans: Directing the flow of data to the file or from the file for input or output.
Example : ls > wc

104. How to terminate a process which is running and the specialty on command kill 0?
Ans: With the help of kill command we can terminate the process.
Syntax: kill pid
Kill 0 – kills all processes in your system except the login shell.

105. What is a pipe and give an example?
Ans: A pipe is two or more commands separated by pipe char ‘|’. That tells the shell to arrange for the output of the preceding command to be passed as input to the following command.
Example : ls -l | pr
The output for a command ls is the standard input of pr.
When a sequence of commands are combined using pipe, then it is called pipeline.

106. Explain kill() and its possible return values.
Ans: There are four possible results from this call:
‘kill()’ returns 0. This implies that a process exists with the given PID, and the system would allow you to send signals to it. It is system-dependent whether the process could be a zombie.
‘kill()’ returns -1, ‘errno == ESRCH’ either no process exists with the given PID, or security enhancements are causing the system to deny its existence. (On some systems, the process could be a zombie.)
‘kill()’ returns -1, ‘errno == EPERM’ the system would not allow you to kill the specified process. This means that either the process exists (again, it could be a zombie) or draconian security enhancements are present (e.g. your process is not allowed to send signals to *anybody*).
‘kill()’ returns -1, with some other value of ‘errno’ you are in trouble! The most-used technique is to assume that success or failure with ‘EPERM’ implies that the process exists, and any other error implies that it doesn’t.
An alternative exists, if you are writing specifically for a system (or all those systems) that provide a ‘/proc’ filesystem: checking for the existence of ‘/proc/PID’ may work.

Related Fresher Interview Questions

1. C Language Interview Questions
2. C++ Language Interview Questions
3. Data Structures Interview Questions
4. DBMS Interview Questions
5. Operating System Interview Questions
6. UNIX Interview Questions

Tags: basic unix interview questions, General UNIX interview questions, Some UNIX Interview Questions, unix commands, unix interview, unix interview faq, unix interview questions, Unix Interview Questions And Answers, unix interview questions and answers for freshers, unix interview questions and answers pdf, unix interview questions for freshers, unix interview questions with answers, unix shell scripting interview questions

Responses to “unix interview questions | Part9”

Leave a Comment