Header Ads

Top 20 Linux interview Question with Answar


1. what is Linux?

Linux is a free, open-source operating system based on the Linux kernel. It is a popular operating system for servers, desktops, and embedded systems. Linux is known for its stability, security, and versatility, and is used by individuals and organizations around the world. Linux is also the foundation for many other operating systems, such as Android and Chrome OS.

  1. What is the Linux kernel?

The Linux kernel is the core of the Linux operating system. It is responsible for managing the system's resources, such as memory and processors, and communicating with hardware devices.

  1. What is a distribution of Linux?

A distribution of Linux is a version of the Linux operating system that includes the Linux kernel and a set of user programs and tools. Some popular distributions of Linux include Red Hat, Ubuntu, and Fedora.

  1. What is a shell in Linux?

A shell in Linux is a command-line interface that allows users to interact with the operating system. Examples of shells in Linux include the Bourne shell (sh) and the Bash shell (bash).

  1. What is the root user in Linux?

The root user in Linux is the superuser account that has full privileges to perform any action on the system. It is typically used for system administration tasks.

  1. How do you create a user in Linux?

To create a user in Linux, you can use the "useradd" command followed by the username. For example: "useradd newuser"

  1. How do you delete a user in Linux?

To delete a user in Linux, you can use the "userdel" command followed by the username. For example: "userdel olduser"

  1. How do you change a user's password in Linux?

To change a user's password in Linux, you can use the "passwd" command followed by the username. For example: "passwd newuser"

  1. What is a process in Linux?

A process in Linux is an instance of a program that is being executed. Each process has a unique process ID (PID) and is assigned a certain amount of memory and CPU resources.

  1. How do you view running processes in Linux?

To view running processes in Linux, you can use the "ps" command. For example: "ps aux"

  1. How do you kill a process in Linux?

To kill a process in Linux, you can use the "kill" command followed by the PID of the process. For example: "kill 12345"

  1. What is a daemon in Linux?

A daemon in Linux is a background process that performs tasks or services for other programs or users. Daemons are often used to perform system-level tasks such as scheduling jobs or running network services.

  1. What is a package manager in Linux?

A package manager in Linux is a software tool that helps to install, update, and manage software packages on a Linux system. Examples of package managers in Linux include yum (for Red Hat-based systems) and apt (for Debian-based systems).

  1. What is a shell script in Linux?

A shell script in Linux is a text file that contains a series of commands that can be executed in sequence. Shell scripts are often used to automate tasks or to perform batch processing.

  1. What is a pipe in Linux?

A pipe in Linux is a way to redirect the output of one command as the input to another command. Pipes are represented by the "|" symbol. For example: "command1 | command2"

  1. What is a cron job in Linux?

A cron job in Linux is a scheduled task that is executed at a predetermined time. Cron jobs are often used to perform routine maintenance tasks or to run scripts at regular intervals.

17. What is the Difference between "du" and "df" command in Linux?

The du command stands for "disk usage," and it is used to show the amount of space used by a file or directory in a file system. The df command stands for "disk free," and it is used to show the amount of available space on a file system.

The du command can be used to show the size of a specific file or directory, or it can be used to show the sizes of all files and directories in a directory tree. It can also be used with options to show the sizes of files and directories in a more readable format, such as in human-readable units (e.g., "1K" for 1 kilobyte).

The df command, on the other hand, shows information about the available space on the file systems on a computer. It can be used to show the available space on a specific file system, or it can be used to show the available space on all file systems. It can also be used with options to show the available space in a more readable format, such as in human-readable units.

In summary, the du command is used to show the space used by files and directories, while the df command is used to show the available space on file systems.

18. What is "sed" command in Linux?

The sed command is a command-line utility in Unix-like operating systems that allows you to edit text in place. It stands for "stream editor," and it is used to perform basic text transformations on an input stream (a file or input from a pipeline).

The sed command reads input line by line, and it can be used to search for specific patterns in the input and replace them with other text. It can also be used to delete lines, insert text, and perform other text manipulation tasks.

Here are a few examples of how the sed command can be used:

  • To replace all occurrences of a string with another string in a file: sed 's/old-string/new-string/g' input-file > output-file

  • To delete all lines that contain a specific string: sed '/string-to-delete/d' input-file > output-file

  • To insert text at a specific line number: sed '3i\ This text will be inserted on line 3' input-file > output-file
The sed command is a powerful tool that can be used to perform a wide range of text manipulation tasks. It is often used in shell scripts and other automated processes to manipulate text data.

19. What is "top" command in Linux?

The top command is a system monitor tool that displays real-time information about the running processes on a Linux system. It provides a dynamic, constantly updated view of the system's processes, including their CPU and memory usage, as well as other information such as the user who owns the process and the command that was used to start the process.

The top command is usually run in an interactive mode, in which it shows the running processes in a list, updating the list in real time. The user can then interact with the top command using keystrokes to perform various tasks, such as sorting the process list by different criteria, killing processes, and changing the way the information is displayed.

Here are a few examples of the types of information that the top command can display:

  • * The total number of running processes and the number of active processes
  • * The CPU utilization and load averages for the system
  • * The total amount of physical and virtual memory on the system, and the amount of memory that is being used
  • * The uptime of the system and the current time

The top command is a useful tool for monitoring the performance and resource usage of a Linux system, and it is often used by system administrators to troubleshoot problems and optimize system performance.

20. what is "awk" command in Linux ?

The awk command is a utility in Unix-like operating systems for processing text files. It is a powerful tool for manipulating and extracting data from text files, and it is often used in shell scripts and other automated processes for data processing and analysis.

awk stands for "Aho, Weinberger, and Kernighan," the creators of the awk programming language. The awk command is used to execute awk programs, which are scripts written in the awk programming language. These programs consist of a series of pattern-action pairs, where the awk command reads the input line by line and performs a specific action for each line that matches a specified pattern.

Here are a few examples of how the awk command can be used:

  • To print the second field (column) of a tab-separated file: awk -F'\t' '{print $2}' input-file

  • To print the second and fourth fields of a comma-separated file: awk -F',' '{print $2, $4}' input-file

  • To print the line number and the input line for all lines that contain a specific string: awk '/string-to-match/ {print NR, $0}' input-file

The awk command is a versatile tool that can be used to perform a wide range of text processing tasks. It is often used in combination with other Unix commands, such as grep and sed, to create complex text processing pipelines.


No comments

Powered by Blogger.