
# 非root用户切root用户时，连接超时怎么办？
#### 问题描述
针对镜像为Ubuntu、Debian的弹性云服务器，使用sudo命令切换root用户时，系统提示连接超时，如[图1]所示。
图1连接超时   
![](https://support.huaweicloud.com/trouble-ecs/zh-cn_image_0094801740.png "点击放大")
#### 处理方法
1. 登录弹性云服务器。
2. 执行以下命令，编辑hosts文件。 **vi /etc/hosts**
   
3. 按"i"，进入编辑模式。
4. 在hosts文件最后添加一行内容，写入IP地址和主机名。 ***私有IP地址 主机名***
   示例：
   假设弹性云服务器的主机名为"hostname"，私有IP地址为"192.168.0.1"，则需添加的语句为：
   192.168.0.1 hostname
   
5. 按"Esc"退出编辑模式。
6. 执行以下命令，保存并退出。 **:wq**
   
![](https://support.huaweicloud.com/trouble-ecs/public_sys-resources/note_3.0-zh-cn.png)
针对镜像为Ubuntu、Debian的弹性云服务器，如果需要更新主机名，需将/etc/cloud/cloud.cfg中的manage_etc_hosts参数设置为false，同时将新设置的主机名更新至/etc/hosts中。编辑/etc/hosts文件时，请勿删除127.0.0.1所在行语句，否则会出现非root用户切换root超时问题。
