Ubuntu Server在虚拟机上的一些初始配置
最近又在虚拟机(VMware)上新建了一个Ubuntu Service,有的配置偶尔记不住,这次就记录一下,方便以后查阅~
1.更换国内源
啥也别说,先换源吧。不换源就基本上就没法正常工作,下载一个东西就得好久。原因是官方源在国外,自然就很慢,这里推荐中科大的镜像源,当然还有很多优秀的镜像源,如:清华、阿里。
1.1备份
备份sources.list,防止出现问题。
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
1.2修改源列表
sudo vi /etc/apt/sources.list
用vim编辑器打开源列表,进行全部替换。需要注意的是,下面的xenial
代表ubuntu的版本号,其中18.04的是bionic
。
deb http://mirrors.ustc.edu.cn/ubuntu/ xenial main restricted universe multiverse
deb http://mirrors.ustc.edu.cn/ubuntu/ xenial-security main restricted universe multiverse
deb http://mirrors.ustc.edu.cn/ubuntu/ xenial-updates main restricted universe multiverse
deb http://mirrors.ustc.edu.cn/ubuntu/ xenial-proposed main restricted universe multiverse
deb http://mirrors.ustc.edu.cn/ubuntu/ xenial-backports main restricted universe multiverse
deb-src http://mirrors.ustc.edu.cn/ubuntu/ xenial main restricted universe multiverse
deb-src http://mirrors.ustc.edu.cn/ubuntu/ xenial-security main restricted universe multiverse
deb-src http://mirrors.ustc.edu.cn/ubuntu/ xenial-updates main restricted universe multiverse
deb-src http://mirrors.ustc.edu.cn/ubuntu/ xenial-proposed main restricted universe multiverse
deb-src http://mirrors.ustc.edu.cn/ubuntu/ xenial-backports main restricted universe multiverse
deb [arch=amd64] https://download.docker.com/linux/ubuntu xenial stable
# deb-src [arch=amd64] https://download.docker.com/linux/ubuntu xenial stable
# deb-src [arch=amd64] https://download.docker.com/linux/ubuntu xenial stable
1.3更新源命令
sudo apt-get update
sudo apt-get upgrade
到这里,已经换源成功,通过以上update的命令就已经可以感受到速度的变化了。
1.4其他源的收集
- 官方中国Ubuntu 18.04
deb http://cn.archive.ubuntu.com/ubuntu/ bionic main restricted universe multiverse
deb http://cn.archive.ubuntu.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://cn.archive.ubuntu.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://cn.archive.ubuntu.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb http://cn.archive.ubuntu.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://cn.archive.ubuntu.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://cn.archive.ubuntu.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://cn.archive.ubuntu.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://cn.archive.ubuntu.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://cn.archive.ubuntu.com/ubuntu/ bionic-backports main restricted universe multiverse
- 官方中国Ubuntu 16.04
deb http://cn.archive.ubuntu.com/ubuntu/ xenial main restricted universe multiverse
deb http://cn.archive.ubuntu.com/ubuntu/ xenial-security main restricted universe multiverse
deb http://cn.archive.ubuntu.com/ubuntu/ xenial-updates main restricted universe multiverse
deb http://cn.archive.ubuntu.com/ubuntu/ xenial-backports main restricted universe multiverse
##测试版源
deb http://cn.archive.ubuntu.com/ubuntu/ xenial-proposed main restricted universe multiverse
# 源码
deb-src http://cn.archive.ubuntu.com/ubuntu/ xenial main restricted universe multiverse
deb-src http://cn.archive.ubuntu.com/ubuntu/ xenial-security main restricted universe multiverse
deb-src http://cn.archive.ubuntu.com/ubuntu/ xenial-updates main restricted universe multiverse
deb-src http://cn.archive.ubuntu.com/ubuntu/ xenial-backports main restricted universe multiverse
##测试版源
deb-src http://cn.archive.ubuntu.com/ubuntu/ xenial-proposed main restricted universe multiverse
# Canonical 合作伙伴和附加
deb http://archive.canonical.com/ubuntu/ xenial partner
deb http://extras.ubuntu.com/ubuntu/ xenial main
- 阿里云Ubuntu 18.04
deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
- 网易Ubuntu 18.04
deb http://mirrors.163.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ bionic-backports main restricted universe multiverse
- 搜狐
http://mirrors.sohu.com/ubuntu/
- 中科院、清华、上交等
2.SSH连接
VMware直接使用服务器很不方便,即使安装了VMware Tools,也不能很好地粘贴复制内容;而且屏幕的显示只是一页,比如我有一次准备看看虚拟机有哪些进程在运行,输入后只能看到一部分进程,看不到完整的,就很头疼,另外就是VMware太太太笨重了,我们完全可以让它在后台运行,然后通过SSH工具,像连接云服务器一样的操作它。话不多说,下面进行安装。
1.安装SSH
- 在Server中安装SSH服务
首先看系统中是否有
whereis ssh
如果没有返回值,则没有安装,需要执行以下命令:
sudo apt-get install ssh
在上面换源的加持下,这一步应该非常快。
2. 在本机上安装SHH工具
这里推荐用XShell,不用说,很强大。
Xshell 是一个强大的安全终端模拟软件,它支持SSH1, SSH2, 以及Microsoft Windows 平台的TELNET 协议。Xshell 通过互联网到远程主机的安全连接以及它创新性的设计和特色帮助用户在复杂的网络环境中享受他们的工作。
2.查看ip
我们通过什么标记想要连接的主机,答案是ip地址。通过下面命令:
ifconfig
其中ens33中的inet addr就是该虚拟机的在内网中的ip地址。
3.连接
打开XShell,输入主机地址,即上述的ip地址。
之后再正确输入虚拟主机的用户名和密码(记得点记住),这样就可以方便的连接到主机了。最后,将VMware中运行的主机以后台方式运行。
可以愉快的使用虚拟机了~