Home > Common Problem > What is free in linux

What is free in linux

青灯夜游
Release: 2023-03-02 09:59:14
Original
6960 people have browsed it

In Linux, free is a built-in command to check the memory usage status. It can display the usage status of system physical memory, virtual memory (swap swap partition), shared memory and system cache. The syntax is "free [option] "; The output of the free command is very similar to the memory part of the top command.

What is free in linux

#The operating environment of this tutorial: linux7.3 system, Dell G3 computer.

Linux free command: Check memory usage status

The free command is used to display the system memory status, including system physical memory, virtual memory (swap swap partition), and shared memory And the system cache usage, the output is very similar to the memory part of the top command.

The basic format of the free command is as follows:

# free [选项]
Copy after login

Table 1 lists the commonly used options of this command and their respective meanings.

##- b Displays memory usage in Byte (byte). -k Displays memory usage in KB. This option is the default option of the free command. -m Displays memory usage in MB. -gDisplays memory usage in GB. -tIn the final result of the output, output the total amount of memory and swap partition. -oDo not display the system buffer column. -s Interval seconds Continue to display memory usage according to the specified interval.

free 命令可以显示系统中剩余及已用的物理内存和交换内存,以及共享内存和被核心使用的缓冲区。

如果加上 -h 选项,输出的结果会友好很多:

有时我们需要持续的观察内存的状况,此时可以使用 -s 选项并指定间隔的秒数:

$ free -h -s 3
Copy after login

The above command outputs memory usage every 3 seconds until you press ctrl c.

Since the free command itself is relatively simple, the focus of this article will be on how to understand the current memory usage of the system through the free command.

Introduction to output

Let’s first explain the output content:

Table 1 Free command common options and their meanings
OptionsMeaning