当前位置: 首页 > news >正文

南昌网站设计企业哪家培训机构好

南昌网站设计企业,哪家培训机构好,建设书法网站的主题是,拓者设计吧邀请码在Windows 安装的Ubuntu,如何修改主机名。有列了两种方法,提供给大家参照。 文章目录 方法一:hostname指令修改方法二:修改配置文件修改hostnanmewsl.conf 文件配置选项推荐阅读 方法一:hostname指令修改 hostname指…

在Windows 安装的Ubuntu,如何修改主机名。有列了两种方法,提供给大家参照。
在这里插入图片描述

文章目录

    • 方法一:hostname指令修改
    • 方法二:修改配置文件修改hostnanme
    • wsl.conf 文件配置选项
    • 推荐阅读

方法一:hostname指令修改

hostname指令修改hostname:

sudo hostname test

修改后,需要reboot,我们可以通过执行特定指令查看是否有修改:

hostname

可以看到hostname已经暂时修改,但

mirror@Y2040001-PC:~$ hostname
test

方法二:修改配置文件修改hostnanme

打开 /etc/wsl.conf wsl.conf这个文件,如果这个文件不存在,则新建:

sudo vi /etc/wsl.conf
hostname = Ubuntu22
generateHosts = false
  • hostname = Ubuntu22将更新/etc/hostname中的主机名
  • generateHosts = false 将阻止WSL自动生成/etc/hosts文件。否则,在重新启动Ubuntu时,hosts文件更改将被覆盖,会出现报错:sudo: unable to resolve host test: Name or service not known
sudo vi /etc/hosts

红框处修改为新的hostname:
在这里插入图片描述

# This file was automatically generated by WSL. To stop automatic generation of this file, add the following entry to /etc/wsl.conf:
# [network]
# generateHosts = false
127.0.0.1       localhost
127.0.1.1       Ubuntu22.localdomain    Ubuntu22                                                                                                                                                                                             127.0.0.1       localhost

修改完成后,保存并退出。关闭子系统或者重新运行子系统,
修改不会立即生效,关闭子系统后必须等待~8秒。必须等待8秒的原因,官方解释如下:

If you launch a distribution (ie. Ubuntu), modify the wsl.conf file, close the distribution, and then re-launch it. You might assume that your changes to the wsl.conf file have immediately gone into effect. This is not currently the case as the subsystem could still be running. You must wait ~8 seconds for the subsystem to stop before relaunching in order to give enough time for your changes to be picked up.

可以在power shell中执行wsl --list --running查看子系统是否仍然还在运行。

PS C:\Users\Administrator> wsl --list --running

如果想要立即停止,可以执行如下:

wsl -t Ubuntu

或者

wsl --shutdown

重新开机子系统,验证hostname修改成功。

mirror@Ubuntu22:~$ hostname
Ubuntu22
mirror@Ubuntu22:~$

wsl.conf 文件配置选项

wsl.conf 文件,有一些配置选项,大家可以根据自己需要参考:

# Automatically mount Windows drive when the distribution is launched
[automount]# Set to true will automount fixed drives (C:/ or D:/) with DrvFs under the root directory set above. Set to false means drives won't be mounted automatically, but need to be mounted manually or with fstab.
enabled = true# Sets the directory where fixed drives will be automatically mounted. This example changes the mount location, so your C-drive would be /c, rather than the default /mnt/c. 
root = /# DrvFs-specific options can be specified.  
options = "metadata,uid=1003,gid=1003,umask=077,fmask=11,case=off"# Sets the `/etc/fstab` file to be processed when a WSL distribution is launched.
mountFsTab = true# Network host settings that enable the DNS server used by WSL 2. This example changes the hostname, sets generateHosts to false, preventing WSL from the default behavior of auto-generating /etc/hosts, and sets generateResolvConf to false, preventing WSL from auto-generating /etc/resolv.conf, so that you can create your own (ie. nameserver 1.1.1.1).
[network]
hostname = DemoHost
generateHosts = false
generateResolvConf = false# Set whether WSL supports interop processes like launching Windows apps and adding path variables. Setting these to false will block the launch of Windows processes and block adding $PATH environment variables.
[interop]
enabled = false
appendWindowsPath = false# Set the user when launching a distribution with WSL.
[user]
default = DemoUser# Set a command to run when a new WSL instance launches. This example starts the Docker container service.
[boot]
command = service docker start

推荐阅读

  • Ubuntu挂载NFS(Network File System) ,怎么解决权限不一致的问题?
  • Ubuntu镜像源cn.arichinve.ubuntu.com不可用原因分析和解决
  • Windows 11安装Ubuntu 实战教程
  • PowerShell无人参与安装最新版本SQL Server Management Studio (SSMS)
  • VRRP(虚拟路由器冗余协议)标准协议工作机制与优势介绍
http://www.zhongyajixie.com/news/46490.html

相关文章:

  • 太原免费网站建设哪个平台可以接推广任务
  • 正规网站建设多少钱买了500元黑科技引流靠谱吗
  • 佛山新网站制作咨询推广平台
  • wordpress建网站知乎竞价关键词优化软件
  • 巩义做网站xd seo东莞seo优化
  • 政务网站建设建议互联网推广公司靠谱吗
  • 同城做鸡网站游戏推广公司好做吗
  • 海淀地区网站建设seo技术员
  • 广州做网站的公司哪家好品牌推广软文200字
  • 重庆网站建设公司多少钱百度指数资讯指数是指什么
  • 哪家做网站做的好百度明星人气榜
  • 企业网站服务器的选择抖音十大搜索关键词
  • 猪八戒网站怎么做任务网站的优化从哪里进行
  • 做服务器的网站的模板爱站网爱情电影网
  • 计算机毕业设计代做网站市场营销网站
  • 软件开发者能看到手机信息吗重庆seo软件
  • wordpress替换函数台州百度快照优化公司
  • 做都是正品的网站很难吗百度一下进入首页
  • 面包屑网站导航怎么做嘉兴网站建设方案优化
  • 云南云南住房和城乡建设厅网站创建网站平台
  • 免费学做淘宝的网站活动策划
  • 年前做招聘网站话术艾滋病多久能检查出来
  • 网站空间租赁运营推广的方式和渠道有哪些
  • 环保公司网站模板河南品牌网络推广外包
  • vue可以做pc端网站吗杭州最好的电商培训机构
  • 网站建设_免费视频百度网站下拉排名
  • 网站建设做网站多少钱长沙网站推广排名优化
  • 如何做静态页网站新网站快速收录
  • 赣州建设信息网山西seo排名
  • 天津网站建设诺亚网销怎么销售的