sudo apt-get install lightdm
sudo dpkg-reconfigure lightdm
避免重启后,无法使用图形界面登录
sudo apt-get install ubuntu-desktop
切换成功后,重启即可
桌面重启前Ubuntu可以正常联网,重启后用ifconfig查看IP仅本地的回环ip,ping 别的ip显示connect: Network is unreachable, ping百度时显示 Name or service not known。
适用于图形化桌面可正常登录
适用于图形化桌面无法登录
sudo service networking restart
或者
sudo service network-manager restart
若方案一不生效,使用方案二
xxx:~$ cd /etc/network
xxx:/etc/network$ cat interfaces
# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback
可以发现没有无线网卡的设置信息
xxx:/etc/network$ ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: wlo1: <BROADCAST,MULTICAST> mtu 1500 qdisc noqueue state DOWN group default qlen 1000
link/ether dc:8b:28:09:10:28 brd ff:ff:ff:ff:ff:ff
上述信息中,无线网卡名称为:wlo1, 状态为:DOWN(即:关闭状态)
xxx:/etc/network$ sudo vim interfaces
输入信息:
auto wlo1
iface wlo1 inet dhcp
wpa-essid {$wifi名称}
wpa-psk {$wifi密码}
保存退出
注:若需要连接的wifi网络为WEP加密,也可删除最后两行,直接使用iwconfig连接
说明:
- 配置文件中直接配置wifi信息的原因:
- 可以开机自启网卡并连接指定wifi
- iwconfig命令只支持WEP加密的wifi网络,不支持WPA-PSK加密方式
- 这里wpa-essid、wpa-psk是以dhcp的方式设置开机默认WPA-PSK加密的wifi网络
- 若wifi是WEP加密方式,则最后两行修改为:
wireless-essid {$wifi名称} wireless-key {$wifi密码}
- 若需要使用静态连接方式设置开机默认WPA-PSK加密的Wi-Fi网络:
auto wlo1 iface wlo1 inet static address {$wifi同网段ip} netmask 255.255.255.0 gateway {$路由器ip} wpa-essid {$wifi名称} wpa-psk {$wifi密码}
同理,若wifi是WEP加密方式,则最后两行使用wireless-essid、wireless-key
xxx:/etc/network$ sudo ifup wlo1
xxx:/etc/network$ ifconfig
wlo1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 172.16.4.2 netmask 255.255.255.0 broadcast 172.16.4.255
inet6 fe80::de8b:28ff:fe09:1028 prefixlen 64 scopeid 0x20<link>
ether dc:8b:28:09:10:28 txqueuelen 1000 (Ethernet)
RX packets 61575 bytes 12700714 (12.7 MB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 86836 bytes 13447138 (13.4 MB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
或者
xxx:/etc/network$ ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: wlo1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
link/ether dc:8b:28:09:10:28 brd ff:ff:ff:ff:ff:ff
以上显示网卡启动成功
xxx:/etc/network$ ping {$ip}
PING {$ip} ({$ip}) 56(84) bytes of data.
64 bytes from {$ip}: icmp_seq=1 ttl=63 time=2.72 ms
64 bytes from {$ip}: icmp_seq=2 ttl=63 time=1.35 ms
64 bytes from {$ip}: icmp_seq=3 ttl=63 time=1.35 ms
xxx:/etc/network$ ping www.baidu.com
PING www.a.shifen.com (180.97.34.96) 56(84) bytes of data.
64 bytes from 180.97.34.96 (180.97.34.96): icmp_seq=1 ttl=54 time=8.19 ms
64 bytes from 180.97.34.96 (180.97.34.96): icmp_seq=2 ttl=54 time=7.50 ms
64 bytes from 180.97.34.96 (180.97.34.96): icmp_seq=3 ttl=54 time=7.93 ms
xxx:/etc/network$ cd /etc
xxx:/etc$ sudo vim resolv.conf
输入:
nameserver 8.8.8.8
nameserver 8.8.4.4
保存退出
xxx:/etc$ ping www.baidu.com
PING www.a.shifen.com (180.97.34.96) 56(84) bytes of data.
64 bytes from 180.97.34.96 (180.97.34.96): icmp_seq=2 ttl=54 time=10.0 ms
64 bytes from 180.97.34.96 (180.97.34.96): icmp_seq=3 ttl=54 time=9.93 ms
成功
sudo apt-get install ubuntu-desktop
中间弹框,选择lightdm
sudo service lightdm restart
登录成功