Top 30 Linux Interview questions - Interview Help - Top Interview Questions

Latest

Interview Help - Top Interview Questions

Top Interview Questions and Tips for a good Interview

Wednesday, August 19, 2020

Top 30 Linux Interview questions

 

Top 30 Linux Interview questions



Q1. What is Linux? Who invented Linux?

    

   Linux is an operating system, which is based on Linux Kernel. It

   is an open-source operating system where it can run on different

   hardware platforms.

   It provides a free and low-cost operating system for users.

   It is a user-friendly environment where they can easily modify and

   create variations in the source code.

   Linus Torvalds created Linux in 1991.




Q2. What are the basic components of Linux?

 

   Basic components of Linux are :

 

 1. Kernel: It is the core component of the Linux, it acts as an

    interface between software and hardware.  

 2. Shell: It acts as an interface between the user and the Kernel.

 3. GUI:  It stands for Graphic User Interface, which is another way

    for the user to interact with the system. But it is unlike 

    images,buttons, text boxes for interaction.

 4. System Utilities: These are the software functions that allow 

    users to manage the computer.

 5. Application Programs: Set of functions designed to perform a set 

    of tasks.



 

Q3. What is File System in Linux?

 

  A Linux file system is a structured collection of files on a disk

  drive or a partition.  It stores the data on hard disks (HDD) or 

  some equivalent storage type.

   

  The Linux file system contains the following sections:

 

  a) The root directory (/)

  b) A specific data storage format (EXT3, EXT4, BTRFS, XFS and so

     on)

  c) A partition or logical volume having a particular file system.

 



Q4. What are the Types of Linux File System?

 

   When we install the Linux operating system, Linux offers many 

   file systems such as Ext, Ext2, Ext3, Ext4, JFS, ReiserFS, XFS, 

   btrfs, and swap.

 

 

 A) Ext, Ext2, Ext3 and Ext4 file system : 

· The file system Ext stands for Extended File System. he Ext file system is an older version, and is no longer used due to some limitations.

 

· Ext2 is the first Linux file system that allows managing two terabytes of data.it is an upgraded version of Ext2 and contains backward compatibility.

 

· Ext3  does not support servers because this file system does not support file recovery and disk snapshot.

 

· Ext4 file system is the faster file system among all the Ext file systems.it is the default file system in Linux distribution.

   

   

B) JFS File System : JFS stands for Journaled File System. It is an alternative

 to the Ext file system.

   

   

C) ReiserFS File System : ReiserFS is an alternative to the Ext3 file system.

 It has improved performance and advanced features.

   

   

D) XFS File System :  XFS file system was considered as high-speed JFS.NASA

 still using this file system with its high storage server (300+ Terabyte

server).

  

   

E) Btrfs File System : Btrfs stands for the B tree file system. It is used for

fault tolerance, repair system, fun administration, extensive storage

configuration, and more.

  

   

F) Swap File System : The swap file system is used for memory paging in Linux

operating system during the system hibernation. A system that never goes in

hibernate state is required to have swap space equal to its RAM size.

 




Q5. How to Navigate the File System?

 

    We can navigate the file system by using cd, pwd, ls.

 



 

Q6. What are File permissions in Linux?

 

    There are 3 Types of permission in Linux:

    1. Read (r): Allows a user to open and read the file

    2. Write (w): Allows a user to open and modify the file

    3. Execute(x): Allows a user to run the file.

 

    Controlled By 3 levels : 1. user(u)

                             2. group(g)

                             3. Other(o)

 

  We can change the permission of a file or a directory using the 

   chmod command.

 

  For Example : $ chmod u=rwx,g=rx,o=r filename

 

              Values : r(4)

                       w(2)

                       x(1)

 

               $ chmod 754 filename




Q7. Which are the Linux Directory Commands?

 

    There are 5 main Directory Commands in Linux:

 

    1. pwd: Displays the path of the present working directory.

 

             Syntax: $ pwd

 

    2. ls: Lists all the files and directories in the present working

           directory.

 

            Syntax: $ ls

 

    3. cd: Used to change the present working directory.

 

            Syntax: $ cd <path to new directory>

 

    4. mkdir: Creates a new directory

 

            Syntax: $ mkdir <name (and path if required) of new 

                 directory>

 

    5. rmdir: Deletes a directory

 

            Syntax: $ rmdir <name (and path if required) of 

               directory>

 



Q8. Which are the different modes of vi editor?

 

   There are 3 modes of vi editor:

 

   1. Regular/Command mode: you can view the content

   2. Insertion/edit mode: you can delete or insert content

   3. Replacement mode: you can overwrite content

 




Q9.  How to exit from vi editors?

 

    We can use two commands to exit from the vi editor. They are:

 

    1. Wq: wq command saves the current work and exits from the vi 

           editor.

    2. q!: q! Command does not save the current work, but it exits 

           from the vi editor.




Q10.  How to delete information from a file in vi?

 

     1. Command x deletes the current character.

     2. Command dd deletes the current line.

 



Q11. How to find where a file is stored in Linux?

 

   We can use the locate command to find the path to the file.

 

   Suppose We want to find the locations of a file name xyz.txt, then command

    would be:

 

    $ locate xyz.txt

 



Q12. How to find directory only in Linux?

 

    We can use the find command to find the directory.

 

   



Q13. How to shrink or extend the size of file in linux?

 

 

    Truncate command is used to shrink or extend the size of file.

 




Q14.  How to filter the repeated or duplicate values?

 

     uniq command is used to filters out the repeated or duplicate 

     values.




Q15.  How to replace a string in the file?

 

      Sed command is used to replace a string in the file.

 

     For example : sed 's/old_txt/new-txt/g'

 



Q16.  How to create a directory?

 

      mkdir command is used to create a directory.




Q17.  How to create a file?

 

     We can create a file by using touch, vi, cp.




Q18.  How to display a file?

 

     Cat command is used to display a file.



Q19.  What is the use of pipe (|) command?

 

      It is used by the shell to connect the output of one command 

      directly to the input of another.

 



Q20.   What is grep command in Linux?

 

       grep command is a filter which is used to the global search

       for regular expressions.

 

       for Example: grep [options] pattern [files]

 



Q21.  What is ps command in Linux?

 

     ps command display the current process status of the system. 

     And it displays the process id’s with some other related data

     also.

 



Q22.  Enlist some Linux file content commands?

 

      File content commands

 

      1. head: Display top lines of the file.

      2. tail: Display last lines of the file.

      3. cat: Concatenate more than 2 files.

      4. more: Displays the content in pager form to view in the 

               terminal.

 

      


Q23. How to terminate a running process in Linux?

 

    Every process has a unique process id. To terminate the process, 

    we first need to find the process id. The ps command will list 

    all the running processes along with the process id.

    And then we use the kill command to terminate the process.

 

    The command for listing down all the processes:

 

      $ ps

 

   Suppose the process id of the process you want to terminate is 

   3899, then you will have to terminate it like this:

 

   $ kill 3899

 



Q24. How would you schedule a task in Linux?

 

    The cron command is used to repeatedly schedule a task at a

    specific time.

    The tasks are stored in a cron file and then executed using the

    cron command.

    The cron command reads the string from this file and schedules 

    the task.

    

    For Example : <minute> <hour> <day> <month> <weekday> <command>

 

                 Suppose you want to run a command at 4 pm every

                 Sunday, then the string would be:

 

                   0 16 * * 0 <command>

 

Q25.  How to identify which shell you are using?

 

      Open the terminal and run:

 

          $ echo $SHELL

 

     This will print the name of the Shell being used.


 

Q26.  What is the command to calculate the size of a folder?

 

      To calculate the size of a folder uses the command

          du –sh folder1.

 



Q27. How can you check the memory status?

 

     free -m to display output in MB

 

     free -g to display output in GB

 

Q28.  What is shell Scripting?

 

      It is an executable file containing multiple shell commands 

      that are executed sequentially.

 

Q29.  What are types of Linux shells?

 

     There are several shells available with Linux which includes the

     following:

 

     BASH (Bourne Again SHell)

     CSH ( C Shell)

     KSH ( Korn Shell)

     TCSH



Q30.  Explain the work of Ctrl+Alt+Del key combination on the Linux 

      operating system?

 

      It is used to restart the system. there is no confirmation 

      message displayed and a system is rebooted directly.

 


No comments:

Post a Comment