TOP 100+ Linux Interview Questions And Answers for freshers and experienced:
Linux Interview Questions And Answers are as follows –
Q1. What is called Shell?
ANSWER: The interface between user and system called a shell. Shell accepts commands and set them to execute for user operations.
Q2. Describe the usage and functionality of the command “rm –r *” in UNIX?
ANSWER: The command “rm –r *” is a single line command to erase all files in a directory with its subdirectories.
“rm” – Is for deleting files.
“-r” – Is to delete directories and subdirectories with files within.
“*” – Is indicate all entries.
Q3.Specify the difference between absolute path and related path?
ANSWER: Absolute path refers to the exact path as defined from the root directory. Related path refers to the path related to the current locations.
Q4. What is the UNIX command to list files/folders in alphabetical order?
ANSWER: The ‘ls –l’ command is used to list down files and folders in alphabetical order. When you use ‘ls –lt’ is list down files /folders sorted with modified time.
Q5. What is the behavioral difference between “cmp” and “diff” commands?
ANSWER: Both commands for file comparison.
Cmp – Compare given two files with byte by byte and display the first mismatch.
Diff – Display changes that need to done to make both file identical.
Q6. What are the duties of following commands?
ANSWER: chmod, chown, chgrp
chmod – Change the permission set of the file.
chown – Change ownership of the file.
chgrp – Change group of the file.
Q7. What is the command to find today’s date?
ANSWER: The command “date” use to retrieve current date.
Q8. What is the purpose of the following command?
more README.txt
ANSWER: The command is to display the first part of the file names README.txt which just fit as much as on one screen.
Q9. Describe the zip/unzip command using gzip?
ANSWER: gzip filename. — to zip the filename into filename.gz
gunzip filename.gz — to unzip the filename.gz into filename
Q10.How to display the last line of a file called README.txt
ANSWER: tail -f 1 README.txt
Q11. Explain the advantage of executing processes in the background?
ANSWER: The general advantage is to execute processes in the background is to get the possibility to execute some other process without waiting for the previous process to get completed. The symbol “&” at the end of the process tells to the shell to execute given a command in the background.
Q12. How to Kill a process in UNIX?
ANSWER: The Kill command accepts process ID (PID) as an in a parameter. This is applicable only for the processes own by the command executor.
Q13. What is the command to find hidden files in the current directory?
ANSWER: ls –la is to display hidden files in current directory.
Q14. How to display all cuurent running process?
ANSWER: ps -ef
Q15. How to find out the diskspace of the fileSystem?
ANSWER: df -kh
Q16. What is the UNIX command to make a new directory?
ANSWER: “mkdir directory_name” is used to create a new directory.
Q17. What is the UNIX command to confirm a remote host is alive or not?
ANSWER: Either “ping” or “telnet” command can use to confirm a remote host alive or not.
Q18. What is the method to see command line history?
ANSWER: The “history” command display all the command used previously within the session.
Q19. What is the command to find weather system is 32 bit or 64 bit?
ANSWER: “arch” or “uname -a” can use for this process.
Q20. Explain ‘nohup’ in UNIX?
ANSWER: “nohup” is a special command that is available to run a process in the background. The process started with ‘nohup’ command is not terminating even the user started to log off from the system.
Q21. What is the UNIX command to find how many days the server is up?
ANSWER: “uptime” command returns the number of dates that the server is up.
Q22. What is the purpose of “echo” command?
ANSWER: “echo” command is similar to “ls” command and it displays all the files in current directory.
Q23. What is called piping?
ANSWER: “piping” is used to combine two or more commands together. The output of the first command work as the input of the second command, and so on. Pipe character ( | ) is represent piping.
Q24. What is the process to count the number of characters and line in a file?
ANSWER: “wc – c filename” command can use to retrieve the number of characters in a file & “wc –l filename” command can use to retrieve the number of lines in a file.
Q25. Enlist some commonly used network commands.
ANSWER: Some commonly used networking commands in Unix are enlisted below:
- a) telnet: it is used for remote login as well as for communication with another hostname.
- b) ping: it is defined as an echo request for checking network connectivity.
- c) nslookup: performs DNS query.
- d) traceroute: method to determine the number of hoops and response time required to reach the network host.
- e) netstat: it provides a lot of information like ongoing network connection on the local system and ports, routing tables, interfaces statistics, etc.
Q26. Enlist some filename manipulation commands in UNIX.
ANSWER: Some Filename manipulation commands along with their description is enlisted below in table:
cat filename : Displays contents of the file
cp source destination : Used to copy source file into the destination
mv old name new name : Move/rename and old name to the new name
rm filename : Remove/delete filename
Touch filename : Changing modification time or for creating a file.
In [-s] old_name new_name : Creates soft link on old name
Is –F : Displays information about file type
Q27. Explain alias mechanism.
ANSWER: To avoid typing long commands or to improve efficiency, the alias command is used to assign another name to a command. Basically, it acts as a shortcut to the larger commands which can be typed and run instead.
For creating an alias in Unix, following command format is used:
alias name=’command you want to run’
Q28. Explain pid.
ANSWER: A pid is used to denote unique process id. It basically identifies all the processes that run on the Unix system. It does not matter whether the processes are running in the foreground or in the background.
Q29. Explain mount and unmount command.
ANSWER:
Mount command: As the name suggests, the mount command mounts a storage device or file system onto an existing directory and thus making it accessible to users.
Unmount command: This command unmounts the mounted file system by safely detaching it. It also the task of this command to inform the system to complete any pending read and write operations.
To view all mount : ‘mount’
To mount : mount /dev/sdb /data — you have added a disk /dev/sdb on on your system. Now you want to mount this on /data directory.
To unmount : umount /dev/sdb — Use umount command to unmount any mounted filesystem on your system. Run umount command with disk name or mount point name to unmount currently mounted disk.
Q30. What are some common shells and what are their indicators?
ANSWER:
sh – Bourne shell
csh – C SHell
bash – Bourne Again Shell
tcsh – enhanced C Shell
zsh – Z SHell
ksh – Korn SHell
Q31. What is the use of -l when listing a directory?
ANSWER: -l, which is normally used in listing command like ls, is used to show files in a long format, one file per line. Long format refers to additional information that is associated with the file, such as ownership, permissions, data, and filesize.
Q32. why is it that it is not advisable to use root as the default login?
ANSWER: The root account is very important, and with abusive usage, can easily lead to system damage. That’s because safeguards that normally apply to user accounts are not applicable to the root account.
Q33. Differentiate cat command from more command.
ANSWER: When using the cat command to display file contents, large 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.
Q34. How do you switch from any user type to a super user type?
ANSWER: In order 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.
Q35. Write a command that will display files in the current directory, in a colored, long format.
ANSWER: ‘ls -l –color”
Q36. 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.
ANSWER: “sort IN.TXT | uniq > OUT.TXT”
Q37. What is Sun micro systems UNIX called as?
ANSWER: Solaris.
Q38. Is UNIX/Linux case sensitive from the console terminal end.
ANSWER: Yes.
Q39. Is UNIX open source?
ANSWER: No, Linux is open source.
Q40. Name 5 variants of linux?
ANSWER: Redhat, Cent OS, Debian, Ubuntu and Fedora.
Q41. How to open a file in read only mode using vi editor?
ANSWER: vi − R
Q42. How can you display line numbers in vi editor?
ANSWER: “:set nu”
Q43. What is the full form of grep?
ANSWER: Globally search for regular expression.
Q44. Which filter can be used to extract a specific range of character from the lines of text?
ANSWER: cut
Q45. What is the basic purpose of ‘find’ command?
ANSWER: To search for a file/files.
Q46. What is a zombie process?
ANSWER: The process is dead but have not been removed from the process table.
Q47. Which is the environment variable which holds your home directory information?
ANSWER: HOME.
Q48. How can you list all the directories using ls command?
ANSWER: ls −l|grep “^d”
Q49. Which command can be used to execute a command/s repeatedly for the given schedule?
ANSWER: Crontab
Q50. How can you display nth line of a file?
ANSWER: head −<n> file.txt | tail −1
Q51. How will you find which operating system your system is running on in UNIX?
ANSWER: By using command “uname -a” in UNIX
Q52. What is difference between ps -ef and ps -auxwww?
ANSWER: ps -ef will omit process with very long command line while ps -auxwww will list those process as well.
Q53. How do you find how many cpu are in your system and there details?
ANSWER: By looking into file /etc/cpuinfo for example you can use below command:
Q54. Your application home directory is full? How will you find which directory is taking how much space?
ANSWER: By using disk usage (DU) command in Unix for example du –sh .
Q55. Search a file from root directory.(filename = sample.txt)
ANSWER: find / -name sample.txt
Q56. Display the numbers in sorted order
ANSWER: sort -nu
Q57. How can display top 10 disk usage files.
ANSWER: du -sh *|sort -nr|head -10
Q58. How to zip a Directory
ANSWER: gzip -r /hom/bea/app
Q59. syntax for tar and untar a file?
ANSWER: tar -cvf filename.tar file1 file2 file3.
tar -Xvf filename.tar
Q60. what is command search a string in a file.
ANSWER: grep
Q61.Display all java process in unix.
ANSWER: ps -ef |grep java
Q62.How to kill a prosess.
ANSWER: kill -9 pid
-9 is to forcefull kill.
Q63.Display the updated lines in file
ANSWER: tail -f filename
Q64. Which command is used to search and replace a string?
ANSWER: sed
Q65. How to search a string and replace it in vi editor.
ANSWER: “%s/old string /new string/ g”
Example : %s/OLD/old/g
%s/TRUE/FALSE/g
Q66. How can replace astring in unix in file.
ANSWER: sed “s/oldstring/newstring/g” filename
Q67. How to search a string in vi editor from bottom to top.
ANSWER: ?string name
or / string name
Q68. How to insert a line above the current line in vi editor .
ANSWER: esc+o
Q69. How to delete 10 lines in vi editor.
ANSWER: 10dd
Q70. How to goto the end of the line in Vi editor?
ANSWER: G –Shift g
Q71. Copy 10 line in vi editor?
ANSWER: 10yy
Q72. How to display top 10 lines from a file?
ANSWER: head -10 filename.
Q73. How to go to insert mode in vi editor?
ANSWER: Esc+i / ESC + insert
Q74. How to do undo in vi Editor’s?
ANSWER: u
Q75. How to goto 100 Line in Vi Editor’s?
ANSWER: 100L
Q76. How to display last 100 Line from a file?
ANSWER: tail -100 filename
Q77. How to search a string in a file(filename=sample,string=weblogic)?
ANSWER: grep weblogic sample
Q78. How to display the updated lines in file ?
ANSWER: tail -f filename.
Q79. How to display hiddean a file?
ANSWER: ls -a.
Q80. When do you use vi editor?
ANSWER: In UNIX environments we have vi editor for creating new file which can be shell or python or jython or plain file.
I – insert mode
Esc – to come out of the mode
r – replace char
a – append to the line
O – insert above line
o – insert below line
dw – delete word
dd – delete line
x – delete char
/ – search a pattern
:set nu setup numbers etc…
Q81. Display the directiory count in current dir?
ANSWER: ls -lrt !wc -l
Q82. How to display all files ending with “log”?
ANSWER: grep -lr *.log
Q83. How to appeand data to the existing file?
ANSWER: cat>>filename
Q84. How to rename a file .
ANSWER: mv file1 file2
Q85. copy the content one directory to another directory.
ANSWER: cp -r dir1/file1 dir2/file2
Q86. How can delete blank lines in directory.
ANSWER: grep -v “^$” sample > temp
mv temp sample
Q87.How to retrive a field in a file.
ANSWER: cut -f 1,2 stud.
Q88.How to copyfile from one unix to other unix system and syntax (file=sample.txt,target host=192.168.11.128,target file path=/home/bea)?
ANSWER: scp -rp sample.txt username@192.168.11.128:/home/bea
Q89.Copy file from path to other tree structure is given below?
ANSWER: cp -r /curent/path/filename /to/given/path/
Q90.How to find out CPU utiligation?
ANSWER: top
Q91.How to execute ascript using nohup(script name=startweblogic.sh)?
ANSWER: nohup ./startWeblogic.sh &
Q92.which command is used to search astring in multiple files?
ANSWER: fgrep
Q93. how to save and quit from vi Editor’s?
ANSWER: WQ!
Q94. what are the Advantages of nohup command?
ANSWER: nohup will execute the process if you layout system.
Syntax:nohup &.
Q94. Differance b/w the ping and tracert?
ANSWER: ping tracert
1)It is check the connectivity. 1.It is packet information one place to
another place destination.
2)It is display all at a time. 2.It display only 30 hubs in tracert.
Q95. tar dir1 dir2 dir3 and new_dir?
ANSWER: syntax:tar -cvf new_dir.tar dir1 dir2 dir3 .
tar file name which is created will be new_dir.tar
Q96. How to display the ipaddress and portnumber?
ANSWER: netstat -anp
Q97. how to delete directory with recursion and force?
ANSWER: rm -rf filename.
Q98. How to Open a file with page to page ?
ANSWER: more filename
Q99. How to Hide a file (file name=tuxedo)?
ANSWER: mv tuxedo .tuxedo
Q100. write A syntax for the scp Commands?
ANSWER: Scp filename root@ipaddress:location.
I hope you understood on how to answers Linux Interview Question. Good Luck !!
Happy Learning !!
Related Posts:
- TOP 200+ JAVA Interview Questions And Answers
- Python Interview Question And Answers
- HTML Interview Questions And Answers
- C# interview questions and answers
- DOTNET Interview Questions And Answers
- [UPDATED] ASP.net Interview Questions And Answers
- C programming Interview Questions and Answers
- CPP Interview Questions And Answers
- JUNIT Interview Questions And Answers
- Networking Interview Questions And Answers
- Android Interview Questions And Answers
- Operating System Interview Questions and Answers
- Top 90 SQL Interview Questions And Answers
For more Interview Questions And Answers click here