安装虚机后基本配置

记录一下今天在安装了全新的Ubuntu(16.04)虚机后所做的一些基本配置

一、配置apt源并下载基本软件

Ubuntu的包管理命令apt默认使用美国仓库,将其配置为国内源镜像可大幅提高下载软件的速度。
我使用的是清华的镜像,下面vi编辑的内容可参考https://mirrors.tuna.tsinghua.edu.cn/help/ubuntu/

sudo su
cd /etc/apt
mv sources.list sources.list.bak
vi sources.list
apt update

#配置完毕后下载vim、jdk8、python等
apt install vim
apt install openjdk-8-jdk
apt install python3

二、配置主机名和静态IP

  1. 修改主机名
vim /etc/hostname
  1. 配置静态ip地址
vim /etc/network/interfaces
#--------------------------vim编辑以下内容-----------------------------------
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

source /etc/network/interfaces.d/*

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
# auto ens33
# iface ens33 inet dhcp
auto ens33
iface ens33 inet static
address 192.168.0.211
netmask 255.255.255.0
gateway 192.168.0.1
  1. 配置dns服务器
vim /etc/resolvconf/resolv.conf.d/head
#--------------------------vim编辑以下内容-----------------------------------
# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
#     DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
nameserver 8.8.8.8

三、开启ssh并配置免密码登录

  1. 虚机开启ssh服务器功能
apt install openssh-server
  1. 客户端配置免密码登录
ssh-copy-id [email protected] 

猜你喜欢

转载自blog.csdn.net/hch814/article/details/106179873