Friday, April 15, 2011

UNIX Commands Interview Questions Part 2


1. What is the use of 'grep' command?
'grep' is a pattern search command. It searches for the pattern, specified in the command line with appropriate option, in a file(s).
Syntax : grep
Example : grep 99mx mcafile

2. What is the difference between cat and more command?
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.

3. Write a command to kill the last background job?
Kill $!

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

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

6. What will the following command do?
$ echo *
It is similar to 'ls' command and displays all the files in the current directory.

7. Is it possible to create new a file system in UNIX?
Yes, 'mkfs' is used to create a new file system.

No comments:

Post a Comment