Linux Interview Questions

FREE Online Courses: Click for Success, Learn for Free - Start Now!

In this article, we will go through 40 of the most beautiful interview questions based on Linux. So without any further ado, let’s start!

Linux Interview Questions

Q1. What are the different file types in the Linux file system?

In the Linux filesystem, there are 3 main types of files, they are

1. Regular files – This file type is the most common file type in the Linux file system. regular files contain program instructions human-readable text and ASCII characters.

2. Special files – these are the files that represent physical devices for any input and output devices like printers, CD drives, keyboards, mice, etc.

3. Directories – these directories basically mean folder and work just like the folders that are present in the Windows operating system. a directory is a special type of file that stores both regular and special files in a hierarchical order. this hierarchy starts from the root directory which is denoted by a slash (/).

Q2. What is the root directory?

To root directory is exactly like the C folder on windows systems. The root directory is denoted by a slash “/”, that is why any path on Linux starts with a “/”, just like most paths on windows start with “C:\”.

Q3. What is a Linux filesystem?

The Linux file system stores and handles all of the data in form of a file. Without a file system, Linux operating system cannot know where the file starts and ends. Everything in Linux is a file in the filesystem.

Q4. what is the bin directory?

The bin directory contains all 0f the essential user essential binaries or programs that are needed when the system is mounted in single-user mode. Important system programs and utilities such as the bash shell are located in the “/bin” directory whereas applications like Firefox and LibreOffice are stored in the “/usr/bin” directory.

Q5. What is the etc directory?

The etc directory contains the configuration files of the system. These configuration files can generally be edited by hand in a text editor. It must be noted that the etc directory contains only system-wide configuration files and the user configuration files are stored in the user’s home directory.

Q6. Explain the home directory in brief

The home directory is where all the pieces of information about the users in the computer are stored. This directory contains a home folder for every user on the PC. It contains all user data and user-specific configuration files.

Each user can access and modify their own home folder and must have elevated permissions (or sudo privileges) if they wish to modify other user files on the system.

Q7. What is the mnt directory?

The mount or mnt directory is where system administrators mounted temporary file systems while using them. The process of making a file system available to the operating system is called mounting.

Note that some Linux distributions like Debian allocate /floppy and /cdrom as mount points whereas other distros like RHEL put them in /mnt/floppy and /mnt/cdrom.

Q8. Explain the run directory

The run directory gives applications a standard place to store transient files they require (like process ID and sockets). These files cannot be stored in the directory /tmp because tmp might delete them, since tmp stores only temporary files for a specif time period.

Q9. What is the SELinux directory?

If you use Security enhanced Linux for security, the special files used by SE Linux are stored in the directory “/selinux”

Q10. What do you mean by the term managing files?

The term managing files of filesystem management refers to the various tasks we perform on files and directories. These tasks include navigating through directories, finding files, deleting files, moving, copying and pasting files and directories, searching for a specific file, and more.

Q11. What are the different commands to manage the filesystem?

There are many commands that help in filesystem management in Linux, some of them are: pwd, ls, cd, mkdir, rmdir, touch, cat, mv, cp, find, locate, wc, sed, grep, and so many more.

Q12. How does Linux keep its filesystem safe?

Linux is a very secure operating system, it asks you for authentication in the form of a password before running an application or program. However, the first line of defense Linux uses to keep its file systems safe is by using “file permission” or “access rights”

Q13. What are file permissions?

In Linux based operating system, file permissions are the rights that specify who can do what with the files. There are 3 permissions in Linux: read (r), write (w), and execute (x).

Q14. To whom do file persimmons or access rights apply?

The permissions read, write and execute apply to the user, user group, and other users. Permissions are 3 sets of 9 characters, where the first set of 3 characters apply o the user, the second set applies to th users’ group and the last set of 3 characters applies to the other users.

Q15. What is LVM and why is it required?

LVM is the abbreviation for Large Volume Management. It is a storage management device and it increases abstraction, flexibility, and control. Users can perform various tasks like creating, resizing and deleting LVM partitions. LVM is required to gather existing storage devices into the group and allocate logical units.

Q16. What is unmask?

Unmask stands for user file creation mode. When a user creates a file, it has default file permissions, unmask will specify a few restrictions to the newly created file. It basically controls the file permissions.

Q17. How do you change file permissions in Linux?

We can change file permissions by using the chmod command. Using the chmod command we can change file permissions in 3 ways:
a. By using octal notation
b. Symbolic representation
c. specifying the whole permission

Q18. What is a sticky bit?

A sticky bit or restricted deletion flag is a single bit whose interpretation depends on the file type. In directories, it prevents deprived users from removing or renaming any file in that directory unless they own that file.

A restricted deletion flag for a directory is commonly found on world-writable directories like /tmp. For normal files on older systems, the bit saves the program’s text image on the swap device so it loads quicker when run.

Q19. What is the octal notation of permissions?

Octal notation of permissions is where the binary numbers are converted to base – 8 by using the digits 0 to 7 as shown below:

Binary NotationOctal NotationPermissionmeaning
0000No permission
0011–xOnly execute
0102-w-Only write
0113-wxWrite and execute
1004r–Only read
1015r-xRead and execute
1106rw-Read and write
1117rwxRead write and execute

Q20. What are stuid and setgid bits?

The chmod tool clears the set-group-ID bit of a regular file if the file’s group ID does not match either the user’s group ID or one of the user’s supplementary group IDs.

Extra restrictions may cause the set-user-ID (setuid) and set-groupID (setgid) bits of MODE or RFILE to be ignored. This depends on the policy and functionality of the underlying chmod call system.

Q21. What does the permission “635” mean?

The permission 635 (in octal form) stands for “rwx—r-x”.

Q22. What does the permission “721” mean?

The permission 721 stands for “rwx-w—x”. This means that the user can read write and execute, the user group can only write and other can only execute the file.

Q23. What is network bonding in Linux?

Network bonding is the process of combining more than two network interfaces to configure a single network interface. It offers redundancy and improvement of performance by increasing the throughput of the network and bandwidth.

Q24. What happens when you create a new user in Linux?

When we are creating a user In Linux, the system does the following:

1. It assigns a UID to the new user.

2. It creates another new /home directory for the new user.

3. Sets the default shell as /bin/sh for the new user

4. Creates a private user group named after the user name you entered.

5. Contents of the directory “/etc/skel” are copied to the home directory of the new user.

6. It copies files containing environmental variables for the user’s session like .bashrc, .bash_profile, and .bash_logout to the new user’s home directory.

Q25. How do you lock a user account in Linux?

The main reason for locking up a user is for security purpose so that unauthorized users cannot log in. There are many ways of doing the same, here are 3 such ways:

1. Use the “passwd” command to Lock or disable the password

2. We can use the “usermod” or “change” commands to Expire the user account

3. Change the shell using the “nologin” command

Q26. What is the difference between soft and hard mounting points?

The soft mount gives an error report and closes the connection if the user fails to connect to the server whereas, the hard mount, the connection hangs if the client fails to access the server. once the system is up, it again accesses the server.

Q27. How do you terminate a process in Linux?

Every process is uniquely identified with a process identification number (PID). we can pair this PID with the “kill” command to terminate a process.

Q28. What do you think is the best distribution of Linux and why?

I personally think that Linux mint is singlehandedly the best distro of Linux. Linux mint is one of the thousands of distributions of Linux. Some of the features that make it the best are

1. Cinnamon used low memory than GNOME

2. It comes with the best software manager

3. Lots of preinstalled applications

4. Its interface is very compatible

5. The desktop interface is extremely customizable and easy to use

6. Mint does not need powerful hardware to run on

7. It includes every goodie of Linux

8. It gets supported for a very long time

9. Mint disables snap store by default

10. It is free and open source

11. It is lighter and faster than ubuntu (which is already light and fast)

Q29. What are daemons?

Damons are computer programs that run as background processes to provide functions that might not be available in the standard Operating System. They usually run services in the background without directly being in control of interactive users. Daemons handle periodic requests and then forward the requests to appropriate programs for execution.

Q30. What are the different states of processes? Explain them in brief.

Processes have 5 stages from thor creation, they are

1. Creation – a process is normally created when an application or program makes an exact copy of itself in the memory.

2. Running – In this stage, a process is either up and running or ready to run, meaning it is waiting to be assigned to one of the CPUs.

3. Waiting – In this phase, the process is waiting for something (or an event) to occur. It could also be waiting for a particular system resource.

4. Stopped – In this phase, a process is stopped. Processes usually stop by receiving a signal.

5. Zombie – In this state the process, as the name suggests, is dead, meaning it has been stopped and still has an entry in the process table.

Q31. What are internal commands and external command?

Internal commands are the command that is directly run by the shell and there is no separate process to run the commands. External commands are the Commands which are run by the kernel and every single command has its own unique process id.

Q32. What are the differences between BASH and DOS?

There are many differences between BASH and DOS, here are a few:

BASHDOS
Commands in BASH are case sensitiveCommands in DOS are case insensitive
Forward slash (/) in BASH represents directories separatorForward slash (/) in BASH represents command arguments
BASH does not follow conventions naming in files  DOS  follows conventions naming in files  
Double quotes (“) in BASH represents an escape characterDouble quotes (“) in DOS represents directories separator

Q33. What is a stateless Linux server?

A stateless server is a centralized server that does not have any existing states on the working station. It has many scenarios where the user wants all other machines to be in that particular state when a state of a particular system takes a snapshot.

Q34. Explain the feature of a stateless Linux server In brief.

A stateless Linux server has many features, here are 4 of them:
1. It Stores the prototype of every system.
2. It stores the snapshot that was taken.
3. It Stores the home directories.
4. A stateless Linux server uses LDAP, which contains the information about which snapshot should run on which system.

Q35. What is the Zombie process?

A zombie process is a process whose execution is completed but even the information exists in the process table. Once a zombie process is completed using the wait system call, then the zombie process is removed from the process table. The process of a process turning into a zombie only occurs for the child process because the parent process needs to read the child process status.

Q36. What does the key combination “ctrl + alt + delete” do?

The key combination “ctrl + alt + delete” is a shortcut to restart or reboot your system. This key combination works exactly as it does in Microsoft Windows, except for printing a confirmation message before rebooting the system. Therefore, you must be really careful to save all the work before using this key combination.

Q37. What is SSH? Explain in brief

SSH is the abbreviation for Secure Socket Shell or Secure Shell. SSH is a protocol used to connect to a remote server or system securely. It uses an SSH protocol (a secure protocol)as the data transfers between the client and the host takes place in an encrypted manner.

The prime role of the SSH command in Linux is to manage remote systems. Normally, this would be another Linux system, it could also be a router, firewall, or even a computer with a different operating system.
By definition, SSH is a cryptographic network protocol used for an encrypted connection between a client and a server.

Q38. How does SSH work?

to establish an SSH connection, we need two primary components, a client and a host. The host can be a domain name, IP address, server, and more. The client uses the specified host information to establish the connection. If at all the credential provided is verified, an encrypted connection is established.

Q39. What is symmetric encryption?

This technique of encryption generates a simple key for both encrypting and decrypting. This single key is distributed among the hosts and clients and creates a secure connection.

Q40. What is asymmetric encryption?

This technique is the most used and the most secure. It works on the principle of factoring in really large numbers. Asymmetric encryption generated 2 keys called the private and public keys. The private key is used to encrypt messages, while the public key decrypts messages only encrypted using the respective private key.

The private key is kept with the client machine while the public key is distributed to other machines. It must be noted that the private key must be always kept a secret, else it will compromise the entire secure connection.

Summary

This was all about the interview questions of linux. Hope you enjoyed the linux interview questions that contains answers as well.

If you are Happy with DataFlair, do not forget to make us happy with your positive feedback on Google

follow dataflair on YouTube

Leave a Reply

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