Make 命令未找到？这是修复它的方法
make
![](/data/attachment/album/202106/02/203049l51rbr5v55kivg11.jpg)


有一天，我试图在一个新的 Ubuntu 系统上编译一个程序，当我试图使用 `make` 命令时，它向我抛出一个错误：



```
The program 'make' is currently not installed. You can install it by typing:
sudo apt install make

```

这表明 `make` 命令还没有安装。你可以用这些命令在 Ubuntu 上逐步安装 `make`：



```
sudo apt update
sudo apt install make

```

第一个命令是更新本地的软件包缓存。如果是一个新安装的 Ubuntu 系统，这是很有必要的。有了刷新的软件包缓存，你的系统就会知道应该从哪个仓库下载 `make` 包。


并验证 `make` 是否已经正确安装：



```
make --version

```

![Checking make version](/data/attachment/album/202106/02/203058qmrwood959kzfkoa.png)


### 在 Ubuntu 上安装 make 的更好方法


安装 `make` 命令的一个更好的方法是使用 `build-essential` 包。这个包包含 `make`、`gcc`、`g++` 和其他一些编译器和开发工具。



```
sudo apt install build-essential

```

![Installing Build Essential package](/data/attachment/album/202106/02/203059w87mc6vm686nmf6w.png)


安装了这个 `build-essential` 包后，你就可以[在 Linux 中轻松地运行 C/C++ 程序](https://itsfoss.com/c-plus-plus-ubuntu/)。


### 如果 make 已经安装了，但它没有工作怎么办？


在一些罕见的情况下，可能会发生 `make` 已经安装了，但却无法工作的情况。


其原因是 `make` 命令不在 `$PATH` 变量中。你可以用这个命令重新安装 `make`：



```
sudo apt install --reinstall make

```

如果这不起作用，你可以尝试 [手动添加二进制文件到你的 PATH 中](https://itsfoss.com/add-directory-to-path-linux/)，但这应该不需要手动。


我希望这个快速提示能帮助你。仍然有问题或对相关主题有疑问？请随时在评论区留言。




---


via: <https://itsfoss.com/make-command-not-found-ubuntu/>


作者：[Abhishek Prakash](https://itsfoss.com/author/abhishek/) 选题：[lujun9972](https://github.com/lujun9972) 译者：[geekpi](https://github.com/geekpi) 校对：[wxy](https://github.com/wxy)


本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译，[Linux中国](https://linux.cn/) 荣誉推出


OK
The other day I was trying to compile a program on a fresh new Ubuntu system and it threw me an error when I tried to use the make command:

```
The program 'make' is currently not installed. You can install it by typing:
sudo apt install make
```


One of the reasons you see the [bash: command not found error](https://itsfoss.com/bash-command-not-found/) is because the command is not installed on the system. You may install make on Ubuntu using these commands one by one:

```
sudo apt update
sudo apt install make
```


The first command updates the local package cache. It is necessary specially if it is a freshly installed Ubuntu system. With the refreshed package cache, your system would know about the repository from where make package should be downloaded.

And verify that make has been properly installed:

`make --version`


![check make version linux](https://itsfoss.com/content/images/wordpress/2021/05/check-make-version-linux-800x293.png)

## A better way to install make on Ubuntu

An even better way to install make command is to [use the build essential package](https://itsfoss.com/build-essential-ubuntu/). This package contains make, gcc, g++ and several other compilers and developer tools.

`sudo apt install build-essential`


![install build essentials](https://itsfoss.com/content/images/wordpress/2021/05/install-build-essentials-800x410.png)

With this build-essential package installed, you can [easily run C/C++ programs in Linux](https://itsfoss.com/c-plus-plus-ubuntu/).

## What if make is installed but it doesn’t work

In some rare cases, it may happen that make is installed and yet it doesn’t work.

The reason is that make command is not in the $PATH variable. You can either reinstall make with this command:

`sudo apt install --reinstall make`


If that doesn’t work, you may try to [manually add the binary to your PATH](https://itsfoss.com/add-directory-to-path-linux/) but it shouldn’t come to this manual effort.

I hope this quick tip helped you. Still have the problem or question on the related topic? Feel free to use the comment section. I’ll try to help you in my capacity. If you want an even more rapid response, you may [join It’s FOSS Community forum](https://itsfoss.community/). Enjoy :)