Linux Interview Questions From Real Interviewer

Linux interview questions
Before we start a technical side, I think the first step to winning an interview is to go through with few things that will help you be successful at the interview.

Analyzing The Position:

It would be best if you began with a systematic review of the job description. Your objective is to collect as much information as possible about how the job and what knowledge and competencies are needed to perform your future job.

Take a close look at the official job description. Consider the environment in which the job is going to be performed. Are there any special skills required? what tools and software you need to know to perform this job.

Make a note of any tools that are being used to perform the tasks of the job, For instance, with the kind of servers, storage protocols, and operating systems they are using, and familiarise yourself with all those tools before the interview.

You can also talk with those who have held the job in the past. If you don’t know anyone, just try to find them through linkedin.com and scan their profiles for tools and skillsets they have used.

Check what competencies and skills contributed to their success? Did the lack of specific competencies or skills cause or contribute to difficulties that they experienced on the job?

What you should have and what interviewers are looking for:

Before they offer you the contract for a long-term relationship with you, they want to know what’s in it for them.

  • Problem-solving skills. It would be best if you have a couple of stories in which you solved the problem independently. Bring any certificate if you got any. 
  • Good people skills. The ability to foster good working relationships is a vital business skill. Discuss situations where you worked well with others. For instance, you can narrate your stories of helping co-workers under challenging conditions.
  • Getting Things Done Skills. The ability to get things done. Mention those times when your good judgment or ingenuity helped you close a deal.
So let’s start our main topic for which you are visiting this post.

1. Tell us about your experience with Linux and the projects you have accomplished?

In response to this question, you should tell your experiences, such as your current or previous job experiences and all the big/small projects you have done. Don’t trust your present memory. Please write it down and try to be fluent in these details.

2. What is the difference between Linux & Unix?

Unix: It is considered the mother of most operating systems. It is a Proprietary operating system and original code developed by AT & T. Originally the Bourne shell. Compatible with PA and Itanium machines. It is also compatible with many command interpreters. AIX and BSD are the renowned flavors of UNIX.
    Linux: The code developed by Linus Torvalds. By default, the shell is BASH (Bourne Again Shell) and can use multiple shells. Ubuntu, Debian , centos, and Redhat are the different flavors of Linux.

      3. What is the shell?

      I think the simplest answer is  “shell is a language to communicate with a computer.”Bash or the Bourne-Again Shell is the most widely used shell among Linux admins.  

      4. What is the structure of Linux filesystem?

      Linux interview Questions form Real interviewer

      All files on a Linux system are stored on file systems, which are inverted into a single inverted tree of directories, known as a file-system hierarchy. This tree is invented because the root of the tree is to be at the top of the hierarchy, and the branches of directories and subdirectories stretch below the root. 
      LOCATIONPURPOSE
      /Is the root directory at the top of the file-system hierarchy.
      /usrIt contains installed software, shared libraries, includes files and read-only program data. Subdirectories include /usr/bin user commands, /usr/sbin/ system admin commands, /usr/local: locally customized software
      /etcconfiguration files specific to this system
      /varvariable data specific to this system that should persist between boots. Files that dynamically change such as databases, cache directories, log files, and website content the most famous one
      /runRuntime data for processes started since the last system boots.
      /homeHome directories are where regular users store their personal data and configuration files
      /tmpThis directory has a world-writable space. Any user can put files here, and within 30 days, the files will be deleted.

      5. Which directory contains regular commands and utilities?

      /usr contains regular commands and utilities.

      6. What is the root account?

      The root account is a system administrator account and has all the powers to give you complete control of the system. Here you can create and maintain user accounts, assigning different permissions for each account. It is the default account every time you install Linux.

      5. How to ensure that newly created users have passwords that must be changed every 90 days?

      you can set password policy from the file /etc/login.defs by changing the value ” PASS_MAX_Days” to 90.

      6. How you will configure the administrative rights for all members of the group named consultants that its members are able to execute any command as any user?

      Create the new file /etc/sudoers.d/consultants and add the following content to it. You can use the sudo vim /etc/sudoers.d/consultants command to perform this step.%consultants ALL=(ALL) ALL

      7. What are symbolic links?

      Symbolic links are files that act as pointers to other files.

      8. If you lost your root password, can you change the root password, and how?

      We can reset the root password, and you can look into this link for the details.

      9. What is initialzation?

      The term “init” is the program on Unix-like system which spawns all other processes. It runs as a daemon and typically has a PID 1.

      10. What is a pstree?

      This is the command to check the running processes.

      11.What will you do if you receive the alert that your partition is full?

      First of all, check which files are the biggest ones on the affected partition. In most cases, log files are there which are causing the troubles, so in this case, you can zip the file after nullifying.

      12. How can you find out that how much memory is being used by your server?

      You can take the help of different tools to find the memory usage on your system.
      free - m
      
      vmstat
      
      top
      
      htop

      17. What is a recommendation of the SWAP partition under a Linux system?

      The recommended size for a swap partition is twice the amount of physical memory available on the system. However, if you cant put the double in size, you can put the same amount as memory in your system.

      18. How to display IP address?

      ip address show

      19. How to displaying the Network performance Statistics?

      ip -s link show ens3       #ens3 is your interface

      20. How to displaying the Routing table?

      ip route

      21. How to Tracing Route Taken by Traffic?

      tracepath access.redhat.com tracepath options ICMP ( -I) TCP (-T)*traceroute command not installed by default

      22. Troubleshooting Ports and Services?

      ss command is meant to replace netstat
      ss -ta
      -n show numbers insted of names for interfaces and ports
      -t show TCP sockets
      -u Show UDP sockets
      -l show listening sockets
      -a show all ( listening and establisted)

      23. How to show the status of the network devices?

             nmcli dev status

      24. How to show the connection status?

               nmcli con show

      25. How to list on active connection?

           nmcli con show --active

      26. How to control network connections?

      You must be able to demonstrate how to control your network connections.
      nmcli con up static-ens3
      nmcli dev dis ens3
      nmcli con show static-ens3
      nmcli con reload
      nmcli con down "static-ens3"
      nmcli con up "static-ens3"

      27. How to remove a network connection?

      nmcli con del static-ens3

      28. What are nmcli commands?

      nmcli dev status : show the networkManagaer stusus of all netwokr interfaces
      nmcli con show : List all connections
      nmcli con show NAME : list the current settings for the connection name
      nmcli con add con-name name Add a new connection named name
      nmcli con mod name modify the connectiuon anem
      nmcli con up name enable it and make it up
      nmcli dev dis devf disconnects it.
      nmacli con del name Deletes

      29. How to change the System hostname?

      hostnameclt set-hostname host@example.com
      hostnamectl status
      hostname

      30. How to test the DNS name resolution?

      host classroom.example.com
      host IP

      31. How to configure the name resolution without the DNS server?

      Command to check the hostname in Redhat is getent hosts hostnameIf you don’t have a DNS server you can configure it through /etc/hosts.getent hosts hostname command can be used to test the hostname resolution using the /etc/hosts file.

      32. How to Manage SELinux?

      Selinux is a set of security rules that determine which process can access which files, directory, and ports. every file process directory and port has a special security label called an SELinux context.By default, policy does not allow any interaction.SELinux has several contexts: user, role, type, and sensitivity.

      33. How to find out the current SELinux policy?

      [root@servera ~]# grep '^SELINUX' /etc/selinux/config
      SELINUX=enforcing
      SELINUXTYPE=targeted
      *if you want to disable you, then replace enforcing to disabled and reboot the server.

      34. How to Change SELinux context?

      This is how you can change the /virtual context
      semanage fcontext -a -t httpd_sys_content_t '/virtual(/.*)?'
      restorecon -RFvv /virtual

      35. How to check the current context?

      ls -zD /virtual OR ls -Zd /var/www
       

      36. How are you troubleshooting SELinux issues?

      You can check the logs from autdit.log
      tail /var/log/audit/audit.log
      
      And do,
      
      less /var/log/messages and search like this / sealert and copy past sealert -l b1c9cc8f-a953-4625-b79b-82c4f4f1fee3
      
      ausearch -m AVC -ts recent
      
      -ts time based search

      39. How to check if ports are open or not?

      There are many ways to perform this activity, but few famous are shown below:by using /etc/services
      # cat /etc/services | grep " 123/"
      Diagnostic Steps
      by using netstat
      # netstat -tulpn | grep :123
      udp 0 0 0.0.0.0:123 0.0.0.0:* 26868/chronyd
      udp6 0 0 :::123 :::* 26868/chronyd
      By using nmap  (nmap is a utility for network discovery and security auditing)
      # nmap -p 123 <server-ip>
      By default nmap would give details of TCP port 123. To get details of 123/udp port use below command :
      Raw
      # nmap -sU -p 123 <server-ip>

      41. what is systemd?

      systemd uses units to manage different types of objects.

      41. What is service units?

      service units have service extensions and represent system services, for example web servers.

      42. What are socket units?

      socket units have a .socket extension and represent inter-process communication sockets that systemd should monitor.

      43. What is path units?

      Path units have .path extension and are used to delay the activation of service until a specific file system change occurred.

      44. What is systemctl?

      It is used to manage units. you can get more information with systemctl -t help

      45. How to check all the services and their status?

      systemctl list-units --type=service

      46. How to view the status of the service in Linux?

      systemctl status name.type
      
      systemctl status sshd.service
      
      systemctl status chronyd

      47. How to verify the status of the service?

      systemctl is-active sshd.service

      47. How to check if service is enabled during boot?

      systemctl is-enabled sshd.service

      48. How to check if the service is failed during boot?

      systemctl is-failed sshd.service

      49. how to display to check all the services failed during boot?

      systemctl is-failed –type=service 

      50. How you define the booting process?

      • The server is powered on. The system firmware runs a POST  (UFFI or BIOS) and stats to initialize the hardware.
      • System firmware searches for a bootable device.
      • System firmware reads a boot loader from the disk and then passes control of the system to the boot loader.
      • In REDHAT boot loader is GRand Unified bootloader version 2 (GRUB2) which loads configuration from this file ( /boot/groub2/grub.cfg).
      • Now, you will have the option to select the kernel and once you select the kernel, the boot loader loads the kernel and Initramfs from the disk.
      • boot loader hands over the kernel to check the location of the intramfs in the memory. Here kernel initiates all the hardware by finding out the drivers.
      • systemd instance from intiramfs executes all units for the initrd.target.

      51. What are the system Targets modes

      systemd targets are represented by targets units, but in earlier versions, prior to RHEL 7, the system was coming with SysV runlevels.

      52. how to check the default target?

      systemctl get-default

      53. how to view the target units?

      systemctl list-units --type target --all

      54. How to change the default target?

      systemctl get-default
      
      systemctl set-default multi-user.target
      
      reboot

      55. How to boot in the rescue mode?

      systemctl rescue

      56. How to check the available subscription?

      subscription-manager list --available | less

      57. How to attach the subscription?

      subscription-manager attach --auto
      The most important yum command
      yum help
      yum list 'http*'
      yum search all 'web server'
      yum info httpd
      yum provides /var/www/html
      yum list kernel
      yum remove httpd
      
      yum group list
      yum group "RPM Development Tools"
      
      
      

      58. All the rpm-related history save in which file?

      /var/log/dnf.rpm.log or yum history

      59. At what location system save your repo files?

      /etc/yum.repos.d/errata.repo

      60. How to check which repos are attached to the system? 

      yum repolist all
                

      Leave a Reply

      Your email address will not be published. Required fields are marked *