ubuntu 2404 系统安装
创建虚拟机
创建过程省略。
安装过程
提示:为了防止连网更新软件包,该地方需断开网卡安装系统。系统安装完成后,再配置网络。
更改地址为 http://mirrors.aliyun.com/ubuntu
使用华为的mirror速度更快:http://mirrors.huaweicloud.com/ubuntu
等待安装完成,该过程需要从Internet上下载软件包,还可以查看安装日志。
安装完成
重启系统
出现以下提示,不用理会,直接回车继续重启。
[FAIED] Failed unmounting /dev/cdrom安装后配置
安装常规软件包
vim和命令补全软件包。
ggg@ubuntu:~$sudoapt-getinstall-yvimbash-completion配置 IP
ggg@ubuntu:~$cd/etc/netplan/ ggg@ubuntu:/etc/netplan$sudomkdirbackup ggg@ubuntu:/etc/netplan$sudomv50-cloud-init.yaml backup ggg@ubuntu:/etc/netplan$sudovim00-installer-config.yaml# This is the network config written by 'subiquity'network: ethernets: ens32: dhcp4: no addresses: -10.1.8.10/24 routes: - to: default via:10.1.8.2 nameservers: addresses: -223.5.5.5 -223.6.6.6 version:2# 应用配置ggg@ubuntu:/etc/netplan$sudochmod60000-installer-config.yaml ggg@ubuntu:/etc/netplan$sudonetplan apply配置 root 密码
ggg@ubuntu:~$sudopasswdroot[sudo]passwordforggg:`123`New password:`123`Retype new password:`123`passwd: password updated successfully配置 root 远程登录
ggg@ubuntu:~$sudovim/etc/ssh/sshd_config#PermitRootLogin prohibit-passwordPermitRootLoginyes# 重新sshd服务配置ggg@ubuntu:~$sudosystemctl reloadsshggg@ubuntu:~$sudosystemctlenablesshubuntu 系统网络管理
netplan
介绍
Netplan是Canonical(Ubuntu系统的开发和维护组织)开发的实用程序,能在Linux系统上轻松配置网络。要配置网络接口,只需创建所需网络接口的YAML描述,然后Netplan将为所选的渲染器工具生成所有必需的配置。
您可以在/usr/share/doc/netplan/examples中找到Netplan网络配置文件。Netplan当前支持以下后端渲染器,例如NetworkManager和Systemd-networkd。
netplan只是NetworkManager和Systemd-networkd前端工具。
Netplan定义文件位于/etc/netplan目录,例如/etc/netplan/00-ens32.yaml。
示例
示例1:定义一个静态配置ip
root@ubuntu:/usr/share/doc/netplan/examples# cat static.yamlnetwork:ethernets:ens33:dhcp4:noaddresses:-10.1.8.88/24routes:-to:defaultvia:10.1.8.2nameservers:addresses:-10.1.8.2-223.5.5.5version:2示例2:定义一个动态获取ip
root@ubuntu:/usr/share/doc/netplan/examples# cat dhcp.yamlnetwork:version:2renderer:networkdethernets:enp3s0:dhcp4:true命令
应用上面定义的配置文件:
root@ubuntu:~# netplan apply# 获取当前配置信息root@ubuntu:~# netplan getnetwork: version:2ethernets: ens33: addresses: -"10.1.8.88/24"nameservers: addresses: -10.1.8.2 -223.5.5.5 dhcp4:falseroutes: - to:"default"via:"10.1.8.2"ubuntu 系统软件包管理
使用apt管理软件包
atp和apt-xxx命令 区别-中文
atp和apt-xxx命令 区别-英文
apt 和 其他apt命令
命令区别
虽然 apt 与 apt-get 有一些类似的命令选项,但它并不能完全向下兼容 apt-get 命令。也就是说,可以用 apt 替换部分 apt-get 系列命令,但不是全部。
| apt 命令 | 取代的命令 | 命令的功能 |
|---|---|---|
| apt install | apt-get install | 安装软件包 |
| apt remove | apt-get remove | 移除软件包 |
| apt purge | apt-get purge | 移除软件包及配置文件 |
| apt update | apt-get update | 刷新存储库索引 |
| apt upgrade | apt-get upgrade | 升级所有可升级的软件包 |
| apt autoremove | apt-get autoremove | 自动删除不需要的包 |
| apt full-upgrade | apt-get dist-upgrade | 在升级软件包时自动处理依赖关系 |
| apt search | apt-cache search | 搜索应用程序 |
| apt show | apt-cache show | 显示装细节 |
apt 还有一些自己的命令:
| 新的apt命令 | 命令的功能 |
|---|---|
| apt list | 列出包含条件的包(已安装,可升级等) |
| apt edit-sources | 编辑源列表 |
apt
子命令
root@ubuntu:~# apt --<tab><tab>autoclean dependsinstallreinstall update autopurge dist-upgrade list remove upgrade autoremove download moo search build-dep edit-sources policy show changelog full-upgrade purge showsrc cleanhelprdependssourceupdate 子命令
update - update list of available packages
从软件仓库中获取最新软件清单。
root@ubuntu:~# apt update相当于yum makecache
list 子命令
list - list packages based on package names
查看软件仓库中软件清单。
# 可用于查看的选项root@ubuntu:~# apt list --<tab><tab>--all-versions --manual-installed--upgradable--installed--target-release--verbose# 查看软件包清单root@ubuntu:~# apt listWARNING:aptdoes not have a stable CLI interface. Use with cautioninscripts. Listing... 0ad-data-common/jammy,jammy0.0.25b-1 all 0ad-data/jammy,jammy0.0.25b-1 all 0ad/jammy0.0.25b-2 amd64 0install-core/jammy2.16-2 amd64......# 查看特定软件包root@ubuntu:~# apt list openssh-serverListing... Done openssh-server/jammy-updates,now1:8.9p1-3ubuntu0.1 amd64[installed]openssh-server/jammy-updates1:8.9p1-3ubuntu0.1 i386# 查看特定软件包所有版本root@ubuntu:~# apt list openssh-server --all-versionsListing... Done openssh-server/jammy-updates,now1:8.9p1-3ubuntu0.1 amd64[installed]openssh-server/jammy1:8.9p1-3 amd64 openssh-server/jammy-updates1:8.9p1-3ubuntu0.1 i386 openssh-server/jammy1:8.9p1-3 i386show 子命令
show - show package details
查看仓库中软件包详细信息。
root@ubuntu:~# apt show openssh-server# 类似 dpkg -s openssh-serversearch 子命令
search - search in package descriptions
root@ubuntu:~# apt search --<tab><tab>--full--names-only root@ubuntu:~# apt search --names-only apache2install 子命令
install - install packages
从仓库中获取软件包并安装。
root@ubuntu:~# apt install --<tab><tab>--allow-change-held-packages --fix-broken--purge--allow-downgrades --fix-missing--reinstall--allow-insecure-repositories --fix-policy--remove--allow-remove-essential --force-yes --show-progress --allow-unauthenticated --ignore-hold --show-upgraded --arch-only --ignore-missing--simulate--assume-no --install-recommends--solver--assume-yes --install-suggests --target-release --auto-remove --no-install-recommends --trivial-only--download--no-install-suggests--upgrade--download-only --only-upgrade --verbose-versions --dry-run --print-uris root@ubuntu:~# apt install apache2 -y# 安装特定版本root@ubuntu:~# apt install apache2=2.4.52-1ubuntu4.5reinstall 子命令
reinstall - reinstall packages
从仓库中获取软件包并再次安装(系统中已安装)。
root@ubuntu:~# apt reinstall apache2 -yremove 子命令
remove - remove packages
卸载系统中已安装软件包。
root@ubuntu:~# apt remove apache2 -yReading package lists... Done Building dependency tree... Done Reading state information... Done The following packages were automatically installed and are no longer required: apache2-bin apache2-data apache2-utils libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap Use'apt autoremove'to remove them. The following packages will be REMOVED: apache20upgraded,0newly installed,1to remove and282not upgraded. After this operation,546kB disk space will be freed.(Reading database...202598files and directories currently installed.)Removing apache2(2.4.52-1ubuntu4.5)... Processing triggersforman-db(2.10.2-1)... Processing triggersforufw(0.36.1-4build1)...autoremove 子命令
autoremove - Remove automatically all unused packages
root@ubuntu:~# apt autoremove -yupgrade 子命令
upgrade - upgrade the system by installing/upgrading packages
# 升级系统所有可更新软件包root@ubuntu:~# apt upgrade# 升级系统中特定软件包root@ubuntu:~# apt upgrade openssh-server -yfull-upgrade 子命令
full-upgrade - upgrade the system by removing/installing/upgrading packages
# 升级系统所有可更新软件包root@ubuntu:~# apt full-upgrade# 升级系统中特定软件包root@ubuntu:~# apt full-upgrade openssh-server -ydownload 子命令
download - download packages
root@ubuntu:~# apt download openssh-serverroot@ubuntu:~# lsopenssh-server_1%3a8.9p1-3ubuntu0.1_amd64.debedit-sources 子命令
edit-sources - edit the source information file
root@ubuntu:~# export EDITOR=vimroot@ubuntu:~# apt edit-sources# 使用vim编辑文件 /etc/apt/sources.listapt-file
作用:查找软件包中文件。
apt-file is a command line tool for searching files in packages for the APT package management system.
帮助信息
root@ubuntu:~# apt-file --helpapt-file[options]action[pattern]apt-file[options]-faction<file>apt-file[options]-Daction<debfile>Pattern options:================--fixed-string-FDo notexpandpattern --from-deb-DUsefilelist of .deb package(s)as patterns;implies-F--from-file-fRead patterns from file(s), one per line(use'-'forstdin)--ignore-case-iIgnorecasedistinctions--regexp-xpattern is a regular expression --substring-match pattern is a substring(no glob/regex)Search filter options:======================--architecture-a<arch>Use specific architecture[L]--index-names-I<names>Only search indices listedin<names>[L]--filter-suites<suites>Only search indicesforthe listed<suites>[L](E.g."unstable")--filter-origins<origins>Only search indices from<origins>[L](E.g."Debian")Other options:==============--config-c<file>Parse the given APT configfile[R]--option-o<A::B>=<V>Set the APT config option A::B to"V"[R]--package-only-lOnly display packages name--verbose-vruninverbose mode[R]--help-hShow this help. -- End of options(necessaryifpattern starts with a'-')[L]: Takes a comma-separated list of values.[R]: The option can be used repeatedly Action: list|show<pattern>List filesinpackages list-indices List indices configuredinAPT. search|find<pattern>Search filesinpackages update Fetch Contents files from apt-sources.示例
# 更新apt仓库中文件清单缓存root@ubuntu:~# apt-file update# 仓库中某个软件包的文件清单root@ubuntu:~# apt-file list openssh-serveropenssh-server: /etc/default/ssh openssh-server: /etc/init.d/ssh openssh-server: /etc/pam.d/sshd openssh-server: /etc/ssh/moduli openssh-server: /etc/ufw/applications.d/openssh-server openssh-server: /lib/systemd/system/rescue-ssh.target......# 使用正则表达式查询ifconfig工具由哪个软件包提供root@ubuntu:~# apt-file -x search '.*bin/ifconfig$'net-tools: /sbin/ifconfig