Senario

本来我是想要修改下 machine name

在Ubuntu中的步骤是这样的

1 sudo hostname newMechineName
2 sudo vi /etc/hostname
  把原来的机器名改为新的 newMechineName
3 sudo vi /etc/hosts
  修改 127.0.1.1 对应的计算机名为新的计算机名称

先要修改下 hosts 文件

因为刚用 cygwin, 对系统不是很熟, 只是以为 cygwin 系统是一个封闭的系统放在宿主机器的某个文档夹里面

经过此次发掘,搞清楚 cygwin 和 host machine 的关系

ganiks.liu@MAMIS-Gaiks-Liu ~
$ gvim /etc/hosts

ganiks.liu@MAMIS-Gaiks-Liu ~
$ ll /etc/hosts
lrwxrwxrwx 1 Administrators root 46 Jul 25 13:34 /etc/hosts -> /cygdrive/c/WINDOWS/system32/drivers/etc/hosts

ganiks.liu@MAMIS-Gaiks-Liu ~
$ vim /etc/hosts
/cygdrive/d/Program Files/Git/bin/vim: line 3: /share/vim/vim74/vim: No such file or directory
/cygdrive/d/Program Files/Git/bin/vim: line 3: exec: /share/vim/vim74/vim: cannot execute: No such file or directory
#无法打开
ganiks.liu@MAMIS-Gaiks-Liu ~
$ vi /etc/hosts
#正常打开
ganiks.liu@MAMIS-Gaiks-Liu ~
$ gvim /etc/hosts
#这里打开文件时空的

cygwin中用的 命令/程序 都来自哪里?

只有 vi 可以打开 /etc/hosts

ok, 问题明白了, 就是权限问题

要搞清楚 vi, vim, gvim 分别是属于哪里的就明白了

  • vi
  • vim
  • gvim
ganiks.liu@MAMIS-Gaiks-Liu ~
$ whereis.exe vi
vi: /usr/bin/vi.exe /cygdrive/d/Program Files/Git/bin/vi

ganiks.liu@MAMIS-Gaiks-Liu ~
$ whereis.exe vim
vim: /cygdrive/d/Program Files/Git/bin/vim /cygdrive/d/Program Files/Vim/vim74/vim.exe

ganiks.liu@MAMIS-Gaiks-Liu ~
$ whereis.exe gvim
gvim: /cygdrive/d/Program Files/Vim/vim74/gvim.exe

ganiks.liu@MAMIS-Gaiks-Liu ~
$

让 cygwin 系统支持权限(chmod, chown)

说到权限, 这里还有一点要注意

最开始我的 cygwin 装在 E:\ 盘上, 当时 E:\ 的格式是 Fat32

然后用到 chmod 命令的时候失效 :参考另一篇文章

http://www.cnblogs.com/ganiks/p/cygwin-chmod-not-support.html

转换为 NTFS 格式之后, 支持了权限的管理, 有个细节要注意到就是所有文档的 USER:GROUP 变化啦

drwxr-xr-x 1 ganiks.liu Domain Users 0 Jul 25 13:28 .
drwxr-xr-x 1 ganiks.liu Domain Users 0 Jul 25 13:10 ..
drwxr-xr-x 1 ganiks.liu Domain Users 0 Jul 25 13:49 uscreens

# 转换 NTFS 之后
ganiks.liu@MAMIS-Gaiks-Liu /tmp
$ ll
total 0
drwxrwx---+ 1 Administrators root 0 Jul 25 13:28 .
drwxrwx---+ 1 Administrators root 0 Jul 25 13:10 ..
drwxrwxrwx+ 1 ganiks.liu     root 0 Jul 25 13:49 uscreens

ganiks.liu@MAMIS-Gaiks-Liu /tmp
$

cygwin 跟宿主系统的关系是什么?

ganiks.liu@MAMIS-Gaiks-Liu ~
$ ll /etc/
total 537
drwxrwx---+ 1 Administrators root      0 Jul 26 08:45 .
drwxrwx---+ 1 Administrators root      0 Jul 25 13:10 ..
drwxrwx---+ 1 Administrators root      0 Jul 25 13:28 alternatives
-rwxrwx---+ 1 Administrators root    856 Jul 25 13:35 bash.bash_logout
-rwxrwx---+ 1 Administrators root   1176 Jul 25 13:35 bash.bashrc
-rwxrwx---+ 1 Administrators root  58352 Feb 12  2011 bash_completion
drwxrwx---+ 1 Administrators root      0 Jul 25 13:28 bash_completion.d
drwxrwx---+ 1 Administrators root      0 Jul 25 13:28 dbus-1
drwxrwx---+ 1 Administrators root      0 Jul 25 13:28 defaults
-rwxrwx---+ 1 Administrators root   5023 Jul 25 13:34 DIR_COLORS
-rwxrwx---+ 1 Administrators root   3095 Jul 22 11:00 drirc
drwxrwx---+ 1 Administrators root      0 Jul 25 13:29 fonts
-rwxrwx---+ 1 Administrators root    192 Jul 25 13:34 fstab
drwxrwx---+ 1 Administrators root      0 Jul 25 13:34 fstab.d
-rwxrwx---+ 1 Administrators root    560 Jul 25 13:34 group
drwxrwx---+ 1 Administrators root      0 Jul 25 13:29 gtk-2.0
lrwxrwxrwx  1 Administrators root     46 Jul 25 13:34 hosts -> /cygdrive/c/WINDOWS/system32/drivers/etc/hosts
-rwxrwx---+ 1 Administrators root 149610 May  8  2012 lynx.cfg
-rwxrwx---+ 1 Administrators root   3583 May  8  2012 lynx.lss
-rwxrwx---+ 1 Administrators root     66 Jul 25 13:35 lynx-site.cfg
-rwxrwx---+ 1 Administrators root   5135 Jul 25 13:35 man_db.conf
-rwxrwx---+ 1 Administrators root 242153 May 24 02:59 moduli
lrwxrwxrwx  1 Administrators root     12 Jul 25 13:34 mtab -> /proc/mounts
lrwxrwxrwx  1 Administrators root     49 Jul 25 13:34 networks -> /cygdrive/c/WINDOWS/system32/drivers/etc/networks
drwxrwx---+ 1 Administrators root      0 Jul 25 13:35 pango
-rwxrwx---+ 1 Administrators root    943 Jul 25 13:34 passwd
drwxrwx---+ 1 Administrators root      0 Jul 25 13:30 pkcs11
drwxrwx---+ 1 Administrators root      0 Jul 25 13:28 pki
drwxrwx---+ 1 Administrators root      0 Jul 25 13:28 postinstall
drwxrwx---+ 1 Administrators root      0 Jul 25 13:28 preremove
-rwxrwx---+ 1 Administrators root   7634 Jul 25 13:35 profile
drwxrwx---+ 1 Administrators root      0 Jul 25 13:28 profile.d
lrwxrwxrwx  1 Administrators root     50 Jul 25 13:34 protocols -> /cygdrive/c/WINDOWS/system32/drivers/etc/protocols
-rwxrwx---+ 1 Administrators root  51799 Jul 25 13:34 rebase.db.i386
drwxrwx---+ 1 Administrators root      0 Jul 25 13:30 sasl2
lrwxrwxrwx  1 Administrators root     49 Jul 25 13:34 services -> /cygdrive/c/WINDOWS/system32/drivers/etc/services
drwxrwx---+ 1 Administrators root      0 Jul 25 13:10 setup
-rwxrwx---+ 1 Administrators root    210 Jul 25 13:35 shells
drwxrwx---+ 1 Administrators root      0 Jul 25 13:35 skel
drwxrwx---+ 1 Administrators root      0 Jul 25 13:28 ssl
-rwxrwx---+ 1 Administrators root   4795 Jul 25 13:46 wgetrc
drwxrwx---+ 1 Administrators root      0 Jul 25 13:35 xml

看看 hosts -> /cygdrive/c/WINDOWS/system32/drivers/etc/hosts

明白了吧, 原来想要访问宿主系统, 只需要进入到 /cygdrive/ 目录下 !

越是想要了解一个东西,越是不能放过任何一个小小的疑问
这里就是因为想要修改 machine name 就让我发现这么重要的一个对 cygwin 认知。

最终没有修改成功 hostname

ganiks.liu@MAMIS-Gaiks-Liu ~
$ hostname.exe wswtech
hostname: cannot set hostname; this system lacks the functionality

介绍一篇不错的 cygwin 入门教程:

http://w.gdu.me/wiki/cygwin/index.html

cygwin and its host machine的更多相关文章

  1. C# Socket 您的主机中的软件中止了一个已建立的连接 An established connection was aborted by the software in your host machine

    http://tieba.baidu.com/p/3223234493 问题: 服务端在接收客户端数据的时候,抛了个异常出来:System.Net.Sockets.SocketException: 您 ...

  2. Extended paging tables to map guest physical memory addresses from virtual memory page tables to host physical memory addresses in a virtual machine system

    A processor including a virtualization system of the processor with a memory virtualization support ...

  3. Installing Cygwin and Starting the SSH Daemon

    This chapter explains how to install Cygwin and start the SSH daemon on Microsoft Windows hosts. Thi ...

  4. Docker Machine, Compose, and Swarm: How They Work Together

    The three tools are now neatly packaged into what’s called the Docker Toolbox. Docker Machine1/ crea ...

  5. 使用Vagrant machine

    使用Vagrant 查看Vagrant状态 vagrant status SSH vagrant ssh 共享文件 在vagrantfile中添加共享文件配置 Vagrant.configure(2) ...

  6. Docker教程:dokcer machine的概念和安装

    http://blog.csdn.net/pipisorry/article/details/50920982 Docker machine介绍 做为Docker容器集群管理三剑客之一的Docker ...

  7. Online Resource Mapping for SDN Network Hypervisors using Machine Learning

    发表时间:2016 一些定义: self-configuring networks: FlowVisor: FlowVisor是建立在OpenFlow之上的网络虚拟化工具,它可以将物理网络划分成多个逻 ...

  8. cygwin下安装c语言开发环境

    1.到官网cygwin.com下载安装程序. 2.添加清华的cygwin镜像:https://mirrors.tuna.tsinghua.edu.cn/cygwin/ 3.在安装:vim,git,gc ...

  9. Windows 10 host where Credential Guard or Device Guard is enabled fails when running Workstation (2146361)

    To disable Device Guard or Credential Guard on Itanium based computers: Disable the group policy set ...

随机推荐

  1. DoNet屌丝学Android(一)——Android开发准备工作 & No HelloWord & (真机)调试

    先乱扯淡一下吧,本人一.net屌丝,手持Android 4.2.2手机,Win7 x64本本,闲来无聊学习一下Android的开发,至于要开发啥玩意目前没有什么想法,就是想学学,搞不好是三分热度也有可 ...

  2. POJ C程序设计进阶 编程题#4:Tomorrow never knows?

    来源: POJ (Coursera声明:在POJ上完成的习题将不会计入Coursera的最后成绩.) 注意: 总时间限制: 1000ms 内存限制: 65536kB 描述 甲壳虫的<A day ...

  3. javascript中match和RegExp组合用法

    function getCookie(name)//取cookies函数 { //coook中document.cookie = "age=12; name=1.css"; var ...

  4. 如何验证 jemalloc 优化 Nginx 是否生效

    Jemalloc 源于 Jason Evans 2006年在 BSDcan conference 发表的论文:<A Scalable Concurrent malloc Implementati ...

  5. linux 的开机启动脚本顺序

    linux 开机启动脚本顺序 linux 开机启动脚本顺序. 第一步:启动内核 第二步:执行init (配置文件/etc/inittab) 第三步:启动相应的脚本,并且打开终端/etc/init.d  ...

  6. Yii-数据模型- rules类验证器方法详解

    public function rules(){ return array( array('project_id, type_id, status_id, owner_id, requester_id ...

  7. 直接拿来用!超实用的Java数组技巧攻略[转]

    来自csdn http://www.csdn.net/article/2013-09-16/2816947-methods-for-java-arrays 本文分享了关于Java数组最顶级的11大方法 ...

  8. Material Design:CollapsingToolbarLayout

    activity_main.xml: <android.support.design.widget.CoordinatorLayout xmlns:android="http://sc ...

  9. Python之定向爬虫Scrapy

    1.Scrapy介绍 Scrapy,Python开发的一个快速,高层次的屏幕抓取和web抓取框架,用于抓取web站点并从页面中提取结构化的数据.Scrapy用途广泛,可以用于数据挖掘.监测和自动化测试 ...

  10. MVC的Filters(拦截过滤)的Error页面,支持Ajax报错

    报错拦截过滤到error页面 [AttributeUsage(AttributeTargets.Method | AttributeTargets.Class, Inherited = true, A ...