✏️
ougege
  • README
  • Docs
    • index
    • Articles
      • AI
        • 体验Chrome AI
        • 体验Cloudflare Workers AI
        • 体验deepseek
      • CSS
        • CSS优化-PurgeCSS
        • 实用效果
        • 开发常用样式
      • Deepin
        • deepin20安装mysql
        • deepin使用tensorflow入门机器学习
        • deepin安装cuda和cuDNN
        • deepin安装lamp
        • deepin安装nvidia驱动
        • deepin安装oh my Zsh
        • deepin安装p7zip
        • deepin换源
        • 安装deepin系统后要做的事
      • Docker
        • CI/CD搭建配置
        • deepin搭建docker环境
        • docker安装和使用gitlab
        • docker搭建nginx+php环境
      • Essay
        • IOS申请邓白氏编码
        • Markdown-Mermaid
        • Markdown Use
        • webview白屏的问题查找和修复
        • 前端开发对接问题和解决办法汇总
        • 国务院机构改革方案
        • 国家级智库
        • 实用网站推荐
        • 常用Markdown数学公式语法
        • 强烈推荐前端要安装的vscode扩展
        • 新建销售计划-页面卡死问题分析
        • 海淘入坑手册
        • 竞品研究
        • 足球知识速成
      • Git
        • GitBook安装和常用命令
        • GitKraken免费版本
        • Git安装和配置
        • Git异常处理
        • Git Worktree使用
        • 前端工程化相关的实用git命令
      • JS
        • ESM模块导出方式对比
        • Emoji多端统一处理
        • JS发布订阅模式
        • JS性能优化
        • JS标准内置对象
        • JS链式调用原理
        • Promise介绍和使用
        • Range的使用
        • Vue+Oauth登录实现
        • Vue实现富文本插入Emoji
        • chrome扩展入门
        • es5新特性
        • es6常用特性
        • es常用片段
        • uniapp使用eslint校验代码
        • 与移动端通信
        • 优秀js库moment
        • 使用vue-socketio
        • 实现一个中间件
        • 小程序webview调试
        • 常用snippets
        • 常用正则
        • 常用的设计模式
        • 微信jssdk封装使用
        • 浏览器宏任务和微任务
        • 浏览器的5种Observer
        • 深入理解赋值、浅拷贝、深拷贝
        • 解析vue指令clickoutside源码
        • 键盘事件与KeyBoardWrapper交互
        • 高德地图常用方法封装
        • 高阶函数片段
      • Network
        • 使用Lighthouse分析前端性能
        • 前后端启用https
        • 宝塔nginx安装ngx_brotli
        • 比较gz与br加载速度
        • 浏览器https提示不安全
        • 浏览器提示HSTS
        • 简单使用tcpdump
        • 静态资源gzip优化
      • Node
        • CommonJS模块导出方式对比
        • Taro command not found 多平台解决方案
        • koa使用和API实现
        • node安装报错Unexpected-token
        • 使用nvm和nrm
        • 使用uniapp给小程序添加云函数
        • 使用verdaccio搭建本地npm仓库
        • 使用vue-cli搭建vue项目
        • 安装Node.js和npm配置
        • 编译成cjs和mjs的思路解析
        • 让你的npmPackage同时支持cjs和mjs
        • 通过GithubAction将内容部署到vps
      • Python
        • Python源管理
        • Python版本管理
        • mitmproxy抓包
        • 微信公众平台开发爬坑经历
      • Shell
        • Ubuntu安装deepin桌面环境
        • Ubuntu安装flatpak软件
        • Ubuntu安装wireshark
        • Ubuntu常见问题汇总
        • dell G3装系统无法识别第二块硬盘
        • linux下virtualbox用gho还原系统
        • mysql常用命令
        • navicat连接一键集成环境的mysql
        • nginx常用命令
        • pm2常用命令
        • virtualbox虚拟机和宿主机互相复制粘贴
        • vps内资源通过mega快传到本地
        • vps报错temporary failure in name resolution
        • vscode修改文件监控数
        • windows+linux双系统引导修复
        • zsh常用插件和命令
        • 一键搭建ChatGPT web版
        • 使用V2ray,CloudFlare Warp解锁GPT
        • 使用vscode进行java开发
        • 利用zx和SSHKey发布代码到服务器
        • 反爬虫一些方案总结和尝试
        • 安装1Panel
        • 安装Bt面板
        • 安装Ubuntu22.04后要做的事
        • 无显示器linux设置默认分辨率
        • 特别实用的shell命令
        • 解决linux安装xmind缺少依赖报错
      • Standards
        • CSS格式化之stylelint
        • CSS规范
        • HTML规范
        • JS规范
        • commit规范
        • 使用husky+commitlint规范代码提交
        • 使用semantic-release自动管理版本号
        • 命名规范
        • 图片规范
        • 版本编号规范
      • Wall
        • 科学上网-Cloudflare-Pages
        • 科学上网-Cloudflare-Warp
        • 科学上网-Geph
        • 科学上网-RackNerd
        • 科学上网-Slicehosting
        • 科学上网-Surfshark
        • 科学上网-Tor
        • 科学上网-XX-NET
        • 科学上网-heroku
        • 科学上网-shadowsock
        • 科学上网-v2ray使用
        • 科学上网-v2ray搭建
        • 科学上网-浏览器代理
        • 科学上网-让终端走代理
      • Windows
        • SourceTree破解免登录(windows版)
        • git bash交互提示符不工作
        • nexus 7 2013 wifi 刷机
        • tree命令生成文件目录
        • 利用charles抓包app
        • 安装Openssl
        • 安装msi文件报错2503和2502
        • 神器vimium使用说明
        • 自用host
        • 解决win10扩展出来的屏幕模糊
        • 解决安装Adobe Air时发生错误
    • Snippets
      • zsh
        • docker
        • extract
        • git-commit
        • git
        • mysql-macports
        • npm
        • nvm
        • pip
        • pm2
        • systemd
        • ubuntu
        • vscode
Powered by GitBook
On this page
  • 介绍
  • xrandr命令
  • 安装虚拟显示器
  • 配置xorg.conf
  • 使用nvidia-xconfig生成xorg配置
  • 参考

Was this helpful?

  1. Docs
  2. Articles
  3. Shell

无显示器linux设置默认分辨率

介绍

使用 teamview 远程连接无显示器的主机时,默认分辨率会被设置为 640x480,显示的内容有限,操作非常不便。

xrandr命令

# 查看当前分辨率
xrandr
# 设置分辨率(进对有显示器生效)
xrandr -s 1920x1080
xrandr --output VGA-1 --mode 1920x1080

安装虚拟显示器

# 安装xserver-xorg-video-dummy
sudo apt install xserver-xorg-video-dummy

配置xorg.conf

# 进入xorg配置目录
sudo cd /etx/X11
# 备份原始配置文件
sudo cp xorg.conf xorg.conf.bak
# 编辑xorg.conf文件
sudo gedit xorg.conf

粘贴以下内容到 xorg.conf 文件中: ::: details

# This xorg configuration file will start a dummy X11 server.
# move it to /etc/X11/xorg.conf
# don't forget apt install xserver-xorg-video-dummy;
# based on https://xpra.org/Xdummy.html

Section "ServerFlags"
  Option "DontVTSwitch" "true"
  Option "AllowMouseOpenFail" "true"
  Option "PciForceNone" "true"
  Option "AutoEnableDevices" "false"
  Option "AutoAddDevices" "false"
EndSection

Section "InputDevice"
  Identifier "dummy_mouse"
  Option "CorePointer" "true"
  Driver "void"
EndSection

Section "InputDevice"
  Identifier "dummy_keyboard"
  Option "CoreKeyboard" "true"
  Driver "void"
EndSection

Section "Device"
  Identifier "dummy_videocard"
  Driver "dummy"
  Option "ConstantDPI" "true"
  #VideoRam 4096000
  #VideoRam 256000
  VideoRam 192000
EndSection

Section "Monitor"
  Identifier "dummy_monitor"
  HorizSync   5.0 - 1000.0
  VertRefresh 5.0 - 200.0
  #To add your own modes here, use a modeline calculator, like:
  #http://xtiming.sourceforge.net/cgi-bin/xtiming.pl
  #or using the "gtf" command line tool (http://gtf.sourceforge.net/)

  #This can be used to get a specific DPI, but only for the default resolution:
  #DisplaySize 508 317
  #NOTE: the highest modes will not work without increasing the VideoRam
  # for the dummy video card.
  Modeline "32768x32768" 15226.50 32768 35800 39488 46208 32768 32771 32781 32953
  Modeline "32768x16384" 7516.25 32768 35544 39192 45616 16384 16387 16397 16478
  Modeline "16384x8192" 2101.93 16384 16416 24400 24432 8192 8390 8403 8602
  Modeline "8192x4096" 424.46 8192 8224 9832 9864 4096 4195 4202 4301
  Modeline "6400x2160" 160.51 6400 6432 7040 7072 2160 2212 2216 2269
  Modeline "5680x1440" 142.66 5680 5712 6248 6280 1440 1474 1478 1513
  Modeline "5496x1200" 199.13 5496 5528 6280 6312 1200 1228 1233 1261
  Modeline "5280x1080" 169.96 5280 5312 5952 5984 1080 1105 1110 1135
  Modeline "5280x1200" 191.40 5280 5312 6032 6064 1200 1228 1233 1261
  Modeline "5120x3200" 199.75 5120 5152 5904 5936 3200 3277 3283 3361
  Modeline "4800x1200" 64.42 4800 4832 5072 5104 1200 1229 1231 1261
  Modeline "4720x3840" 227.86 4720 4752 5616 5648 3840 3933 3940 4033
  Modeline "3840x2880" 133.43 3840 3872 4376 4408 2880 2950 2955 3025
  Modeline "3840x2560" 116.93 3840 3872 4312 4344 2560 2622 2627 2689
  Modeline "3840x2048" 91.45 3840 3872 4216 4248 2048 2097 2101 2151
  Modeline "3840x1200" 108.89 3840 3872 4280 4312 1200 1228 1232 1261
  Modeline "3840x1080" 100.38 3840 3848 4216 4592 1080 1081 1084 1093
  Modeline "3864x1050" 338.00 3864 4112 4520 5176 1050 1053 1063 1089
  Modeline "3600x1200" 106.06 3600 3632 3984 4368 1200 1201 1204 1214
  Modeline "3600x1080" 91.02 3600 3632 3976 4008 1080 1105 1109 1135
  Modeline "3520x1196" 99.53 3520 3552 3928 3960 1196 1224 1228 1256
  Modeline "3360x1050" 293.75 3360 3576 3928 4496 1050 1053 1063 1089
  Modeline "3288x1080" 39.76 3288 3320 3464 3496 1080 1106 1108 1135
  Modeline "3120x1050" 272.75 3120 3320 3648 4176 1050 1053 1063 1089
  Modeline "2728x1680" 148.02 2728 2760 3320 3352 1680 1719 1726 1765
  Modeline "2048x2048" 49.47 2048 2080 2264 2296 2048 2097 2101 2151
  Modeline "2048x1536" 80.06 2048 2104 2312 2576 1536 1537 1540 1554
  Modeline "2048x1152" 197.97 2048 2184 2408 2768 1152 1153 1156 1192
  Modeline "2560x1600" 47.12 2560 2592 2768 2800 1600 1639 1642 1681
  Modeline "2560x1440" 42.12 2560 2592 2752 2784 1440 1475 1478 1513
  Modeline "1920x1440" 69.47 1920 1960 2152 2384 1440 1441 1444 1457
  Modeline "1920x1200" 26.28 1920 1952 2048 2080 1200 1229 1231 1261
  Modeline "1920x1080" 23.53 1920 1952 2040 2072 1080 1106 1108 1135
  Modeline "1680x1050" 20.08 1680 1712 1784 1816 1050 1075 1077 1103
  Modeline "1600x1200" 22.04 1600 1632 1712 1744 1200 1229 1231 1261
  Modeline "1600x900" 33.92 1600 1632 1760 1792 900 921 924 946
  Modeline "1440x900" 30.66 1440 1472 1584 1616 900 921 924 946
  ModeLine "1366x768" 72.00 1366 1414 1446 1494  768 771 777 803
  Modeline "1280x1024" 31.50 1280 1312 1424 1456 1024 1048 1052 1076
  Modeline "1280x800" 24.15 1280 1312 1400 1432 800 819 822 841
  Modeline "1280x768" 23.11 1280 1312 1392 1424 768 786 789 807
  Modeline "1360x768" 24.49 1360 1392 1480 1512 768 786 789 807
  Modeline "1024x768" 18.71 1024 1056 1120 1152 768 786 789 807
  Modeline "768x1024" 19.50 768 800 872 904 1024 1048 1052 1076


  #common resolutions for android devices (both orientations):
  Modeline "800x1280" 25.89 800 832 928 960 1280 1310 1315 1345
  Modeline "1280x800" 24.15 1280 1312 1400 1432 800 819 822 841
  Modeline "720x1280" 30.22 720 752 864 896 1280 1309 1315 1345
  Modeline "1280x720" 27.41 1280 1312 1416 1448 720 737 740 757
  Modeline "768x1024" 24.93 768 800 888 920 1024 1047 1052 1076
  Modeline "1024x768" 23.77 1024 1056 1144 1176 768 785 789 807
  Modeline "600x1024" 19.90 600 632 704 736 1024 1047 1052 1076
  Modeline "1024x600" 18.26 1024 1056 1120 1152 600 614 617 631
  Modeline "536x960" 16.74 536 568 624 656 960 982 986 1009
  Modeline "960x536" 15.23 960 992 1048 1080 536 548 551 563
  Modeline "600x800" 15.17 600 632 688 720 800 818 822 841
  Modeline "800x600" 14.50 800 832 880 912 600 614 617 631
  Modeline "480x854" 13.34 480 512 560 592 854 873 877 897
  Modeline "848x480" 12.09 848 880 920 952 480 491 493 505
  Modeline "480x800" 12.43 480 512 552 584 800 818 822 841
  Modeline "800x480" 11.46 800 832 872 904 480 491 493 505
  #resolutions for android devices (both orientations)
  #minus the status bar
  #38px status bar (and width rounded up)
  Modeline "800x1242" 25.03 800 832 920 952 1242 1271 1275 1305
  Modeline "1280x762" 22.93 1280 1312 1392 1424 762 780 783 801
  Modeline "720x1242" 29.20 720 752 856 888 1242 1271 1276 1305
  Modeline "1280x682" 25.85 1280 1312 1408 1440 682 698 701 717
  Modeline "768x986" 23.90 768 800 888 920 986 1009 1013 1036
  Modeline "1024x730" 22.50 1024 1056 1136 1168 730 747 750 767
  Modeline "600x986" 19.07 600 632 704 736 986 1009 1013 1036
  Modeline "1024x562" 17.03 1024 1056 1120 1152 562 575 578 591
  Modeline "536x922" 16.01 536 568 624 656 922 943 947 969
  Modeline "960x498" 14.09 960 992 1040 1072 498 509 511 523
  Modeline "600x762" 14.39 600 632 680 712 762 779 783 801
  Modeline "800x562" 13.52 800 832 880 912 562 575 578 591
  Modeline "480x810" 12.59 480 512 552 584 810 828 832 851
  Modeline "848x442" 11.09 848 880 920 952 442 452 454 465
  Modeline "480x762" 11.79 480 512 552 584 762 779 783 801
EndSection

Section "Screen"
  Identifier "dummy_screen"
  Device "dummy_videocard"
  Monitor "dummy_monitor"
  DefaultDepth 24
  SubSection "Display"
    Viewport 0 0
    Depth 24
    #Modes "32768x32768" "32768x16384" "16384x8192" "8192x4096" "5120x3200" "3840x2880" "3840x2560" "3840x2048" "2048x2048" "2560x1600" "1920x1440" "1920x1200" "1920x1080" "1600x1200" "1680x1050" "1600x900" "1400x1050" "1440x900" "1280x1024" "1366x768" "1280x800" "1024x768" "1024x600" "800x600" "320x200"
    Modes "5120x3200" "3840x2880" "3840x2560" "3840x2048" "2048x2048" "2560x1600" "1920x1440" "1920x1200" "1920x1080" "1600x1200" "1680x1050" "1600x900" "1400x1050" "1440x900" "1280x1024" "1366x768" "1280x800" "1024x768" "1024x600" "800x600" "320x200"
    #Virtual 32000 32000
    #Virtual 16384 8192
    #Virtual 8192 4096
    #Virtual 5120 3200
    Virtual 1024 768
  EndSubSection
EndSection

Section "ServerLayout"
  Identifier   "dummy_layout"
  Screen       "dummy_screen"
  InputDevice  "dummy_mouse"
  InputDevice  "dummy_keyboard"
EndSection

:::

保存并重启

::: warning 注意 Identifier :虚拟显示器的名称,你可以根据需要自定义。

Driver :虚拟显示器的驱动程序,这里应该选择dummy。

Modeline :虚拟显示器的显示模式,你可以根据需要选择适当的模式。

Viewport :虚拟显示器的显示区域,你可以根据需要设置。

我们只需要将 Virtual 1024 768 改成适合你的分辨率,比如 Virtual 2560 1440,如果首次进入没有识别分辨率,可以进显示设置选择合适分辨率 :::

使用nvidia-xconfig生成xorg配置

# 方法一:
# 使用nvidia-xconfig生成xorg配置
sudo nvidia-xconfig
# 编辑xorg.conf文件,将 Virtual 2560 1440 加入到 Section "Screen" 中
# 保存,重启

# 方法二:
# 使用nvidia-xconfig命令加参数生成xorg配置
sudo nvidia-xconfig --use-display-device=all --virtual=2560x1440

::: warning 注意 使用 nvidia-xconfig 配置虽然简单,但是会导致显示无法显示底部菜单(本人使用 deepin23 测试,其他系统可能也会出现类似问题) :::

参考

Previous安装Ubuntu22.04后要做的事Next特别实用的shell命令

Last updated 11 months ago

Was this helpful?

Ubuntu虚拟显示器且远程控制(无显示器接入)
linux 下更改分辨率
ubuntu设置虚拟显示器且远程连接
解决Todesk、向日葵等远程访问“无显示器”主机黑屏问题
X11 Dummy configuration.txt
如何通过nvidia-xconfig开启默认显示器