Top 50 unix interview question and answer.


1 what is unix

UNIX is a computer Operating System which is capable of handling activities from multiple users at the same time. is an operating system that originated at Bell Labs in 1969 as an interactive time-sharing system.


Unix was designed to be portable, multi-tasking and multi-user in a time-sharing configuration. Unix systems are characterized by various concepts: the use of plain text for storing data; a hierarchical file system; treating devices and certain types of inter-process communication (IPC) as files; and the use of a large number of software tools, small programs that can be strung together through a command-line interpreter using pipes, as opposed to using a single monolithic program that includes all of the same functionality.



2. what is mean by command ls

ls command lists all files in the directory




ls [options] [names]


If the name is blank, then ls command displays all files in the directory.



3. what is mean by command ls -l command

It will show you a list of directories in long (detail) format.



4. what is mean by ls -a

it will list the current directory including hidden files.



5. How you find hidden files in unix.

By using ls -a command



6. what will be output of command ls -ld*

it will list all the file and directory name in the current directory



7. Suppose there is a file1 say test1.txt and file2 say text2.txt and i want to append file1 data to file2

By using cat command, we can append file1 data to file2.


cat file1 >> file2



8.what these two command prints "echo file1","cat file1"?

echo file1, echo simply prints file1.


"cat file1" cat command will searches for a file as "file1" in the PWD. if it finds any file called "file1", then it will prints the contents of the file1 file. else will through the error as file not existing.



9. What is pwd command

It will show parent working directory




10. what cd command will do

It will change current directory to your home directory



11. what will be output of command cd/user/bench

It will change current directory to /user/bench



12. what is mean by cd bench

It will change current directory to the bench, which is a subdirectory of the current directory



13. what will be output of cd..

It will change current directory to the parent directory of the current directory



14. what is mean by cd-bench

It changes the current directory to user bench home directory



15. what is mean by command / in unix.

It will display root directory



16. what is mean by /bench

it will show directory bench (sub-directory of root directory)



17. By using which command you can copy file

By using cp command



18. How you move or rename file in unix

By using mv command



19. what is mean by mv file1 -|bench|

It will move file1 into sub-directory bench in your home directory



20.what is use of rm command in unix

It will use to remove or delete file



21. I have a file say benchpe.txt, by using which command i can move this file

By using MV command, we can move file benchpe.txt Example >> mv /tmp/benchpe.txt /home/ In that benchpe.txt is moved from /tmp file system to /home file system!



22. What command is used to replace the existing string with some other?

sed 's/existingstring/newstring/g' filename or Specfied

row means sed '1,10s/existingstring/newstring/g' filename



23. Which Command will change the name of a directly from bench to benchpe

mv bench benchpe



24.How will you find the current date, time in UNIX?

by using the command date

date having different options according to reqirement like MMDDYY or day of the week,month name



25.What is the command to edit contents of the file?

vi filename is commonly used and also Commands like vi filename, sed, awk, nawk can be used



26. How to copy file into directory?

We can use command cp

cp source destination



27. Name of the command to remove directory with files?

We can use command rm

rm -r



28.Name of the command to find out the difference between files and folders?

We can use command $ls -l

first character of output of long listing. if it is 'd' it is a directory. if it is a '-' it is a regular file.



29. what is the difference between commmands cmp and diff?

The cmp command compares two files of any type and writes the results to the standard output. By default, cmp is silent if the files are the same; if they differ, the byte and line number at which the first difference occurred is reported.



30. How to convert a hidden file to normal visible file?

In unix hidden files are those files whose names are started wiht .(dot). so if you what to convert hidden file to normal visible file just rename those files and remove the leading .(dot) form its name.



30. How to delete a directory containing files and folders?

rm : For deleting the file

rm -i:It will ask conformation

rmdir:For removing the directory

rm -r:It remove recursively all files and directory itself

rm -rf: for deleting the all files and subdirectories in current directory



31. what are the different commands used to create files?

Below commands for creating a file

touch: touch

cat: cat >

vi: vi

vim: vim

pico: pico  


32. If we want to see first 5 lines of a file which command we have to use?

head -25 filename



33. what is kernel? and shell?

It is an core of the operating systems, coz it will handle all the critical tasks like memory management,process management, device management.

The shell reads the command from the user and interprets them as a request to execute a bcoz shell plays this role,it is called as a command line i9nterpreter.

Besides this shell is also a programming language.

it acts as an inretface between user and kernel. three most widely used unix shells are Bourne shell,korn shell and c shell.



34.what does a process mean?

Program under execution is called a process. Each and every process is all ways identified by a number called process id or PID. And Program not under execution is called a File.



36.What is the syntax of grep command and what is its use?

grep command is used to search the any word, any sentence from given or input file. syntex of grep command is grep "word or sentence" filename



37.How do you move a process which is running background to foreground?

%fg is the command used to bring process which is running background to foreground



38.How do you stop a running process?


kill -9 1234 ( get this pid using ps -ef | grep processname ")



39. Which command will you use to change the permissions on file?

chmod,chmod 777,chmod -R 755



40. What is the use of pipes?

Output of one command can be used as input for other command. Hence execution time will be reduced



41. what is the difference between pipe(|) and tee command.

pipe direct output of one command to the input of another command

ls -l | wc

tee command reads standard input, then writes the output to standard output and simultaneously copies it into the specified file or files

ls -l | wc -l | tee out.txt

It shows the output and also write the result into out.txt file



42. how many types of file in unix?.

1. Regular file:(-):contains data in either text format or binary format
2. Directory file:(d):contains entries of files
3. FIFO file:(f):2 communicate betn 2 processes running on same system
4. Block special file:(b):name given 2 special blocks of hard disk
5. Sybolic file:(l):its a link or pointer to already existing file
6. Socket file:(s):2 communicate betn 2 processes running on different system in a network
7. Character special file:(c):handles only characted formatted data
eg.stdin, stdout, stderr



43.What is use of sed command?.

sed is a stream editor for editing files from a script or from the command line to find largest file?

In the Directry Give....

ls -ls|sort -nr|head -1

that gives the largest file statistics...



45. can we use cat command as an editor

The cat utility concatenates and display files. It also can be used as a primitive editor for creation one liners or adding a line to the config file. There is also a version of cat called zcat which performs operation similar to uncompress -c or for GNU version gunzip -c on each input file.



46. How to display top 10 users

use below command

Who | head -10



47.what is the difference between KILL and KILL -9?

Kill command will kill the proecess without specifying the force whereas when we need to apply the force or priority to kill any process we use kill -9.



48.what is the difference between KILL and KILL -9?

how to find the 51th record of a file containing 100 records in unix.

how to find the 51th record of a file containing 100 records in unix.

by using command -n 51 filename |tail -1



49.what is the difference between KILL and KILL -9?

head -n 51 filename |tail -1 a growing log file how will you see the 1st 99 lines?

head -99 (file name)- display 1 st 99 lines

ptail -99 (file name) - display last 99 lines


Recommended For You


Top 7 advantage of using andriod 5.1 lollipop.


Read more

Mozilla firefox 64-bit developer edition launched for windows


Read more.

VLC 2.2 launched for windows, mac, linux.

Read more.

Top 10 Keyboard Shortcuts You should Know

Read more.

Popular Open Source IDES For Web Development

Read more.

Asus has launched PB278Q led-backlit monitor in india

Read more.

Sony launches Cyber-shot


Read more.