title: 虚拟机安装Ubuntu18以及进一步的配置
date: 2019-03-22 22:37:55
前言
最近总是将虚拟机Ubuntu进行卸载、重装、卸载、重装。。。。
每次重装后,都要上网查找Ubuntu各种环境、工具的配置方案。实在太过繁琐,于是便打算自己进行总结一番,以便后用。
此前都是Ubuntu 16系统,这次则使用Ubuntu 18.04
系统(不得不说,实在是很漂亮了)。并选择最小化安装。
具体步骤
1. 修改系统语言为English
在 设置 - 地区和语言
中进行修改。需要重启。
2. VM给虚拟机添加双网卡
在 虚拟机设置 - 硬件
中,点击添加
,选择网络适配器
,然后按步骤直到完成。
两张网卡,一张设置成 NAT 模式
,一张设置成 仅主机模式
。NAT
用于上网,仅主机
用于与主机相连。
仅主机模式
下的ip
使用DHCP
动态分配,经常变动。若要使之固定或变动较小,可通过VM的 编辑 - 虚拟网络编辑器 - (VMnet1)仅主机模式 - DHCP设置
进行自定义配置。
3. 设置root用户密码
命令行输入:
sudo passwd root
意思是为root
用户添加密码。
然后,输入两次密码后即可。
4. 更换apt源
先下载vim
:sudo apt-get install vim
。(没换源,网速是真的慢)
然后:
$ cd /etc/apt
$ sudo cp sources.list sources.list.bak
$ sudo vim sources.list
修改sources.list
文件,将其中内容换成以下国内源:
##中科大源
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
更多Ubuntu 18
的apt
国内源见他人博客。
修改完成后,更新apt
:
sudo apt-get update
sudo apt-get upgrade
(很多apt
安装的问题,可能都是因为源没有配置好)
5. 安装主要工具
sudo apt-get install gdb man git -y
sudo apt-get install openssh-server
安装openssh-server
可能会报错(源的问题),提示需要一些依赖工具,如:openssh-client
、openssh-sftp-server
等。或许,还需要版本要求。你可以通过如下方式安装指定工具的版本:
sudo apt-get install openssh-client=xxxxxxxxx
安装完openssh-client
、openssh-sftp-server
等依赖工具后,openssh-server
应该就可以成功安装了。
可以用主机通过ssh
,连接虚拟机仅主机模式
网卡(可能是ens38
)对应的ip
地址。
(安装openssh-server
,是为了让主机能通过ssh
连接到虚拟机。)
6. 配置vim
见博客vim学习
7. 配置python环境
7.1. 安装python
、pip
、pip3
ubuntu 18
系统自带python3.6
,没有python2
。
$ sudo apt install python # python2
$ sudo apt install python-pip # python2的pip
$ sudo apt install python3-pip # python3的pip
(如果出现各种依赖问题,可能是apt
源配置有问题)
7.2. pip换源和升级
$ mkdir ~/.pip
$ vim ~/.pip/pip.conf
在pip.conf
中添加:
[global]
index-url = http://mirrors.aliyun.com/pypi/simple/
[install]
trusted-host=mirrors.aliyun.com
sudo pip install --upgrade pip
升级pip
。
7.3. 安装python虚拟环境
$ pip install virtualenv
pip
指向python2,会安装到python2中。
virtualenv
的具体使用方法见virtualenv。
8. 安装pwn环境
8.1. pwntools
pip install pwntools
需要用python2地pip安装
网友评论