debian系统图像界面和命令行界面互相切换

debian系统图像界面和命令行界面互相切换

debian 10.6系统亲测有效

将图像界面切换为命令行界面

查看系统当前的值 systemctl get-default

  1. 修改配置文件/etc/default/grub

  2. 修改内容为:将如下配置文件

    # 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

  3. 更新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:~$ 
    
  4. 设置/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

  5. 重启服务器reboot

将命令界面切换为图像界面

  1. 修改/etc/default/grup文件为修改前

  2. 更新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:~$ 
    
  3. 设置系统默认配置
    /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:~$ 
  1. 重启系统reboot
  • 1
    点赞
  • 16
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值