一、下载
官网
清华镜像站(推荐)
二、配置虚拟机
【自定义】
点击“下一步”,此处【默认】,再点击“下一步”。
点击“稍后安装操作系统”,再点击“下一步”。
点击“Linux(L)”,版本选择【Ubuntu 64 位】,再点击“下一步”。
输入想设置的名称和想安装的位置,再点击“下一步”。
内核数量改为2,再点击“下一步”。
内存设置为4096MB,即4G,再点击“下一步”。
选择"使用网络地址转换",再点击“下一步”。
选择"LSI Logic(L)“,再点击“下一步”。
选择"SCSI(S)”,再点击“下一步”。
选择"创建新虚拟磁盘",再点击“下一步”。
设置为40G,建议设置大一些,后面如果不够用,修改起来比较麻烦。选择"将虚拟磁盘拆分成多个文件"
此处【默认】,再点击“下一步”。
点击“完成”。
点击"编辑虚拟机设置"。
按图中所示,点击"浏览",选择你下载好的镜像,点击确定后,点击左边的"开启此虚拟机"。
三、安装Ubuntu
选择"Install Ubuntu"
选择"English"
选择"Use wired connection"
选择"Normal installation"
选择"Erase disk and install Ubuntu"
选择"Ready to install"
Select your timezone(选择时区)
Set up your acount(设置账户)
Choose your theme(选择你的主题),点击Next后开始安装。
开始安装:
安装完成,点击"Restart now",重启。
点击"skip":
点击"Next":
点击"Next":
点击"Done":
三、换源
3.1 图形化方式换源
选择"中科大"的镜像源:
设置"中科大"的镜像源成功界面:
3.2 命令行方式换源
编辑sources.list文件
sudo vim /etc/apt/sources.list
将里面的内容更换为:
# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.
deb https://mirrors.ustc.edu.cn/ubuntu/ lunar main restricted
# deb-src http://cn.archive.ubuntu.com/ubuntu lunar main restricted
## Major bug fix updates produced after the final release of the
## distribution.
deb https://mirrors.ustc.edu.cn/ubuntu/ lunar-updates main restricted
# deb-src http://cn.archive.ubuntu.com/ubuntu lunar-updates main restricted
## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team. Also, please note that software in universe WILL NOT receive any
## review or updates from the Ubuntu security team.
deb https://mirrors.ustc.edu.cn/ubuntu/ lunar universe
# deb-src http://cn.archive.ubuntu.com/ubuntu lunar universe
deb https://mirrors.ustc.edu.cn/ubuntu/ lunar-updates universe
# deb-src http://cn.archive.ubuntu.com/ubuntu lunar-updates universe
## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team, and may not be under a free licence. Please satisfy yourself as to
## your rights to use the software. Also, please note that software in
## multiverse WILL NOT receive any review or updates from the Ubuntu
## security team.
deb https://mirrors.ustc.edu.cn/ubuntu/ lunar multiverse
# deb-src http://cn.archive.ubuntu.com/ubuntu lunar multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ lunar-updates multiverse
# deb-src http://cn.archive.ubuntu.com/ubuntu lunar-updates multiverse
## N.B. software from this repository may not have been tested as
## extensively as that contained in the main release, although it includes
## newer versions of some applications which may provide useful features.
## Also, please note that software in backports WILL NOT receive any review
## or updates from the Ubuntu security team.
deb https://mirrors.ustc.edu.cn/ubuntu/ lunar-backports main restricted universe multiverse
# deb-src http://cn.archive.ubuntu.com/ubuntu lunar-backports main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ lunar-security main restricted
# deb-src http://cn.archive.ubuntu.com/ubuntu lunar-security main restricted
deb https://mirrors.ustc.edu.cn/ubuntu/ lunar-security universe
# deb-src http://cn.archive.ubuntu.com/ubuntu lunar-security universe
deb https://mirrors.ustc.edu.cn/ubuntu/ lunar-security multiverse
# deb-src http://cn.archive.ubuntu.com/ubuntu lunar-security multiverse
按ESC,再输入:wq,保存。
3.3 备份源文件
sudo cp /etc/apt/sources.list /etc/apt/sources.list.backup2023416djc
3.4 更新源文件
sudo apt-get update
3.5 更新软件
sudo apt-get upgrade
若能正常更新源和软件,则代表换源成功。
四、安装配置SSH
4.1 具体配置SSH步骤
#1、安装openssh-client
sudo apt install openssh-client
#2、安装openssh-server
sudo apt install openssh-server
#3、ssh服务重启
service ssh restart
#4、安装net-tools (使用ifconfig时,需要net-tools)
sudo apt install net-tools
#5、查看ip,找到inet的值
ifconfig
#6、验证SSH是否正在运行
sudo systemctl status ssh
##如果为inactive(dead),可以手动开启SSH##
/etc/init.d/ssh start
#补充:
#启用ssh的指令
启动ssh服务:
#sudo /etc/init.d/ssh start
停止ssh服务:
#sudo /etc/init.d/ssh stop
重启ssh服务:
#sudo /etc/init.d/ssh restart
需要手动启动ssh服务的情况:
#7、如果在系统上启用了防火墙,要设置打开SSH的端口
sudo ufw allow ssh
//查看防火墙状态
sudo ufw status
//打开/关闭防火墙
sudo ufw enable/disable
查看防火墙状态并打开防火墙:
设置防火墙打开SSH的端口:
4.2 备份ssd_config文件
将PermitRootLogin prohibit-password那一行修改为PermitRootLogin yes,去掉前面的#号
将port 22前面的#去掉然后重启SSH服务。
#sshd_config.backup2023416.djc为新备份文件名称
sudo cp /etc/ssh/sshd_config /etc/ssh/sshd_config.backup2023416.djc
五、SSH连接
5.1 获取ip地址
#找到inet的值
ifconfig
#确保ssh状态为active(running),如果inactive(dead),使用/etc/init.d/ssh start 命令开启
sudo systemctl status ssh
5.2 使用工具远程登录到Ubuntu
输入登录的用户名:
登录成功:
图形化界面中也能看到之前备份的sshd_config文件:
图形化界面中也能看到之前备份的sources.list文件:
六、获取root用户
在安装软件等情况下时,可能会提示权限不够,获取root权限流程如下:
补充:
(ufw防火墙相关命令)
Usage: ufw COMMAND
Commands:
enable enables the firewall
disable disables the firewall
default ARG set default policy
logging LEVEL set logging to LEVEL
allow ARGS add allow rule
deny ARGS add deny rule
reject ARGS add reject rule
limit ARGS add limit rule
delete RULE|NUM delete RULE
insert NUM RULE insert RULE at NUM
prepend RULE prepend RULE
route RULE add route RULE
route delete RULE|NUM delete route RULE
route insert NUM RULE insert route RULE at NUM
reload reload firewall
reset reset firewall
status show firewall status
status numbered show firewall status as numbered list of RULES
status verbose show verbose firewall status
show ARG show firewall report
version display version information
Application profile commands:
app list list application profiles
app info PROFILE show information on PROFILE
app update PROFILE update PROFILE
app default ARG set default application policy