10 Useful Random Linux Interview Questions and Answers

To a little surprise this time we are not presenting Interview question on any specific subject but on random topics. These question will surely help you in cracking Interviews beside adding to your Knowledge.

Linux Interview Questions
10 Random Linux Questions and Answers
1. Let’s say you maintains a backup on regular basis for the company you are working. The backups are maintained in Compressed file format. You need to examine a log, two months old. What would you suggest without decompressing the compressed file?
Answer : To check the contents of a compressed file without the need of decompressing it, we need to use ‘zcat’. The zcat utility makes it possible to view the contents of a compressed file.
# zcat ­f phpshell­2.4.tar.gz
2. You need to track events on your system. What will you do?
Answer : For tracking the events on the system, we need a daemon called syslogd. The syslogd daemon is useful in tracking the information of system and then saving it to specified log files.

Running ‘syslogd‘ application in terminal generates log file at the location ‘/var/log/syslog‘. The syslogd application is very useful in troubleshooting Linux sytems. A sample log file looks similar to below.

syslongd command
3. How will you restrict IP so that the restricted IP’s may not use the FTP Server?
Answer : We can block suspicious IP by integrating tcp_wrapper. We need to enable the parameter “tcp_wrapper=YES” in the configuration file at ‘/etc/vsftpd.conf’. And then add the suspicious IP in the ‘host.deny’ file at location ‘/etc/host.deny’.
Block IP Address

Open ‘/etc/hosts.deny’ file.

# vi /etc/hosts.deny

Add the IP address that you want to block at the bottom of the file.

# hosts.deny    This file contains access rules which are used to
#               deny connections to network services that either use
#               the tcp_wrappers library or that have been
#               started through a tcp_wrappers-enabled xinetd.
#               The rules in this file can also be set up in
#               /etc/hosts.allow with a 'deny' option instead.
#               See 'man 5 hosts_options' and 'man 5 hosts_access'
#               for information on rule syntax.
#               See 'man tcpd' for information on tcp_wrappers
4. Tell us the difference between Telnet and SSH?
Answer : Telnet and SSH both are communication protocol which are used to manage remote system. SSH is Secured, which requires exchanging of key opposite of telnet which transmit data in plain text, which means telnet is less secure than SSH.
6. You need to stop your X server. When you tries to kill your X server, You got an error message that you cannot quit X server. What will you do?
Answer : When killing a X server, it won’t work normal way like doing ‘/etc/init.d/gdm stop’. We need to execute a special key combination ‘Ctrl+ Alt+ Back Space’ which will force X server to restart.
6. What is the difference between command ‘ping’ and ‘ping6’?
Answer : Both the commands are same and used for the same purpose except that the fact that ping6 is used with ipv6 IP address.
7. You want to search for all the *.tar files in your Home directory and wants to delete all at once. How will you do it?
Answer : We need to use find command with rm command to delete all “.tar” files.
# find /home/ ­name '*.tar' | xargs rm ­rf
8. What is the difference between locate and slocate command?
Answer : The slocate looks for the files that user have access whereas locate will search for the file with updated result.
9. You need to search for the string “Tecmint” in all the “.txt” files in the current directory. How will you do it?
Answer : We need to run the fine command to search for the text “Tecmint” in the current directory, recursively.
# find -­name “*.txt” | xargs grep “Tecmint”
10. You want to send a message to all connected users as “Server is going down for maintenance”, what will you do?
Answer : This can be achieved using the wall command. The wall command sends a message to all connected users on the sever.
# echo please save your work, immediately. The server is going down for Maintenance at 12:30 Pm, sharply. | wall
wall command
wall command

That’s all for now. I will be here again, with an interesting article very soon. Till then stay tuned and connected to Tecmint. Don’t Forget to give your valuable feedback in comment section below.

Hey TecMint readers,

Exciting news! Every month, our top blog commenters will have the chance to win fantastic rewards, like free Linux eBooks such as RHCE, RHCSA, LFCS, Learn Linux, and Awk, each worth $20!

Learn more about the contest and stand a chance to win by sharing your thoughts below!

A Passionate GNU/Linux Enthusiast and Software Developer with over a decade in the field of Linux and Open Source technologies.

Each tutorial at TecMint is created by a team of experienced Linux system administrators so that it meets our high-quality standards.

Join the TecMint Weekly Newsletter (More Than 156,129 Linux Enthusiasts Have Subscribed)
Was this article helpful? Please add a comment or buy me a coffee to show your appreciation.


Leave a Reply
  1. lesspipe will be helpful for viewing backup which is compressed.

    *.deb, *.udeb, *.ddeb
    *.gif, *.jpeg, *.jpg, *.pcd, *.png, *.tga, *.tiff, *.tif
    *.iso, *.raw, *.bin
    *.lha, *.lzh
    *.tar.lz, *.tlz
    *.rar, *.r[0-9][0-9]
    *.tar.gz, *.tgz, *.tar.z, *.tar.dz
    *.gz, *.z, *.dz
    *.tar.xz, *.xz
    *.jar, *.war, *.xpi, *.zip

  2. On question #9, why not do:

    grep Tecmint *

    There are many ways to perform that operation in the current directory. However, not including subdirectories, one can type much less by using the above command…

    • @Lee,

      The grep Tecmint *, do you think this command will list string “Tecmint“? have you tried it before suggesting, i suggest you to try yourself and see long it takes and what it does before giving final results, for me this command is just a waste of time….and will not work at all..

  3. Answer : To check the contents of a compressed file without the need of decompressing it, we need to use ‘zcat’. The zcat utility makes it possible to view the contents of a compressed file.

    This answer implies that zcat doesn’t decompress the file, and uses some fancy algorithm to read compressed data.
    This is not the case, it decompresses the file anyway, then cats the decompressed data.

  4. Several comments:

    7: find /home/ -name \*.tar -exec rm {} \;
    – -exec says whenever you find a match, run the command substituting {} with the filename
    – Escape characters that may be interpreted by the shell, like * and ;
    – no need for -rf since these are files and not directories

  5. Hi Avishek,

    your articles help a lot for linux beginners. But I was stuck with few questions.
    I need to list the files from remote ftp server with regular expression as RCCCFHW01N[0-9]{4}2014[0-9]{10}.dat..

    can you help me in listing the files particular 2014 in which remote server holds files from different years.

  6. Hi Avishek,

    It is really great learning. I have interview for the position of Linux Admin (3-7 Yrs+) exp. What level of expectation they have from me as a 3 Yrs + experience guy?

    Please suggest some of key area where I have to prepare.


    • Dear Thakur,
      It totally depends upon what/whom the company is dealing with and Interviewer’s mood. Still toopics like – Networking, Protocol, Kernel, Scripting, Automation, SSH, FTP, etc are all evergreen. Keep connected with us and in that mean check our previous posts.

    • Dear Devasish Majumdar,
      keep connected with us. Learning is a slow process. You have to learn everyday and so are we coming up with tutorials everyday.


  7. Above article really helpful ..Thanks to Tecmint and Avishek . i really appreciate if get more Q & A on Linux not for crack the interview but also for the knowledge and update .

  8. This is a pretty good list. Though some can have multiple answers. For example:

    Number 2: Systemd systems have the journal, which not only allows the same functionality as syslogd, but also allows for some advanced features to access the log almost like a database. You can also use syslogd to supplement it.

    Also, there’s a problem with number 5: For the past several years Xorg has defaulted to DISABLING CTRL+ALT+BACKSPACE completely. It’s nice to have but unless you configure it ahead of time you can’t count on that option. Worse comes to worse you can use magic sysrqs (Admittedly they can be disabled too.) to take system control back. Another alternative is to always have sshd running (Or socket activated on systemd.) and tunnel in with another machine or device and kill X from there.

    Finally, on 10, why the heck would you use echo to pipe into wall? Waste an entire process on that? Just use wall echo | wall is wasteful and inefficient.

    • Dear Yaro,
      we have always been saying that there may be more than one answer to a question. we mainly focus on the easiest way to get through yet with perfection.

      Yet! your feedback is wonderful and we are thankful to you for your time you gave in explaining the solution, the other way.

  9. Hi,
    This is very good notes. I am very happy if you share some lvm, filesystem and storage connectivity question answer.

  10. Dear Sir,

    Humble request, Please sir provide me tchnical solved question answer as you have post on this site. i prepare it for my career.

  11. alternative to 7

    Not an alternative, in fact. find has its inbuilt command -exec

    find /home -iname “*.tar” -exec rm -f {} \;

    • Yeah Phincy!
      We have always been saying that there may be more than one answer to a question and we try to find a solution that is easy yet perfect.

      Thanks for your feedback.

  12. Thank you for the wonderful tutorial :) By the way how about DDOS attack do you have tips to avoid this in your server? Thanks

        • Dear rajesh,
          it is not possible for us to send our materials to personal mail of our every fan. Moreover it is against our copyright law to send or use the post in any form, withour prior permission of Tecmint.com

          Keep connected to Tecmint, and be updated.

  13. Alternatively for number 9, you can achieve the same results in one command (without the pipe to xargs) by using:

    $ grep -r “Tecmint” *.txt


Got Something to Say? Join the Discussion...

Thank you for taking the time to share your thoughts with us. We appreciate your decision to leave a comment and value your contribution to the discussion. It's important to note that we moderate all comments in accordance with our comment policy to ensure a respectful and constructive conversation.

Rest assured that your email address will remain private and will not be published or shared with anyone. We prioritize the privacy and security of our users.