Ubuntu19.04的安装过程详解以及操作系统初始化配置
作者:尹正杰
版权声明:原创作品,谢绝转载!否则将追究法律责任。
一.安装Ubuntu详细过程
1>.选择默认的英文安装,回车即可
2>.选择第一个,回车即可
3>.默认使用英语,回车即可
4>.选择国家(ubuntu有点恶心,竟然没有把我们*列在上面,咱们选择其它)
5>.选择亚洲
6>.选择中国
7>.选择字符集为"uft-8",回车即可
8>.不要做键盘检查,浪费时间,选择"no",直接回车即可
9>.继续使用英语
10>.键盘布局咱们也选择英语,默认即可
11>.等待他自动安装一些服务
12>.自定义主机名
13>.自定义用户全名
14>.自定义系统用户
15>.输入上一步创建用户的口令
16>.再次输入创建用户的口令
17>.使用默认时区即可,反正这个后期也方便改动
18>.选择手动创建分区,不使用逻辑卷进行分区
19>.选择咱们虚拟机的硬盘
20>.会提示咱们是否要创建一个新的分区,我们选择"yes"
21>.选中咱们上一步创建的分区,按回车即可
22>.创建一个新的分区
23>.自定义一个分区大小
24>.创建主分区
25>.默认即可,从头开始分配咱们创建的分区
26>.确认分配
27>.如下图所示,还有剩余573GB的空间,咱们可以继续分区
28>.继续创建一个新的分区
29>.创建一个1GB的分区来分配给boot使用
30>.继续选择主分区
31>.继续选择从头开始使用分区
32>.将第二个分区分配给"/boot"
33>.重复上述操作,分配出"/data"分区和“swap”分区,如下图所示
34>.分区完成后选择最后一项完成分区,会将咱们的分配信息写入到磁盘
35>.确认写入
36>.如果你的网络需要代理服务器才能上网就直接输入代理地址即可,如果无需代理就能上网那么直接选择继续即可
37>.选择第二个选择自动升级(也可以选择手动打补丁升级,那就选择第一个)
38>.建议安装ssh服务便于远程管理,默认ubantu是不安装的哟
39>.安装boot加载器,选择默认的"yes"即可。
40>.安装完毕
41>.安装完成后会自动重启ubuntu系统
二.为ubuntu配置IP地址
1>.使用子网划分工具来划分子网(http://www.ab126.com/web/3552.html)
2>.对nat的地址进行子网划分
3>.设置DHCP地址池
4>.启动虚拟机,观察到虚拟机会自动分配咱们规划的IP地址
5>.编辑网卡的配置地址
root@ubuntu1904:~# cat /etc/netplan/-netcfg.yaml
# This file describes the network interfaces available on your system
# For more information, see netplan().
network:
version:
renderer: networkd
ethernets:
ens33:
dhcp4: yes #默认是DHCP获取地址的
root@ubuntu1904:~#
root@ubuntu1904:~# vim /etc/netplan/-netcfg.yaml
root@ubuntu1904:~#
root@ubuntu1904:~# cat /etc/netplan/-netcfg.yaml
# This file describes the network interfaces available on your system
# For more information, see netplan().
network:
version:
renderer: networkd
ethernets:
ens33:
dhcp4: no #咱们得禁用DHCP功能,下面就分别配置了IP地址,网关地址以及DNS信息等。
addresses: [192.168.7.100/]
gateway4: 192.168.7.254
nameservers:
addresses: [192.168.7.254]
root@ubuntu1904:~#
root@ubuntu1904:~#
root@ubuntu1904:~# ifconfig
ens33: flags=<UP,BROADCAST,RUNNING,MULTICAST> mtu
inet 192.168.7.1 netmask 255.255.248.0 broadcast 192.168.7.255
inet6 fe80::20c:29ff:fe84:d091 prefixlen scopeid 0x20<link>
ether :0c:::d0: txqueuelen (Ethernet)
RX packets bytes (48.8 KB)
RX errors dropped overruns frame
TX packets bytes (77.4 KB)
TX errors dropped overruns carrier collisions lo: flags=<UP,LOOPBACK,RUNNING> mtu
inet 127.0.0.1 netmask 255.0.0.0
inet6 :: prefixlen scopeid 0x10<host>
loop txqueuelen (Local Loopback)
RX packets bytes (6.3 KB)
RX errors dropped overruns frame
TX packets bytes (6.3 KB)
TX errors dropped overruns carrier collisions root@ubuntu1904:~#
root@ubuntu1904:~# netplan apply #在Ubantu没有像CentOS操作系统那样有network服务,因此我们直接执行"netplan apply"指令后就会立即生效。
root@ubuntu1904:~#
三.将阿里镜像地址配置为ubuntu的源
1>.编辑ubuntu的配置文件
root@ubuntu1904:~# vim /etc/apt/sources.list
root@ubuntu1904:~#
root@ubuntu1904:~# cat /etc/apt/sources.list
deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src 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-backports main restricted universe multiverse
root@ubuntu1904:~#
root@ubuntu1904:~#
root@ubuntu1904:~# vim /etc/apt/sources.list
2>.更新ubantu的镜像源
root@ubuntu1904:~# apt-get update
Get: http://mirrors.aliyun.com/ubuntu bionic InRelease [242 kB]
Get: http://mirrors.aliyun.com/ubuntu bionic-security InRelease [88.7 kB]
Get: http://mirrors.aliyun.com/ubuntu bionic-updates InRelease [88.7 kB]
Get: http://mirrors.aliyun.com/ubuntu bionic-proposed InRelease [242 kB]
Get: http://mirrors.aliyun.com/ubuntu bionic-backports InRelease [74.6 kB]
Get: http://mirrors.aliyun.com/ubuntu bionic/main Sources [829 kB]
Get: http://mirrors.aliyun.com/ubuntu bionic/restricted Sources [5,324 B]
Get: http://mirrors.aliyun.com/ubuntu bionic/multiverse Sources [181 kB]
Get: http://mirrors.aliyun.com/ubuntu bionic/universe Sources [9,051 kB]
Get: http://mirrors.aliyun.com/ubuntu bionic/main amd64 Packages [1,019 kB]
Get: http://mirrors.aliyun.com/ubuntu bionic/main i386 Packages [1,007 kB]
Get: http://mirrors.aliyun.com/ubuntu bionic/main Translation-en [516 kB]
Get: http://mirrors.aliyun.com/ubuntu bionic/restricted i386 Packages [9,156 B]
Get: http://mirrors.aliyun.com/ubuntu bionic/restricted amd64 Packages [9,184 B]
Get: http://mirrors.aliyun.com/ubuntu bionic/restricted Translation-en [3,584 B]
Get: http://mirrors.aliyun.com/ubuntu bionic/universe amd64 Packages [8,570 kB]
Get: http://mirrors.aliyun.com/ubuntu bionic/universe i386 Packages [8,531 kB]
Get: http://mirrors.aliyun.com/ubuntu bionic/universe Translation-en [4,941 kB]
Get: http://mirrors.aliyun.com/ubuntu bionic/multiverse amd64 Packages [151 kB]
Get: http://mirrors.aliyun.com/ubuntu bionic/multiverse i386 Packages [144 kB]
Get: http://mirrors.aliyun.com/ubuntu bionic/multiverse Translation-en [108 kB]
Get: http://mirrors.aliyun.com/ubuntu bionic-security/main Sources [134 kB]
Get: http://mirrors.aliyun.com/ubuntu bionic-security/multiverse Sources [3,184 B]
Get: http://mirrors.aliyun.com/ubuntu bionic-security/restricted Sources [4,220 B]
Get: http://mirrors.aliyun.com/ubuntu bionic-security/universe Sources [163 kB]
Get: http://mirrors.aliyun.com/ubuntu bionic-security/main i386 Packages [417 kB]
Get: http://mirrors.aliyun.com/ubuntu bionic-security/main amd64 Packages [606 kB]
Get: http://mirrors.aliyun.com/ubuntu bionic-security/main Translation-en [196 kB]
Get: http://mirrors.aliyun.com/ubuntu bionic-security/restricted i386 Packages [4,280 B]
Get: http://mirrors.aliyun.com/ubuntu bionic-security/restricted amd64 Packages [17.0 kB]
Get: http://mirrors.aliyun.com/ubuntu bionic-security/restricted Translation-en [5,032 B]
Get: http://mirrors.aliyun.com/ubuntu bionic-security/universe amd64 Packages [633 kB]
Get: http://mirrors.aliyun.com/ubuntu bionic-security/universe i386 Packages [606 kB]
Get: http://mirrors.aliyun.com/ubuntu bionic-security/universe Translation-en [213 kB]
Get: http://mirrors.aliyun.com/ubuntu bionic-security/multiverse i386 Packages [4,288 B]
Get: http://mirrors.aliyun.com/ubuntu bionic-security/multiverse amd64 Packages [6,120 B]
Get: http://mirrors.aliyun.com/ubuntu bionic-security/multiverse Translation-en [2,600 B]
Get: http://mirrors.aliyun.com/ubuntu bionic-updates/restricted Sources [6,216 B]
Get: http://mirrors.aliyun.com/ubuntu bionic-updates/universe Sources [271 kB]
Get: http://mirrors.aliyun.com/ubuntu bionic-updates/multiverse Sources [5,848 B]
Get: http://mirrors.aliyun.com/ubuntu bionic-updates/main Sources [301 kB]
Get: http://mirrors.aliyun.com/ubuntu bionic-updates/main amd64 Packages [830 kB]
Get: http://mirrors.aliyun.com/ubuntu bionic-updates/main i386 Packages [629 kB]
Get: http://mirrors.aliyun.com/ubuntu bionic-updates/main Translation-en [290 kB]
Get: http://mirrors.aliyun.com/ubuntu bionic-updates/restricted i386 Packages [9,584 B]
Get: http://mirrors.aliyun.com/ubuntu bionic-updates/restricted amd64 Packages [26.0 kB]
Get: http://mirrors.aliyun.com/ubuntu bionic-updates/restricted Translation-en [6,976 B]
Get: http://mirrors.aliyun.com/ubuntu bionic-updates/universe i386 Packages [997 kB]
Get: http://mirrors.aliyun.com/ubuntu bionic-updates/universe amd64 Packages [1,035 kB]
Get: http://mirrors.aliyun.com/ubuntu bionic-updates/universe Translation-en [320 kB]
Get: http://mirrors.aliyun.com/ubuntu bionic-updates/multiverse amd64 Packages [9,500 B]
Get: http://mirrors.aliyun.com/ubuntu bionic-updates/multiverse i386 Packages [7,484 B]
Get: http://mirrors.aliyun.com/ubuntu bionic-updates/multiverse Translation-en [4,540 B]
Get: http://mirrors.aliyun.com/ubuntu bionic-proposed/main Sources [31.6 kB]
Get: http://mirrors.aliyun.com/ubuntu bionic-proposed/restricted Sources [1,440 B]
Get: http://mirrors.aliyun.com/ubuntu bionic-proposed/universe Sources [12.7 kB]
Get: http://mirrors.aliyun.com/ubuntu bionic-proposed/multiverse Sources [804 B]
Get: http://mirrors.aliyun.com/ubuntu bionic-proposed/main amd64 Packages [69.0 kB]
Get: http://mirrors.aliyun.com/ubuntu bionic-proposed/main i386 Packages [61.4 kB]
Get: http://mirrors.aliyun.com/ubuntu bionic-proposed/main Translation-en [32.7 kB]
Get: http://mirrors.aliyun.com/ubuntu bionic-proposed/restricted amd64 Packages [3,644 B]
Get: http://mirrors.aliyun.com/ubuntu bionic-proposed/restricted Translation-en [1,232 B]
Get: http://mirrors.aliyun.com/ubuntu bionic-proposed/universe i386 Packages [41.9 kB]
Get: http://mirrors.aliyun.com/ubuntu bionic-proposed/universe amd64 Packages [46.8 kB]
Get: http://mirrors.aliyun.com/ubuntu bionic-proposed/universe Translation-en [24.6 kB]
Get: http://mirrors.aliyun.com/ubuntu bionic-proposed/multiverse amd64 Packages [1,316 B]
Get: http://mirrors.aliyun.com/ubuntu bionic-proposed/multiverse Translation-en [568 B]
Get: http://mirrors.aliyun.com/ubuntu bionic-backports/universe Sources [2,492 B]
Get: http://mirrors.aliyun.com/ubuntu bionic-backports/main Sources [2,532 B]
Get: http://mirrors.aliyun.com/ubuntu bionic-backports/main i386 Packages [2,516 B]
Get: http://mirrors.aliyun.com/ubuntu bionic-backports/main amd64 Packages [2,512 B]
Get: http://mirrors.aliyun.com/ubuntu bionic-backports/main Translation-en [1,644 B]
Get: http://mirrors.aliyun.com/ubuntu bionic-backports/universe amd64 Packages [4,044 B]
Get: http://mirrors.aliyun.com/ubuntu bionic-backports/universe i386 Packages [4,036 B]
Get: http://mirrors.aliyun.com/ubuntu bionic-backports/universe Translation-en [1,900 B]
Fetched 43.9 MB in 16s (, kB/s)
Reading package lists... Done
root@ubuntu1904:~
root@ubuntu1904:~# apt-get update
四.配置Ubuntu可以使用root用户远程登录
1>.查看Ubuntu的sshd默认配置
2>.修改PermitRootLogin的值为yes
3>.重启sshd服务并验证服务是否启动成功
4>.查看Ubuntu宿主机的IP地址
5>.使用xshell工具配置连接地址Ubuntu宿主机
五.设置Ubuntu的主机名级终端显式方式
1>.如下图所示,将xshell的连接终端类型设置为"xterm"
2>.修改配置文件
.设置ps1变量的显示 PS1(是数字1而不是字母l),每个版本bash的PS1变量内的特殊符号可能有些小的差异,你可以先man bash 一下。下面是FC4环境下默认的特殊符号所代表的意义: \d :代表日期,格式为weekday month date,例如:"Mon Aug 1" \H :完整的主机名称。例如:我的机器名称为:fc4.linux,则这个名称就是fc4.linux \h :仅取主机的第一个名字,如上例,则为fc4,.linux则被省略 \t :显示时间为24小时格式,如:HH:MM:SS \T :显示时间为12小时格式 \A :显示时间为24小时格式:HH:MM \u :当前用户的账号名称 \v :BASH的版本信息 \w :完整的工作目录名称。家目录会以 ~代替 \W :利用basename取得工作目录名称,所以只会列出最后一个目录 \# :下达的第几个命令 \$ :提示字符,如果是root时,提示符为:# ,普通用户则为:$ 默认的PS1内容为: PS1='[\u@\h \W]\$ ' ,所以默认的提示符就是: [root@linux ~]#。
设置ps1变量的显示
设置ps1变量的颜色 我们能够通过配置PS1变量使提示符成为彩色。在PS1中配置字符序列颜色的格式为: \[\e[F;Bm\] 基本上是夹在 "\e["(转义开方括号)和 "m" 之间数字值。假如指定一个以上的数字代码,则用分号将他们分开。 其中 F 为字体颜色,编号30~; B 为背景色,编号40~。 可通过 \e[0m 关闭颜色输出;特别的,当B为1时,将显示加亮加粗的文字,请看下面的颜色表和代码表。 颜色表 前景 背景 颜色
---------------------------------------
黑色
红色
绿色
黄色
蓝色
紫色
青色
白色
设置ps1变量的颜色
[ "$PS1" = "\\s-\\v\\\$ " ] && PS1="[\[\e[34;1m\]\u@\[\e[0m\]\[\e[32;1m\]\H\[\e[0m\] \[\e[31;1m\]\w\[\e[0m\]]\\$ "