如何在 Ubuntu 中安装 Wine
Wine
![](/data/attachment/album/202307/24/091940obced5d6hj8ozy7p.jpg)



> 
> 想在 Ubuntu 上运行仅限 Windows 的软件？Wine 就是你的朋友。学习在 Ubuntu Linux 中安装 Wine。
> 
> 
> 


只要稍加努力，你可以使用 Wine 来 [在 Linux 上运行 Windows 应用程序](https://itsfoss.com/use-windows-applications-linux/) 。当你必须在 Linux 上运行一个仅有 Windows 版本的应用程序时，Wine 是一个你可以尝试的工具。


请注意：**你不能使用 Wine 来运行每一个 Windows 游戏或软件**。请浏览 [已支持的应用程序的数据库](https://appdb.winehq.org/)。评估为白金级或黄金级的软件更有可能与 Wine 一起平稳的运行。


如果你已经找到一个仅有 Windows 版本的软件，并且 [Wine](https://www.winehq.org/) 也很好地支持它，现在希望使用它，这篇教程将帮助你在 Ubuntu 上安装 Wine 。



> 
> ? 如果你在此之前已经安装了 Wine ，你应该完全地移除它，以避免一些冲突。此外，你应该参考它的 [下载页面](https://wiki.winehq.org/Download) 来获取特定 Linux 发行版的附加说明。
> 
> 
> 


### 在 Ubuntu 上安装 Wine


这里有很多方法来在你的系统上安装 Wine 。几乎所有的 Linux 发行版都在它们的软件包存储库中提供 Wine 。


大多数的时候，Wine 的最新稳定版本都可以通过软件包存储库获得。


* 从 Ubuntu 的存储库中安装 Wine（简单，但是可能不是最新的版本）
* 从 Wine 的存储库中安装 Wine（稍微复杂一些，但是提供最新的版本）


请耐心等待，按照步骤逐步安装和 Wine 。这里有一些相关的步骤。



> 
> ? 请记住，Wine 会安装很多很多的软件包。你将看到一份庞大的软件包列表，安装大小差不多 1.3 GB 。
> 
> 
> 


![Wine download and installed size](/data/attachment/album/202307/24/092011dkikj822okk6mj22.png)


#### 方法 1. 从 Ubuntu 安装 Wine（简单）


Wine 可以在 Ubuntu 的官方存储库中获得，你可以在那里简单地安装它。不过，这种方法获取的版本可能不能最新的。


即使你正在使用一个 64 位的 Ubuntu 安装，你也想要在你的发行版上添加 32 位架构的支持，这将有利于你安装特殊的软件。


输入下面的命令:



```
sudo dpkg --add-architecture i386

```

接下来，安装 Wine 使用:



```
sudo apt update
sudo apt install wine

```

#### 方法 2: 从 Wine 的存储库安装最新的版本


Wine 是一个日新月异的程序。因此，始终建议安装 Wine 的最新稳定版本，以获取更多软件的支持。


首先，移除已存在的 Wine 安装。


步骤 1: 确保添加 32 位架构支持:



```
sudo dpkg --add-architecture i386

```

步骤 2: 下载和添加存储库密钥:



```
sudo mkdir -pm755 /etc/apt/keyrings
sudo wget -O /etc/apt/keyrings/winehq-archive.key https://dl.winehq.org/wine-builds/winehq.key

```

步骤 3: 现在，下载 WineHQ 源文件文件。



> 
> ? 这个步骤取决于你正在使用的 Ubuntu 或 Mint 的版本。请 [检查你的 Ubuntu 版本](https://itsfoss.com/how-to-know-ubuntu-unity-version/) 或 [Mint 版本](https://itsfoss.com/check-linux-mint-version/) 。在你掌握这些信息后，分别使用针对你的相对应的版本的命令。
> 
> 
> 


针对 **Ubuntu 23.04 Lunar Lobster** ，使用下面的命令:



```
sudo wget -NP /etc/apt/sources.list.d/ https://dl.winehq.org/wine-builds/ubuntu/dists/lunar/winehq-lunar.sources

```

如果你持有 **Ubuntu 22.04 或 Linux Mint 21.X 系列**，使用下面的命令:



```
sudo wget -NP /etc/apt/sources.list.d/ https://dl.winehq.org/wine-builds/ubuntu/dists/jammy/winehq-jammy.sources

```

如果你正在运行 **Ubuntu 20.04 或 Linux Mint 20.X 系列**，使用:



```
sudo wget -NP /etc/apt/sources.list.d/ https://dl.winehq.org/wine-builds/ubuntu/dists/focal/winehq-focal.sources

```

**Ubuntu 18.04 或 Linux Mint 19.X 系列**用户，可以使用下面的命令来添加源文件文件:



```
sudo wget -NP /etc/apt/sources.list.d/ https://dl.winehq.org/wine-builds/ubuntu/dists/bionic/winehq-bionic.sources

```

在完成后，更新软件包信息和安装 Wine 的稳定版本软件包。



```
sudo apt install --install-recommends winehq-stable

```

如果你现有开发版本或暂存版本，相应地使用 `winehq-devel` 或 `winehq-staging` 。


### 初始化 Wine 配置


在 Wine 安装后，运行下面的命令:



```
winecfg

```

这将创建用于安装 Windows 应用程序的 **虚拟的 C: 驱动器** 。


![C: Drive created by winecfg in Home directory](/data/attachment/album/202307/24/092011vmcm0100ates3oc9.png)


在按照这些步骤时，有时，你可能在文件管理器的邮件菜单中找不到 “<ruby> 使用 Wine Windows 程序加载器打开 <rt>  Open With Wine Windows Program Loader </rt></ruby>” 的选项。


在这种情况下，通过 [创建软链接](https://learnubuntu.com/ln-command/) 到适当的目录来修复它:



```
sudo ln -s /usr/share/doc/wine/examples/wine.desktop /usr/share/applications/

```

然后，重新启动你的系统来获取更改。


### 使用 Wine 来运行 Windows 应用程序


在你安装 Wine 并通过运行 `winecfg` 将其配置后, 现在是安装 Windows 应用程序的时间了。


在这里，7Zip.exe 文件是用于演示目的的。我知道我应该使用一个更好的示例，因为 7Zip 在 Linux 上是可获得的。不过，对于其它的应用程序来说，接下来的流程是相同的。


首先，从它的 [官方下载页面](https://www.7-zip.org/download.html) 下载 7Zip 文件。


现在，在该文件上右键单击，并选择“使用 Wine Windows 程序加载器打开”选项：


![Open 7zip exe file using Wine WIndows Program Loader in Nemo file manager](/data/attachment/album/202307/24/092012z52epaiyftm7iz5t.png)


这将提示我们安装该文件。单击 “<ruby> 安装 <rt>  <strong>   Install  </strong> </rt></ruby>” 并让其完成。在完成后，你可以像其它的一些原生应用程序一样打开 7zip 。


![Open 7Zip from Ubuntu Activities Overview](/data/attachment/album/202307/24/092043qp9m6app42dfzl2a.jpg)


你可以使用 `wine uninstaller` 命令来卸载任意已安装的应用程序。


这里是一篇关于在 Linux 上 [使用 Wine 来运行 Windows 软件](https://itsfoss.com/use-windows-applications-linux/) 的专业教程。


### 从 Ubuntu 中移除 Wine


如果你没有发现 Wine 有趣，或者，如果 Wine 不能正确地运行你想要的应用程序，你可能需要卸载 Wine 。为此，按照下面的步骤。


#### 通过 Ubuntu 存储库移除已安装的 Wine


为通过存储库移除已安装的 Wine ，首先运行:



```
sudo apt remove --purge wine

```

更新你的软件包信息:



```
sudo apt update

```

现在，使用 `autoclean` 命令来清理本地存储库中已检索取回的几乎不再有用的软件包文件。



```
sudo apt-get autoclean
sudo apt-get clean

```

移除那些已安装但不再需要的软件包:



```
sudo apt autoremove

```

现在，重新启动系统。


#### 如果 Wine 存储库移除 Wine 安装


移除已安装的 `wine-stable` 软件包。



```
sudo apt remove --purge wine-stable

```

更新你的软件包信息:



```
sudo apt update

```

现在，使用 `autoclean` 和 `clean` 命令来清理本地存储库中已检索取回的几乎不再有用的软件包文件。



```
sudo apt-get autoclean
sudo apt-get clean

```

移除先前添加的源文件文件。使用你的相对应的发行版文件夹。在这里，使用的是 Ubuntu 22.04 。



```
sudo rm /etc/apt/sources.list.d/winehq-jammy.sources

```

在这移除后，更新你的系统信息:



```
sudo apt update

```

可选，如果你希望的话，移除你先前添加的密钥文件。



```
sudo rm /etc/apt/keyrings/winehq-archive.key

```

现在，手动移除剩余的一些的文件。


### 还有一些关于使用 Wine 的问题？


你也可以翻阅我们关于使用 Wine 的教程。它应该能回答你可能想要解决的问题。


没有比 Wine 工程的网站更好的地方了。它们有一个专业的常见问题解答页面:



> 
> **[Wine 的 FAQ](https://wiki.winehq.org/FAQ)**
> 
> 
> 


如果你还有问题，你可以浏览 [它们的维基](https://wiki.winehq.org/Main_Page) 来查看详细的 [文档](https://www.winehq.org:443/documentation) 或者在 [它们的论坛](https://forum.winehq.org/) 中询问你的疑问。


或者，如果你不介意花一些钱，你可以选择 CrossOver 。它基本上就是 Wine ，但是有高级的支持。你也可以联系他们的团队来解决你的问题。


我的意见是，在你不能找到一款你必需使用的替换软件时，你应该求助于 Wine 。事实上，在这种情况下，不能保证与 Wine 一起工作。


但是，Wine 为从 Windows 迁移到 Linux 提供了一些希望。




---


via: <https://itsfoss.com/install-wine-ubuntu/>


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


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


OK
![Warp Terminal](/assets/images/warp-terminal.webp)


![Warp Terminal](/assets/images/warp-terminal.webp)

With some effort, you can [run Windows applications on Linux](https://itsfoss.com/use-windows-applications-linux/) using Wine. Wine is a tool you can try when must use an Windows-only application on Linux.

Please note that **you CANNOT run any Windows games or software with Wine**. Please go through the [database of supported applications](https://appdb.winehq.org/). The software rated platinum or gold have a higher chance of running smoothly with Wine.

If you have found a Windows-only software that [Wine](https://www.winehq.org/) supports well and now looking to use it, this tutorial will help you with the Wine installation on Ubuntu.

[download page](https://wiki.winehq.org/Download)for additional instructions for specific Linux distributions.

## Installing Wine on Ubuntu

There are various ways to install Wine on your system. Almost all the Linux distros come with Wine in their package repository.

Most of the time, the latest stable version of Wine is available via the package repository.

**Install WINE from Ubuntu’s repository (easy but may not be the latest version)****Install WINE from Wine’s repository (slightly more complicated but gives the latest version)**

Please be patient and follow the steps one by one to install and use Wine. There are several steps involved here.

![Wine download and installed size](https://itsfoss.com/content/images/2023/01/WINE-download-and-install-size.png)

*Wine download and installed size*

### Method 1. Install WINE from Ubuntu (easy)

Wine is available in Ubuntu's Official repositories, where you can easily install it. However, the version available this way may not be the latest.

Even if you are using a 64-bit installation of Ubuntu, you will need to add 32-bit architecture support on your distro, which will benefit you in installing specific software.

Type in the commands below:

`sudo dpkg --add-architecture i386`


Then install Wine using:

```
sudo apt update
sudo apt install wine
```


### Method 2: Install the latest version from Wine’s repository

Wine is one such program that receives heavy developments in a short period. So, it is always recommended to install the latest stable version of Wine to get more software support.

**First, remove any existing Wine installation**.

**Step 1**: Make sure to add 32-bit architecture support:

`sudo dpkg --add-architecture i386`


**Step 2**: Download and add the repository key:

```
sudo mkdir -pm755 /etc/apt/keyrings
sudo wget -O /etc/apt/keyrings/winehq-archive.key https://dl.winehq.org/wine-builds/winehq.key
```


**Step 3**: Now download the WineHQ sources file.

[check your Ubuntu version](https://itsfoss.com/how-to-know-ubuntu-unity-version/)or

[Mint version](https://itsfoss.com/check-linux-mint-version/). Once you have that information, use the commands for your respective versions.

For **Ubuntu 23.04 Lunar Lobster**, use the command below:

`sudo wget -NP /etc/apt/sources.list.d/ https://dl.winehq.org/wine-builds/ubuntu/dists/lunar/winehq-lunar.sources`


If you have **Ubuntu 22.04 or Linux Mint 21.X series**, use the command below:

`sudo wget -NP /etc/apt/sources.list.d/ https://dl.winehq.org/wine-builds/ubuntu/dists/jammy/winehq-jammy.sources`


If you are running **Ubuntu 20.04 or Linux Mint 20.X series**, use:

`sudo wget -NP /etc/apt/sources.list.d/ https://dl.winehq.org/wine-builds/ubuntu/dists/focal/winehq-focal.sources`


**Ubuntu 18.04 or Linux Mint 19.X series** users can use the command below to add the sources file:

`sudo wget -NP /etc/apt/sources.list.d/ https://dl.winehq.org/wine-builds/ubuntu/dists/bionic/winehq-bionic.sources`


Once done, update the package information and install the wine-stable package.

`sudo apt install --install-recommends winehq-stable`


If you want the development or staging version, use `winehq-devel`

or `winehq-staging`

respectively.

## Initial Wine configuration

Once Wine is installed, run the following:

`winecfg`


This will create the **virtual C: Drive** for installing Windows applications.

![C: Drive created by winecfg in Home directory](https://itsfoss.com/content/images/2023/01/CDrive-in-nautilus.png)

*C: Drive in Nautilus File Manager*

While following these steps, sometimes, you may not find the “**Open With Wine Windows Program Loader**” option in Nautilus right-click menu.

In that case, fix it by [creating a soft link](https://learnubuntu.com/ln-command/) to appropriate directory:

`sudo ln -s /usr/share/doc/wine/examples/wine.desktop /usr/share/applications/`


And restart your system to get the change.

## Using Wine to run Windows applications

Once you have installed Wine and configured it by running `winecfg`

, now is the time to install Windows apps.

Here, the 7Zip.exe file is used for demonstration purposes. I know I should have used a better example, as 7Zip is available on Linux. Still, the process remains the same for other applications.

Firstly, download the 7Zip .exe file from their [official downloads page](https://www.7-zip.org/download.html).

Now, right-click on the file and select "Open With Wine Windows Program Loader" option:

![Open 7zip exe file using Wine WIndows Program Loader in Nemo file manager](https://itsfoss.com/content/images/2023/01/open-exe-file-with-wine.png)

*Open EXE file with Wine Program loader*

This will prompt us to install the file. Click **Install** and let it complete. Once done, you can open the 7zip like any other native app.

![Open 7Zip from Ubuntu Activities Overview](https://itsfoss.com/content/images/2023/01/7-zip-in-Ubuntu-activities-overview.webp)

*7Zip in Ubuntu Activities Overview*

You can use `wine uninstaller`

command to uninstall any installed application.

Here's a dedicated tutorial on [using Wine to run Windows software](https://itsfoss.com/use-windows-applications-linux/) on Linux:

[Run Windows Applications on Linux [Beginners Guide]Here’s a detailed step-by-step guide with screenshots to show how you can run Windows software on Linux using Wine.](https://itsfoss.com/use-windows-applications-linux/)![](https://itsfoss.com/content/images/2023/06/run-windows-apps-on-linux.png)


![](https://itsfoss.com/content/images/2023/06/run-windows-apps-on-linux.png)

## Remove Wine from Ubuntu

If you don't find Wine interesting or if Wine doesn't run the application you want properly, you may need to uninstall Wine. To do this, follow the below steps.

**Remove Wine installed through the Ubuntu repository**

To remove wine installed through repositories, first run:

`sudo apt remove --purge wine`


Update your package information:

`sudo apt update`


Now, use the `autoclean`

command to clear the local repository of retrieved package files that are virtually useless.

```
sudo apt-get autoclean
sudo apt-get clean
```


Remove those packages that are installed but no longer required using:

`sudo apt autoremove`


Now reboot the system.

**Remove Wine installed through the Wine repository**

Remove the installed `wine-stable`

package.

`sudo apt remove --purge wine-stable`


Update your package information:

`sudo apt update`


Now, use the `autoclean`

and `clean`

command to clear the local repository of retrieved package files that are virtually useless.

```
sudo apt-get autoclean
sudo apt-get clean
```


Now remove the sources file added earlier. Use your respective distribution folder. Here, Ubuntu 22.04 is used.

`sudo rm /etc/apt/sources.list.d/winehq-jammy.sources`


Once this is removed, update your system package information:

`sudo apt update`


Optionally, remove the key file you had added earlier if you want.

`sudo rm /etc/apt/keyrings/winehq-archive.key`


Now remove any residual files manually.

## Still have questions about using Wine?

You may also go through our tutorial on using Wine. It should answer some more questions you might have.

[Run Windows Applications on Linux [Beginners Guide]Here’s a detailed step-by-step guide with screenshots to show how you can run Windows software on Linux using Wine.](https://itsfoss.com/use-windows-applications-linux/)![](https://itsfoss.com/content/images/2023/06/run-windows-apps-on-linux.png)


![](https://itsfoss.com/content/images/2023/06/run-windows-apps-on-linux.png)

There is no place better than the Wine Project website. They have a dedicated FAQ (frequently asked questions) page:

If you still have questions, you can browse through [their wiki](https://wiki.winehq.org/Main_Page) for detailed [documentation](https://www.winehq.org/documentation) or ask your doubts in [their forum](https://forum.winehq.org/).

Alternatively, if you don't mind spending some money, you can opt for CrossOver. It's basically Wine but with premium support. You can also contact their team for your questions.

[Purchase CrossOver Through the CodeWeavers Store Today!Buy CrossOver Mac and CrossOver Linux through the CodeWeavers store. Choose from 12 month and lifetime license plans. Renewals are also available for purchase.](https://www.codeweavers.com/store?ad=838)![](https://www.codeweavers.com/images/og-images/og-default.png)


![](https://www.codeweavers.com/images/og-images/og-default.png)

In my opinion, you should resort to Wine only when you cannot find an alternative to the software you must use. Even in that case, it's not guaranteed to work with Wine.

And yet, Wine provides some hope for Windows migrants to Linux.