Ubuntu 使用 Root 账号登录,并配置网络连接

Kevin 教程 3,820 次浏览 56条评论

启用 Root 账号

运行sudo su切换到 root 登录(需验证当前用户密码),passwd root设置密码即完成启用。

若要停用 root 则运行sudo passwd -l root(用具有 sudo 权限的用户登录运行)。

若要删除之前创建的用户使用userdel -r 用户名命令(这将同时删除用户目录和文件)。

允许 root 以密码方式登录 SSH

确保有安装openssh server软件包(没有用下面命令安装),不然将无法使用 SSH。

apt-get install openssh-server


PermitRootLogin yes             # 允许 root 密码登录
PermitEmptyPasswords no         # 禁止空密码登录

重启 SSH 服务生效。

systemctl restart ssh


下面方法适用于 Ubuntu 16.04。如果是 Ubuntu 18.04 可参考网上这篇文章

先运行ifconfig -a查看网卡名称,下图红框部分。

Ubuntu ifconfig

编辑/etc/network/interfaces网卡配置文件,添加以下内容设置 IP、网关和子网掩码。

下面是一个示例,其中 ens3 用之前查询到的网卡名称替换。

auto ens3
iface ens3 inet static
        address xxx.xxx.xxx.xxx
        gateway xxx.xxx.xxx.xxx
        netmask xxx.xxx.xxx.xxx

若要设置 DHCP 自动获取 IP ,则相应设置为如下。

auto ens3
iface ens3 inet dhcp

刷新 IP 和重启网络生效。

ip addr flush ens3
systemctl restart networking

之后 ping 个域名测试是否正常。如果有问题,用ip a showip r命令检查 IP 和路由。

补充:如果要将网卡设备名称改为传统的eth0,修改/etc/default/grub文件,将里面的 GRUB_CMDLINE_LINUX 参数改为如下这样。

GRUB_CMDLINE_LINUX="net.ifnames=0 biosdevname=0"


上面方法同样适用于 Debian 系统。补充个 Debian 问题,如果安装系统后访问 HTTPS 资源提示证书问题,需要安装下面软件包。

apt-get install ca-certificates


  1. #1

    Hi, very nice website, cheers!
    Need cheap and reliable hosting? Our shared plans start at $10 for an year and VPS plans for $6/Mo.
    Check here: https://www.reliable-webhosting.com/

  2. #2

    hydroxychloroquine by state https://hydroxychloroquine.webbfenix.com/

  3. #3

    what parasites does ivermectin kill in humans https://ivermectin.webbfenix.com/

  4. #4

    hydroxychloroquine buy uk https://hydroxychloroquine.mlsmalta.com/

  5. #5

    cost for viagra http://droga5.net/

  6. #6

    vidalista 5 mg stprxl https://vidalista.mlsmalta.com/

  7. #7

    suhagra tablet https://suhagra.buszcentrum.com/

  8. #8

    ivermectin human use https://ivermectin.mlsmalta.com/

  9. #9

    priligy side effects headache https://ddapoxetine.com/

  10. #10

    vidalista drug interactions list https://vidalista40mg.mlsmalta.com/

  11. #11

    cialis tablets 5mg price https://wisig.org/

  12. #12

    amstyles.com https://amstyles.com/

  13. #13

    how can i get viagra pills

  14. #14

    family life insurance

  15. #15

    life insurance for over 50

  16. #16

    auto liability

  17. #17

    icici term insurance

  18. #18

    30 day free trial cialis https://tadalafili.com/

  19. #19

    sildenafil soft tabs

  20. #20

    hazard insurance

  21. #21

    home emergency insurance

  22. #22

    cost of levitra in canada

  23. #23

    cost of levitra

  24. #24

    aviva home insurance

  25. #25

    payday calendar

  26. #26

    hydroxychloroquine manufacturers usa https://hydroxychloroquinee.com/

  27. #27

    home owner insurance

  28. #28

    house insurance comparison

  29. #29

    generic tadalafil 20 mg canada

  30. #30

    quick money online free

  31. #31

    female viagra tablet in india

  32. #32

    tadalafil generic sales in canada https://tadalafil.cleckleyfloors.com/

  33. #33

    coles home insurance

  34. #34

    how is hydroxychloroquine manufactured https://hydroxychloroquine.wisig.org/

  35. #35

    how is hydroxychloroquine manufactured https://hydroxychloroquine.mymvrc.org/

  36. #36

    homeowner’s insurance

  37. #37

    generic viagra 50

  38. #38

    best personal loan

  39. #39

    does acyclovir works for women https://www.herpessymptomsinmen.org/productacyclovir/

  40. #40

    biggest risk of taking tamoxifen https://tamoxifen.mrdgeography.com/

  41. #41

    how to get prescription online https://buymeds.mlsmalta.com/

  42. #42

    how to get prescription online https://medpills.bee-rich.com/

  43. #43

    viagra in mexico over the counter https://zsildenafil.com/

  44. #44

    best price aurogra 100mg https://aurogra.buszcentrum.com/

  45. #45

    where can you buy tadalafil over the counter https://cialis.mrdgeography.com/

  46. #46

    where can you buy tadalafil over the counter https://cialis.buszcentrum.com/

  47. #47

    cialis generic http://tadalafila.online/

  48. #48

    australian shepherd ivermectin toxicity http://ivermmectin.com/

  49. #49

    online health visit https://edmeds.buszcentrum.com/

  50. #50

    cialis website https://cialzi.com/

  51. #51

    The other day, while I was at work, my sister stole my apple ipad and tested to see if it can survive a
    40 foot drop, just so she can be a youtube sensation. My apple ipad is
    now broken and she has 83 views. I know this is
    totally off topic but I had to share it with someone! http://antiibioticsland.com/Cipro.htm

  52. #52

    Right away I am ready to do my breakfast, when having my breakfast coming over again to read other news. http://cialis.audiovideoninja.com/tadalafil

  53. #53

    lowest price cialis 20mg https://cialis.bee-rich.com/

  54. #54

    lowest price cialis 20mg https://cialis.adicbc.com/

  55. #55

    I have read a few just right stuff here. Certainly value bookmarking for revisiting. I surprise how so much effort you set to create this type of excellent informative website.


  56. #56

    It’s actually a cool and useful piece of info.
    I’m glad that you simply shared this useful info with us.
    Please keep us up to date like this. Thank you for sharing. http://hydroxychloroquinea.anafassia.com/


电邮地址用于 Gravatar 头像显示,不会被公开可见。