Summary of the 10 most frequently asked questions in Linux interviews

Summary of the 10 most frequently asked questions in Linux interviews

Preface

If you are going to interview for a Linux system operation and maintenance engineer position, you must be able to answer the following ten most common questions, otherwise your interview may be in danger. These are relatively basic questions, and everyone needs to understand them instead of just memorizing them.

1. How to check the system kernel version

There are two ways to do this:

1) uname -a

The uname command is used to print system information. -a can print all system information, including the kernel version. For example, my version number is 3.10.0-957.21.3.el7.X86_64.

2) cat /proc/version

Here are some additional information on the meanings of the numbers and letters:

  • 3 represents the major version number, which is changed only when there are structural changes (the latest is 5)
  • 10 represents the minor version number, which will change only when new features are added. Generally, cardinality represents a beta version, and even numbers represent a stable version. On March 30, 2020, Linus Torvalds released the latest Linux kernel version 5.6
  • 0 indicates the revision number or patch number of the minor version
  • 957 represents the number of compilations. Each compilation can optimize or modify a small number of programs.
  • el7 is used to indicate special information about the version, which is quite arbitrary; el stands for Enterprise Edition, pp stands for Beta, fc stands for Fedora Core, and rc stands for Candidate Release
  • X86_64 means 64-bit

2. How to view the current IP address of the system

There are also two methods:

1) ifconfig -a

ifconfig is a command used to configure network interfaces. -a can display all current interfaces.

2) ip addr show

3. How to check how much free space is left on the disk

Here you can mainly use the df -ah command to view it. df is a command used to view the disk space usage of the file system. -a displays all file systems, and -h displays them in a human-readable format.

As you can see above, my disk /dev/vda1 has 40 GB, 1.7 GB has been used, and there is 36 GB of free space.

4. How to manage services in the system

Here someone may ask you how to check whether a service is running, how to start, stop, or reload the configuration file. There are also two answers here.

1) Use the service command

View service status

service [servicename] status

Start/Stop/Restart Services

service [servicename] [start|stop|restart]

Reload the service configuration file (without restarting the service)

service [servicename] [reload]

For example, I want to check whether the sshd service is enabled.

2) Use systemctl command

Newer systems have already adopted systemd. systemctl is a tool of systemd, which is mainly responsible for controlling the systemd system and service manager.

View service status

systemctl status [servicename]

Start/Stop/Restart Services

systemctl [start|stop|restart] [servicename]

Reload the service configuration file (without restarting the service)

systemctl [reload] [servicename]

5. How to view the size of a directory

You can use du -sh [directory] command, du is used to calculate the file/directory size command, -s displays the size of the file or the entire directory, -h is in readable format.

For example, I checked the size of the tmp directory in my home directory above, and it is 80K in total.

6. How to check the open port numbers in your system

1) Use the netstat command

The netstat command is used to display network status, including network connections, routing tables, interface statistics, and other information. Commonly used parameters are as follows:

-a (all) displays all options. By default, LISTEN-related options are not displayed.

-t (tcp) Display only tcp related options.

-u (udp) Display only udp related options.

-n refuses to display aliases and converts all displayed numbers into numbers.

-l only lists the services in Listen state.

-p Display the name of the program that creates the relevant link

-r Display routing information, routing table

-e Display extended information, such as uid, etc.

-s Statistics by protocol

-c Execute the netstat command at a fixed time interval.

Below I used the netstat -tulpn command and can see that port 22 is being listened on.

2) Use the ss command

Many people now use the ss command, which is generally used to dump socket statistics. It can also display all types of socket statistics, including PACKET, TCP, UDP, DCCP, RAW, Unix domain, etc. Here you can use ss -lntpd

7. How to view the CPU usage of a process

1) You can use the top command

The top command is a commonly used performance analysis tool under Linux. It can display the resource usage of each process in the system in real time, similar to the Windows Task Manager.

2) Use the ps command

ps aux can display the processes of all users. The most common method is to use ps aux, and then use a pipe symbol to direct to grep to find a specific process. For example, you can use the following command to view the nginx process:

ps aux | grep nginx

8. How to mount in Linux

The main test here is the mount command, which is used to mount files outside the Linux system.

Just enter the mount command to view all files that have been mounted on the system.

If you want to mount a new file, such as /dev/hda1 under /mnt, you can use

mount /dev/hda1 /mnt

9. How to view some commands you are not familiar with

What we want to test you here is the use of man command. If you are not familiar with a Linux command, you can use man <command> and the system will return a very detailed manual for the command to help you use it.

10. What if you still can’t find the answer after using the man command?

Baidu, or seek help from experts in forums and communities...

Of course, mastering only the above ten basic questions is far from enough. Everyone should focus on accumulation in daily work and study; sort out and fully prepare their own experiences and important knowledge points before the interview; adjust their mentality during the interview, answer questions calmly, with clear logic and clear expression. Finally, I wish everyone can find their ideal job.

Summarize

This concludes this article about the 10 most frequently asked questions in Linux interviews. For more information about the most frequently asked questions in Linux interviews, please search 123WORDPRESS.COM’s previous articles or continue browsing the related articles below. I hope you will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • 25 Linux Shell Script Interview Questions Collection
  • Summary of several classic interview questions of C language under Linux (sharing)
  • Share 9 Linux Shell Scripting Tips for Practice and Interviews
  • Detailed discussion of Linux netstat command (essential for senior interviews)
  • C language fork function process operation in Linux and related interview questions explanation
  • Compilation of must-read books for linux c++ server-side development interviews

<<:  JavaScript Canvas implements Tic-Tac-Toe game

>>:  MySQL database optimization: index implementation principle and usage analysis

Recommend

Detailed introduction to Mysql date query

Query the current date SELECT CURRENT_DATE(); SEL...

Implementation of CSS dynamic height transition animation effect

This question originated from a message on Nugget...

Use Navicate to connect to MySQL on Alibaba Cloud Server

1. First enter the server's mysql to modify p...

Vue detailed introductory notes

Table of contents 1. Introduction 2. Initial Vue ...

How to use React to implement image recognition app

Let me show you the effect picture first. Persona...

Docker's flexible implementation of building a PHP environment

Use Docker to build a flexible online PHP environ...

A brief discussion on the maximum number of open files for MySQL system users

What you learn from books is always shallow, and ...

WeChat applet implements a simple dice game

This article shares the specific code of the WeCh...

SQL insert into statement writing method explanation

Method 1: INSERT INTO t1(field1,field2) VALUE(v00...

Vue simulates the shopping cart settlement function

This article example shares the specific code of ...

Graphical introduction to the difference between := and = in MySQL

The difference between := and = = Only when setti...

How to manage users and groups when running Docker

Docker is a management tool that uses processes a...

Detailed steps for installing JDK and Tomcat on Linux cloud server (recommended)

Download and install JDK Step 1: First download t...