debian系统图像界面和命令行界面互相切换
debian 10.6系统亲测有效
将图像界面切换为命令行界面
查看系统当前的值
systemctl get-default
-
修改配置文件
/etc/default/grub
-
修改内容为:将如下配置文件
# If you change this file, run 'update-grub' afterwards to update # /boot/grub/grub.cfg. # For full documentation of the options in this file, see: # info -f grub -n 'Simple configuration' GRUB_DEFAULT=0 GRUB_TIMEOUT=5 GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian` GRUB_CMDLINE_LINUX_DEFAULT="quiet" GRUB_CMDLINE_LINUX="" # Uncomment to enable BadRAM filtering, modify to suit your needs # This works with Linux (no patch required) and with any kernel that obtains # the memory map information from GRUB (GNU Mach, kernel of FreeBSD ...) #GRUB_BADRAM="0x01234567,0xfefefefe,0x89abcdef,0xefefefef" # Uncomment to disable graphical terminal (grub-pc only) #GRUB_TERMINAL=console # The resolution used on graphical terminal # note that you can use only modes which your graphic card supports via VBE # you can see them in real GRUB with the command `vbeinfo' #GRUB_GFXMODE=640x480 # Uncomment if you don't want GRUB to pass "root=UUID=xxx" parameter to Linux #GRUB_DISABLE_LINUX_UUID=true # Uncomment to disable generation of recovery mode menu entries #GRUB_DISABLE_RECOVERY="true" # Uncomment to get a beep at grub start #GRUB_INIT_TUNE="480 440 1"
修改为:
# If you change this file, run 'update-grub' afterwards to update # /boot/grub/grub.cfg. # For full documentation of the options in this file, see: # info -f grub -n 'Simple configuration' GRUB_DEFAULT=0 GRUB_TIMEOUT=5 GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian` #GRUB_CMDLINE_LINUX_DEFAULT="quiet" #GRUB_CMDLINE_LINUX="" GRUB_CMDLINE_LINUX="text" # Uncomment to enable BadRAM filtering, modify to suit your needs # This works with Linux (no patch required) and with any kernel that obtains # the memory map information from GRUB (GNU Mach, kernel of FreeBSD ...) #GRUB_BADRAM="0x01234567,0xfefefefe,0x89abcdef,0xefefefef" # Uncomment to disable graphical terminal (grub-pc only) #GRUB_TERMINAL=console GRUB_TERMINAL=console # The resolution used on graphical terminal # note that you can use only modes which your graphic card supports via VBE # you can see them in real GRUB with the command `vbeinfo' #GRUB_GFXMODE=640x480 # Uncomment if you don't want GRUB to pass "root=UUID=xxx" parameter to Linux #GRUB_DISABLE_LINUX_UUID=true # Uncomment to disable generation of recovery mode menu entries #GRUB_DISABLE_RECOVERY="true" # Uncomment to get a beep at grub start #GRUB_INIT_TUNE="480 440 1"
注意修改项只有
GRUB_CMDLINE_LINUX_DEFAULT GRUB_CMDLINE_LINUX GRUB_TERMINAL
-
更新grub配置信息
update-grup
user@debian:~$ sudo update-grub Generating grub configuration file ... Found linux image: /boot/vmlinuz-4.19.0-11-amd64 Found initrd image: /boot/initrd.img-4.19.0-11-amd64 done user@debian:~$
-
设置
/etc/systemd/system/default.target
的值systemctl set-default multi-user.target
user@debian:~$ sudo systemctl set-default multi-user.target Removed /etc/systemd/system/default.target. Created symlink /etc/systemd/system/default.target → /lib/systemd/system/multi-user.target. zhxd@debian:~$
该操作即将
/etc/systemd/system/default.target
的值重新链接为/lib/systemd/system/multi-user.target
,默认是/lib/systemd/system/default.target
-
重启服务器
reboot
将命令界面切换为图像界面
-
修改
/etc/default/grup
文件为修改前 -
更新grup配置文件
update-grup
user@debian:~$ sudo update-grub Generating grub configuration file ... Found background image: /usr/share/images/desktop-base/desktop-grub.png Found linux image: /boot/vmlinuz-4.19.0-11-amd64 Found initrd image: /boot/initrd.img-4.19.0-11-amd64 done user@debian:~$
-
设置系统默认配置
/etc/systemd/system/default.target
的值systemctl set-default graphical.target
user@debian:~$ sudo systemctl set-default graphical.target
Removed /etc/systemd/system/default.target.
Created symlink /etc/systemd/system/default.target → /lib/systemd/system/graphical.target.
user@debian:~$
- 重启系统
reboot