在我的电脑上安装 Ubuntu 12.04 后,我的网络完全消失了。在终端中,输入以下内容后,nm-tool
我得到以下内容:
The program nm-tool is currently not installed. You can install by typing:
sudo apt-get install network-manager
输入密码后,我得到了以下信息:
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have requested an impossible situation or if you are using the unstable distribution that some required packages have not yet been created or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
network manager : Depends: iputils-arping but it is not going to be installed
E: Unable to correct problems, you have held broken packages
我对计算机完全是个新手,所以我一点头绪都没有。
答案1
如果您没有网络,那么您的软件包可能已损坏并且无法安装 - Apt 无法检索软件包。
手动下载
正如您在此处发布的那样,您显然还有另一台设备可以访问网络。如果此设备可用于下载软件包,您可以手动进行下载。
- 在Ubuntu 软件包搜索您可以指定分布和包;搜索;选择命中链接;转到页面底部;选择包;选择架构;复制镜像链接/或直接链接;
下载(适用于 i386,准确):
wget http://archive.ubuntu.com/ubuntu//pool/main/n/network-manager/network-manager_0.9.4.0-0ubuntu3_i386.deb
您还将获得该页面的依赖项。
- 或者 - 如果其他机器是相同的版本和架构,在终端中:
uri=$(apt-cache show network-manager | grep "^Filename: " | cut -d' ' -f2) && wget "http://archive.ubuntu.com/ubuntu/$uri"
要列出依赖项和状态,请执行以下操作:
apt-rdepends network-manager --follow=DEPENDS --print-state
如果apt-rdepends
没有安装,则需要安装其依赖项
- 或者 - 关注这些说明。
发布更多信息
现在。更简单的方法可能是尝试使用其他工具来修复网络。
A
打开终端++Ctrl并发出以下命令:AltT
lshw -C network
ifconfig -a
ip addr list
route -n
并将输出发布在您的问题中。
乙
或者,更完整地说,运行一个脚本。参见底部的代码。
- 将代码保存到文件并将其复制到没有网络的机器。
- 打开终端并使其可执行:
chmod 700 文件名
- 运行它并将输出保存到文件:
./文件名 > 结果 # 或者 ./name_of_file | tee 结果
如果您愿意,请对其进行清理并将其添加到您的问题中。
代码:
#!/bin/bash
# No warranties, guaranties etc.
version=0.0.1
sep="=============================================================="
# has_tool "<tool>"
has_tool()
{
command -v "$1" >/dev/null 2>&1
}
# prnt_header "<tool>" "<arg-execute>"
prnt_header()
{
printf ";; %s\n" "$sep"
printf ";; = tool: %-52s =\n" "$1"
[[ "$2" != "" ]] && printf ";; = arg : %-52s =\n" "$2"
if ! has_tool "$1"; then
e=";; = ERR: \`$1' not present."
printf "%-63s =\n" "$e"
printf ";; %s\n" "$sep"
return 1
fi
if [[ "$1" =~ cat|more|less ]]; then
if ! [[ -e "$2" ]]; then
e=";; = ERR: File; \`$2' not present."
printf "%-63s =\n" "$e"
printf ";; %s\n" "$sep"
return 1
fi
fi
printf ";; %s\n" "$sep"
return 0
}
# tool_info "<tool>" "<arg-version>" "<arg-execute>"
tool_info()
{
local v=
(($#!=3)) && {
printf >&2 "* $0 ERR: Bad call to cmd_present. Missing arguments.\n"
printf >&2 ";; '%s'\n" "$@"
return 1
}
if ! prnt_header "$1" "$3"; then
return 1
fi
if [[ $2 ]]; then
printf ";; Version \$ %s %s\n" "$1" "$2"
v=( $($1 $2 2>&1) )
printf ";; %s\n" "${v[*]}"
fi
printf ";;\n"
}
# tool_do "<tool>" "<arg-version>" "<arg-execute>" "<sudo>"
tool_do()
{
(($#!=4)) && {
printf >&2 "* $0 ERR: Bad call to cmd_do. Missing arguments.\n"
printf >&2 ";; '%s'\n" "$@"
return 1
}
if ! tool_info "$1" "$2" "$3"; then
return 1
fi
printf ";; Output:\n"
(($4==1)) && sudo $1 $3 || $1 $3
printf "\n;;\n"
return 0
}
ping_gateways()
{
if has_tool route; then
# TODO: Check for UG flag
gw=$(route -n | awk '{print $2}' | grep -o '^[0-9\.]*')
for g in ${gw[*]}; do
if ! [[ "$g" == "0.0.0.0" ]]; then
tool_do "ping" "-V" "-c 3 $g" 0
fi
done
fi
}
printf ";; _______________________ NET TEST _____________________________\n" | tee /dev/stderr
printf ";; v. %s\n\n" "$version" | tee /dev/stderr
printf >&2 ";; Working ...\n"
tool_info "NetworkManager" "--version" ""
printf >&2 ";; Hardware ...\n"
tool_do "lshw" "-version" "-C network" 1
#printf >&2 "\r\033[KVarious information ..."
printf >&2 ";; Various information ...\n"
tool_do "ifconfig" "-V" "-a" 0
tool_do "ip" "-V" "addr list" 0
tool_do "route" "-V" "-n" 0
tool_do "netstat" "-V" "-rn" 0
tool_do "iptables" "--version" "-n -L" 1
printf >&2 ";; Some cat'ing ...\n"
tool_do "cat" "" "/etc/network/interfaces" 0
tool_do "cat" "" "/etc/hosts" 0
tool_do "cat" "" "/etc/hosts.allow" 0
tool_do "cat" "" "/etc/hosts.deny" 0
tool_do "cat" "" "/etc/modules" 0
tool_do "cat" "" "/etc/modules.conf" 0
tool_do "cat" "" "/etc/resolv.conf" 0
printf >&2 ";; Some dig'ing ...\n"
tool_do "host" "" "localhost" 0
tool_do "nslookup" "" "localhost" 0
tool_do "nslookup" "" "askubuntu.com" 0
tool_do "dig" "" "." 0
tool_do "dig" "" "localhost" 0
tool_do "dig" "" "askubuntu.com" 0
printf >&2 ";; Ping gateways ...\n"
ping_gateways
printf >&2 ";; Ping various ...\n"
tool_do "ping" "" "-c 3 216.239.32.10" 0
printf >&2 ";; Ping google DNS ...\n"
# https://developers.google.com/speed/public-dns/docs/using
tool_do "ping" "" "-c 3 8.8.8.8" 0
tool_do "ping" "" "-c 3 8.8.4.4" 0
printf "\n;; Fine.\n" | tee /dev/stderr