1080*80 ad

Top 10 Linux Interview Questions with Examples (Part 3)

Navigating Linux interviews requires solid understanding of core concepts. Here, we delve into some essential questions often encountered, providing clear and concise explanations.

First, let’s clarify a crucial system component: Swap Space. This is a designated area on your hard drive used when the RAM is full. It acts as virtual memory, allowing the system to move less-used pages of memory from RAM to the swap space, freeing up RAM for active processes. While useful, accessing data from swap space is significantly slower than from RAM.

Understanding file linking is key. There’s a notable difference between Soft Links (or Symbolic Links) and Hard Links. A Soft Link is essentially a pointer or shortcut to the original file. If the original file is deleted, the soft link becomes broken or dangling. A Hard Link, however, creates a duplicate entry for the same file inode. Both hard links point to the same data blocks on the disk. Deleting one hard link does not affect the others or the file content until the last hard link is removed. They must reside on the same file system.

When processes interact with the system, they often use standard file descriptors. There are three primary ones: 0 for Standard Input (stdin), representing the input stream to a process (usually the keyboard); 1 for Standard Output (stdout), representing the output stream from a process (usually the terminal display); and 2 for Standard Error (stderr), representing error messages generated by a process (also usually directed to the terminal display).

You might encounter discussion of peculiar process states. A zombie process is a process that has completed its execution but still has an entry in the process table. This happens because the parent process has not yet read its exit status. While they consume minimal system resources beyond the process table entry, too many zombies can become a problem.

At the heart of file system structure is the inode. An inode (index node) is a data structure that stores information about a file or directory, such as its permissions, ownership, timestamp, size, and location of the data blocks on the disk. Each file and directory has a unique inode number within its file system. The file name is stored in the directory entry, pointing to the inode.

To manage processes, you often need their identification number. To find the PID (Process ID) of a running process, you can use commands like ps, pgrep, or pidof. For instance, pgrep process_name will return the PID of the process named process_name.

Linux systems feature a dynamic virtual file system called /proc. The /proc file system is a pseudo-file system that provides information about processes and other system information. Files within /proc are not real files but represent current kernel data and status. It’s a valuable resource for monitoring and tuning the system.

Working with text files often involves editors. The ‘vi’ editor is a powerful, modal text editor. It has several modes, including:

  • Command Mode: The default mode upon opening. Used for navigation, cutting, pasting, and saving files. Commands are executed by single or combined keystrokes.
  • Insert Mode: Used for inserting text. Entered from Command mode by pressing keys like i, a, o. You type directly into the file.
  • Last Line Mode (or Ex Mode): Entered from Command mode by pressing :. Used for executing commands like saving (:w), quitting (:q), search and replace (:s), etc.

Managing users is a fundamental administrative task. To add a user in Linux, you typically use the useradd command. For example, useradd newuser creates a new user account. You’d then usually set a password using passwd newuser. More options are available for specifying home directory, shell, etc.

Finally, controlling access to files is crucial. To change permissions in Linux, you use the chmod command. Permissions are defined for the user (owner), group, and others, allowing read (r), write (w), and execute (x) access. You can specify permissions using either octal numbers (e.g., 755) or symbolic representation (e.g., u+rwx, go=rx). For example, chmod 755 myfile gives the owner read, write, and execute permission, and group and others read and execute permission.

Mastering these concepts provides a strong foundation for tackling Linux interviews and excelling in system administration tasks.

Source: https://www.tecmint.com/linux-interview-questions-and-answers-for-linux-beginners/

900*80 ad

      1080*80 ad