If you’ve got an Ubuntu machine that you initially installed with Ubuntu Desktop, but would like to run as a server, you can just disable the graphical environment from starting up in order to save resources. This is also useful for doing system maintenance from the command line that needs to be performed outside of the GUI.
如果您有一台最初与Ubuntu桌面一起安装的Ubuntu计算机,但想作为服务器运行,则可以仅禁用图形环境以节省资源。 这对于需要在GUI外部执行的命令行进行系统维护也很有用。
The only reason to do this instead of removing the packages would be because you might want to still sometimes use the box through the GUI.
这样做而不是删除软件包的唯一原因是因为您可能有时仍希望通过GUI使用该框。
Disable X.Org
禁用X.Org
In order to disable the graphical environment, we’ll need to disable GDM, the Gnome Display Manager. In order to do this, you’ll need to run the following command at the terminal:
为了禁用图形环境,我们需要禁用GDM(Gnome显示管理器)。 为此,您需要在终端上运行以下命令:
sudo update-rc.d -f gdm remove
sudo update-rc.d -f gdm删除
When you restart your computer, you’ll be presented with a text-mode login prompt instead of the graphical environment.
重新启动计算机时,将显示文本模式登录提示,而不是图形环境。
Run X.Org While Disabled
禁用时运行X.Org
If you want to run the graphical environment, all you have to do is type the following command from the prompt, making sure to run it as your normal user account.
如果要运行图形环境,只需在提示符下键入以下命令,并确保以普通用户帐户运行它。
startx
初学者
The annoying gray screen will go away once Gnome is fully started.
一旦Gnome完全启动,烦人的灰色屏幕就会消失。
Enable X.Org
启用X.Org
If you want to re-enable X11 it’s a simple matter of running this command from the terminal:
如果要重新启用X11,只需在终端上运行以下命令即可:
sudo update-rc.d -f gdm defaults
sudo update-rc.d -f gdm默认
When you restart, you’ll be presented with the graphical prompt again.
重新启动时,将再次显示图形化提示。
翻译自: https://www.howtogeek.com/howto/ubuntu/prevent-xorg-from-starting-in-ubuntu/