Linux System Administrator (21) Welcome to our Linux Interview Questions and Answers Page
We are delighted to have you here! Whether you are an aspiring Linux professional or an experienced one, this page is your go-to resource for all things Linux interview-related. Browse through our curated collection of questions and comprehensive answers to ace your Linux interviews with confidence.
Top 20 Basic Linux interview questions and answers
1. What is Linux?
Linux is an open-source operating system kernel that is based on UNIX and was created by Linus Torvalds in 1991.
2. What is the difference between Unix and Linux?
Unix is a proprietary operating system, whereas Linux is an open-source operating system. Linux is based on Unix and shares many similarities, but Linux offers more flexibility and customization.
3. What is a shell?
A shell is a command-line interface that acts as an intermediary between the user and the Linux kernel. It allows users to execute commands and scripts.
4. How do you find the IP address of a Linux machine?
You can use the command “ifconfig” or “ip addr show” to find the IP address of a Linux machine.
5. What is a root user?
The root user, also known as the superuser or administrator, has full control over a Linux system. It has permission to access and modify all files and directories.
6. How do you change permissions in Linux?
You can use the “chmod” command to change permissions in Linux. The command follows the format “chmod [permissions] [file/directory]”.
7. Explain the difference between a process and a thread.
A process is an instance of a program that is running on a computer, while a thread is a subset of a process. Multiple threads can exist within a single process, and they share the same resources.
8. What is the difference between absolute and relative paths?
An absolute path specifies the exact location of a file or directory in relation to the root directory (/), while a relative path specifies the location of a file or directory in relation to the current directory.
9. How do you kill a process in Linux?
You can use the “kill” command followed by the process ID (PID) to kill a process in Linux. For example, “kill 1234” will terminate the process with PID 1234.
10. What is the purpose of the “grep” command?
The “grep” command is used to search for specific patterns or keywords within files. It is often used in combination with other commands to filter and manipulate data.
11. How do you check the disk space usage in Linux?
You can use the command “df” to check the disk space usage in Linux. Adding the “-h” flag will display the information in a human-readable format.
12. What is the purpose of the “tar” command?
The “tar” command is used for archiving and extracting files. It can combine multiple files into a single archive file (tarball) and compress it using various algorithms.
13. How do you list files in a directory in Linux?
You can use the command “ls” to list files in a directory. Adding the “-l” flag will display more information about each file, such as permissions and file size.
14. What is the purpose of the “find” command?
The “find” command is used to search for files and directories based on various criteria, such as name, size, or modification time. It is a powerful tool for locating specific files within a directory hierarchy.
15. How do you restart the network service in Linux?
You can use the command “/etc/init.d/network restart” or “service network restart” to restart the network service in Linux. Note that the exact command may vary depending on the Linux distribution.
16. What is the purpose of the “chmod” command?
The “chmod” command is used to change the permissions of files or directories in Linux. The permissions determine who can read, write, or execute a file.
17. Explain the difference between soft link and hard link.
A soft link, also known as a symbolic link, is a pointer to a file or directory. It can be created across different file systems and can link to non-existent files. A hard link, on the other hand, is a direct reference to a file or directory and cannot link to non-existent files.
18. What is the purpose of the “man” command?
The “man” command is used to display the manual pages (documentation) of various commands and system functionalities in Linux. It provides detailed information on how to use and configure different aspects of the system.
19. How do you create a user in Linux?
You can use the “useradd” command to create a user in Linux. For example, “useradd username” will create a user with the specified username.
20. What is the purpose of the “ps” command?
The “ps” command is used to display information about currently running processes on a Linux system. Adding the “-aux” flag will show detailed information about all processes.
Top 20 Advanced Linux interview questions and answers
1. What is a Swap space in Linux?
Swap space is a designated area on a hard disk used by the Linux operating system to store inactive pages of memory. It is a form of virtual memory that allows the system to free up RAM for other processes.
2. How do you add a new user to a Linux system?
The command used to add a new user is ‘useradd’. For example, to add a user named “john”, you can use the command: ‘useradd john’.
3. How do you find the size of a directory in Linux?
You can use the ‘du’ command with the ‘-h’ option to display disk usage in human-readable format. For example, to find the size of a directory named “Documents”, use the command: ‘du -h Documents’.
4. How can you check the status of a network interface in Linux?
The ‘ifconfig’ command allows you to check the status of network interfaces in Linux. For example, to check the status of the interface ‘eth0’, use the command: ‘ifconfig eth0’.
5. What is the purpose of the ‘top’ command in Linux?
The ‘top’ command is used to monitor system activity and display information about processes and resource usage in real-time. It provides an overview of CPU usage, memory usage, and other system statistics.
6. How do you find the process ID (PID) of a running process in Linux?
The ‘pgrep’ command can be used to find the process ID (PID) of a running process based on its name. For example, to find the PID of a process named ‘apache2’, use the command: ‘pgrep apache2’.
7. What is the purpose of the ‘cron’ daemon in Linux?
The ‘cron’ daemon is responsible for executing scheduled tasks or commands at specified intervals. It allows users to automate repetitive tasks, such as backups or system maintenance, by scheduling them to run automatically.
8. How can you change the default runlevel in Linux?
To change the default runlevel in Linux, you need to modify the ‘/etc/inittab’ file or use the ‘init’ command. The default runlevel is typically defined as a single-digit number, such as 3 for multi-user mode or 5 for graphical mode.
9. What is the purpose of the ‘chroot’ command in Linux?
The ‘chroot’ command is used to change the root directory of a process to a new location on the file system. It allows you to create a isolated environment for a process, preventing it from accessing files and resources outside the specified directory.
10. How do you find the total number of open files by a user in Linux?
The ‘lsof’ command can be used to list open files and processes. To find the total number of open files by a specific user, use the command: ‘lsof -u username | wc -l’.
11. How do you check the status of a Linux service?
The ‘systemctl’ command is used to check the status of a Linux service. For example, to check the status of the Apache service, use the command: ‘systemctl status apache2’.
12. How do you create a symbolic link in Linux?
The ‘ln’ command is used to create symbolic links in Linux. For example, to create a symbolic link named ‘link’ pointing to a file ‘target’, use the command: ‘ln -s target link’.
13. How can you find the IP address of a Linux system?
The ‘ifconfig’ command or the ‘ip’ command can be used to find the IP address of a Linux system. For example, to find the IP address of the interface ‘eth0’, use the command: ‘ifconfig eth0’ or ‘ip addr show eth0’.
14. How do you monitor system resource usage in Linux?
The ‘sar’ command can be used to monitor system resource usage in Linux. It provides detailed information about CPU usage, memory usage, disk activity, and other system statistics.
15. How do you compress or archive files and directories in Linux?
The ‘tar’ command is used to compress or archive files and directories in Linux. For example, to create a tar archive of a directory named ‘folder’, use the command: ‘tar -czf archive.tar.gz folder’.
16. What is the difference between a hard link and a symbolic link in Linux?
A hard link is a link to a file that points directly to the file’s inode. Deleting the original file does not affect the hard link, as it still references the same inode. In contrast, a symbolic link is a special type of file that points to another file by name. Deleting the original file renders the symbolic link unusable.
17. How do you mount a file system in Linux?
The ‘mount’ command is used to mount file systems in Linux. For example, to mount a file system from a device ‘/dev/sda1’ to a mount point ‘/mnt’, use the command: ‘mount /dev/sda1 /mnt’.
18. How do you check the available disk space in Linux?
The ‘df’ command can be used to check the available disk space in Linux. For example, to display disk usage in human-readable format, use the command: ‘df -h’.
19. What is the purpose of the ‘ssh’ command in Linux?
The ‘ssh’ command allows secure remote login and command execution on a remote system. It encrypts the communication between the local and remote system, providing a secure way to access and manage remote servers.
20. How do you change the ownership of a file or directory in Linux?
The ‘chown’ command is used to change the ownership of a file or directory in Linux. For example, to change the ownership of a file named ‘file’ to user ‘john’, use the command: ‘chown john file’.
Linux System Administrator (21)