如何从 Debian 稳定版切换到测试版
Debian
![](/data/attachment/album/202302/08/122659a4919hso9onkbmun.jpg)


如果你正在寻找最稳定的 Linux 发行版，当然，Debian 是正确的选择。


特别是如果你打算在服务器上使用它。


但是，在桌面方面，情况就有点不同了。我的意思是，你得到的软件包至少是一年前的，对新时代硬件的支持甚至更糟。


那么，在这种情况下，你会怎么做呢？好吧，你可以使用 Debian <ruby> 测试版 <rt>  Testing </rt></ruby>。


但在跳到解释部分之前，让我们简单了解一下 Debian 测试版。


### 什么是 Debian 测试版？


Debian 社区为你提供 3 种不同的 Debian：


* Debian <ruby> 稳定版 <rt>  Stable </rt></ruby>（你从他们的主页上默认得到的东西）。
* Debian <ruby> 测试版 <rt>  Testing </rt></ruby>（有**新的软件包**，比 Debian 不稳定版更少出现故障）。
* Debian <ruby> 不稳定版 <rt>  Unstable </rt></ruby>（拥有最新的软件包，是**所有版本中最脆弱的**）。


因此，Debian 测试版可以被认为是稳定性和新软件包之间的一个折中点。


我已经玩了一段时间的 Debian 测试版，没有遇到任何问题。


事实上，许多 Debian 用户喜欢测试版而不是稳定版。尽管名字叫“测试”，但它是相当可用的。


但是，**我还是建议你在虚拟机上进行实验**，尝试用你的主要工具来使用它，如果事情进展顺利，你可以在主系统中应用这些变化。


### 从 Debian 稳定版切换到 Debian 测试版


**警告：你不能从 Debian 测试版降级到 Debian 稳定版，因为安装脚本和安装工具只是为了用新版本替换旧版本而设计的。**


另外，我建议在你的主机上应用上述步骤之前，[使用 timeshift 创建一个备份](https://itsfoss.com/backup-restore-linux-timeshift/) 。


首先，使用给定的命令更新现有的软件包：



```
sudo apt update && sudo apt upgrade -y

```

接下来，复制原始的 `sources.list` 文件：



```
sudo cp /etc/apt/sources.list sources.list.backup

```

现在，让我们开始第一步的工作。


#### 步骤 1：编辑 sources.list 文件


有两种方法可以编辑 `sources.list` 文件。要么你可以用 `testing` 手动改变当前版本的名称，要么你可以 [使用 sed 命令](https://linuxhandbook.com/sed-command-basics/) 来完成。


而我要用第二种方法来使整个过程更简单。你只需要使用给定的命令，它就会为你把 `bullseye` 替换成 `testing`：



```
sudo sed -i 's/bullseye/testing/g' /etc/apt/sources.list

```

现在，打开你的终端，使用给定的命令来打开 `sources.list` 文件：



```
sudo nano /etc/apt/sources.list

```

并注释掉有 `security.debian.org` 和任何以 `updates` 结尾的行，如下所示：


![comment out security sources](/data/attachment/album/202302/08/122700ihlwek0e5smykiy0.gif)


如果你像我一样使用 `nano`，你可以按 `Alt + /` 跳到该行的最后。然后你要添加以下一行：



```
deb http://security.debian.org testing-security main

```

![add line to keep track of testing in debian](/data/attachment/album/202302/08/122701zkmymj9bi3in96d2.png)


然后 [保存修改并退出 nano](https://linuxhandbook.com/nano-save-exit/) 文本编辑器。


#### 步骤 2：更新仓库并安装新的软件包


现在，更新仓库索引，它会显示大量的更新等待：



```
sudo apt update

```

![update repository in linux](/data/attachment/album/202302/08/122701my4ijyxzyllpirjz.png)


现在，你可以使用给定的命令，它将为你提供最新的软件包：



```
sudo apt upgrade

```

坐下来，放松一下，因为这将需要一些时间。


完成后，它将向你展示从 Debian 稳定版切换到测试版时的变化列表：


![packages that are updated when switched to debian testing](/data/attachment/album/202302/08/122701apn159nihirpkszl.png)


如果你愿意，你可以阅读，或者你可以**直接按** `q` 继续。


现在，它会告诉你，你系统上安装的一些库需要重新启动。按 `TAB` 键，它将选择 “OK”，然后按**回车**：。


![libraries needs to be restarted after update](/data/attachment/album/202302/08/122702n5a5ncc27ccc5zhv.png)


接下来，它会问你是否要在软件包升级期间重启服务。这里你有一个选择。由于我只做桌面使用，我将选择 “YES”。


![restart services during package upgrades without asking?](/data/attachment/album/202302/08/122702a5vccacgbt7i7g27.png)


完成后，你可以重启你的系统，然后使用下面的命令，让你刚才的改变完全生效：



```
sudo apt full-upgrade

```

现在，重启你的系统，你就会拥有最新的软件包。比如**我进入系统时我在运行 GNOME 43**：


![running gnome 43 in debian](/data/attachment/album/202302/08/122702czdiyv8n55i5ijd4.png)


### 总结


在本教程中，我解释了如何从 Debian 稳定版切换到 Debian 测试版。我希望这对你会有帮助。


如果你遇到任何问题或有任何疑问，请在评论中告诉我。




---


via: <https://itsfoss.com/switch-debian-stable-testing/>


作者：[Sagar Sharma](https://itsfoss.com/author/sagar/) 选题：[lkxed](https://github.com/lkxed) 译者：[geekpi](https://github.com/geekpi) 校对：[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)

If you are looking for the most stable Linux distribution, sure, Debian is the right choice.

Especially if you are planning to use it on servers.

But, on the desktop side, things are a bit different. I mean, you are given packages that are at least a year old and support for new-age hardware is even worse.

So what do you do in those cases, Well, you can use Debian testing!

But before jumping to the explanation part, let’s briefly understand Debian testing.

## What is Debian Testing?

Debian offers you 3 variants of Debian:

- Debian stable (what you get by default from their homepage).
- Debian testing (has
**newer packages**and breaks less often than Debian unstable). - Debian unstable (has the most recent packages and is
**considered the most fragile of all**).

So Debian testing can be considered a sweet spot between stability and fresh packages.

I’ve been playing around with Debian testing for some time and haven’t faced any issues.

In fact, many Debian users prefer the testing variant over the stable version. Despite the name testing, it is pretty usable.

But still, **I would recommend you to experiment with this on VM,** try using it with your primary tools and if things go well, you can apply those changes in the main system.

## Switch from Debian stable to Debian testing

*Warning: You can not downgrade from Debian testing to Debian stable, as installer scripts and installation tools are only designed to replace the older version with the new one.*

Also, I would recommend [using timeshift to create a backup](https://itsfoss.com/backup-restore-linux-timeshift/) before applying the shown steps on your main machine.

First, update the existing packages using the given command:

`sudo apt update && sudo apt upgrade -y`


Next, make a copy of original `sources.list`

file:

`sudo cp /etc/apt/sources.list sources.list.backup`


Now, let’s start with the first step.

### Step 1: Edit sources.list file

There are two ways of editing `sources.list`

file. Either you can manually alter the current release name with `testing`

or you can [use the sed command](https://linuxhandbook.com/sed-command-basics/) to get your job done.

And I’m going with a 2nd one to make the whole process easier. You just have to use the given command, and it will replace `bullseye`

with `testing`

for you:

`sudo sed -i 's/bullseye/testing/g' /etc/apt/sources.list`


Now, open your terminal and use the given command to open `sources.list`

files:

`sudo nano /etc/apt/sources.list`


And comment out the lines having `security.debian.org`

and anything that ends with `-updates`

as shown below:

![comment out security sources](https://itsfoss.com/content/images/wordpress/2022/11/comment-out-security-sources.gif)

If you are using nano as I do, you can press `Alt + /`

to jump to the end of the line. And then you have to add the following line:

`deb http://security.debian.org testing-security main`


![2. add line to keep track of testing in debian](https://itsfoss.com/content/images/wordpress/2022/11/2.-add-line-to-keep-track-of-testing-in-debian.png)

And [save the changes and exit from the nano](https://linuxhandbook.com/nano-save-exit/) text editor.

### Step 2: Update the Repository and install new packages

Now, update the repository index, and it will show you a massive update pending:

`sudo apt update`


![update repository in linux](https://itsfoss.com/content/images/wordpress/2022/11/update-repository-in-linux.png)

Now, you can use the given command, and it will get you the most recent packages:

`sudo apt upgrade`


Sit back and relax as it is going to take a while.

Once done, it will present you with the list of changes made as you switched from Debian stable to testing:

![packages that are updated when switched to debian testing](https://itsfoss.com/content/images/wordpress/2022/11/packages-that-are-updated-when-switched-to-debian-testing.png)

You can read if you want or you can **just press q** to proceed further.

Now, it will show you the message that some of the libraries installed on your system needs to restart. Press the **TAB** key, and it will select the **OK** option, and then press **Enter:**

![libraries needs to be restarted after update](https://itsfoss.com/content/images/wordpress/2022/11/libraries-needs-to-be-restarted-after-update.png)

Next, it will ask you whether you want to restart services during the package upgrade. Here you have a choice. As I’m doing this for desktop usage only, I will go with `YES`

:

![restart services during package upgrades without asking?](https://itsfoss.com/content/images/wordpress/2022/11/restart-services-during-package-upgrades-without-asking.png)

Once done, you can reboot your system and then use the following command to have full effect from the changes you’ve just made:

`sudo apt full-upgrade`


Now, reboot your system, and you’ll have the most recent packages. Such as** I was running GNOME 43** when I got into the system:

![running gnome 43 in debian](https://itsfoss.com/content/images/wordpress/2022/11/running-gnome-43-in-debian.png)

## Wrapping Up

In this tutorial, I explained how you could switch from Debian stable to Debian testing. I hope this will be helpful to you.

And if you face any issues or have any queries, let me know in the comments.