官网 https://cn.ubuntu.com/
最小镜像 https://help.ubuntu.com/community/Installation/MinimalCD/
下载最小镜像
http://archive.ubuntu.com/ubuntu/dists/bionic-updates/main/installer-amd64/current/images/netboot/mini.iso

1.Ubuntu添加源

中科大 这个源

sudo add-apt-repository "deb [arch=amd64] https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu $(lsb_release -cs) stable" # 由于没有公钥,无法验证下列签名: NO_PUBKEY 7EA0A9C3F273FCD8,需要下载公钥
root@ubuntu-demo:/etc/apt# curl -fsSL https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/uste-docker-archive-keyring.gpg
root@ubuntu-demo:/etc/apt# ll /usr/share/keyrings/u
ubuntu-advantage-cc-eal.gpg            ubuntu-advantage-fips.gpg              ubuntu-archive-removed-keys.gpg        uste-docker-archive-keyring.gpg
ubuntu-advantage-cis.gpg               ubuntu-advantage-realtime-kernel.gpg   ubuntu-cloudimage-keyring.gpg
ubuntu-advantage-esm-apps.gpg          ubuntu-advantage-ros.gpg               ubuntu-cloudimage-removed-keys.gpg
ubuntu-advantage-esm-infra-trusty.gpg  ubuntu-archive-keyring.gpg             ubuntu-master-keyring.gpg
#需要重新添加源·
sudo add-apt-repository " deb [arch=amd64  signed-by=/usr/share/keyrings/uste-docker-archive-keyring.gpg]  https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu $(lsb_release -cs) stable"

ubunt添加nginx的官方源
下载官方的key http://nginx.org/keys/nginx_signing.key

root@ubunt-demo:/tmp# rz -E
rz waiting to receive.
root@ubunt-demo:/tmp# sudo apt-key add nginx_signing.key
OKroot@ubunt-demo:~# vim  /etc/apt/sources.list
deb http://nginx.org/packages/ubuntu/ bionic  nginx
deb-src http://nginx.org/packages/ubuntu/ bionic nginxapt update

2 ubuntu修改ip地址

root@ubuntu-demo:~# cat /etc/netplan/00-installer-config.yaml
# This is the network config written by 'subiquity'
network:ethernets:enp0s3:dhcp4: trueenp0s8:addresses:- 192.168.56.111/24gateway4: 192.168.56.1nameservers:addresses:- 8.8.8.8- 114.114.114.114search:- 192.168.56.1version: 2#应用网卡配置netplan apply

3.Ubuntu关于系统时间的修改

3.1 修改时区

###修改时区
root@ubunt-demo:~# timedatectl set-timezone  Asia/Shanghai
root@ubunt-demo:~# timedatectl Local time: Thu 2022-02-10 17:13:45 CSTUniversal time: Thu 2022-02-10 09:13:45 UTCRTC time: Thu 2022-02-10 09:13:46    Time zone: Asia/Shanghai (CST, +0800)
System clock synchronized: no                         NTP service: n/a                        RTC in local TZ: no
root@ubunt-demo:~# cat /etc/default/locale
LANG=en_US.UTF-8
root@ubunt-demo:~# vim /etc/default/locale
root@ubunt-demo:~# cat  /etc/default/locale
LANG=en_US.UTF-8
LC_TIME=en_DK.UTF-8
root@ubunt-demo:~#reboot

需要修改时间为24小时,可以修改/etc/default/locale,默认没有LC_TIME这个变量,在文件中增加一行:
LC_TIME=en_DK.UTF-8

3.2配置时间同步

System clock synchronized: no 反映了没有和远程NTP服务器成功同步, NTP service: n/a 意味着timesyncd没有启动和运行。RTC in local TZ: no表示硬件时钟(RTC)设置为协调世界时(UTC),yes表示硬件时钟设置为本地时间.

root@ubuntu-demo:~# timedatectl statusLocal time: Thu 2023-03-16 14:24:33 CSTUniversal time: Thu 2023-03-16 06:24:33 UTCRTC time: Thu 2023-03-16 06:24:33    Time zone: Asia/Shanghai (CST, +0800)
System clock synchronized: no       #没有开启时间同步                    NTP service: active                     RTC in local TZ: no
root@ubuntu-demo:~# apt-get install systemd-timesyncd
root@ubuntu-demo:~# cat  /etc/systemd/timesyncd.conf
[Time]
NTP=ntp.tencent.com
FallbackNTP=ntp1.tencent.com,ntp2.tencent.com,ntp3.tencent.com
RootDistanceMaxSec=5
PollIntervalMinSec=32
PollIntervalMaxSec=2048root@ubuntu-demo:~#systemctl restart systemd-timesyncd

3.3开启网络时间同步

#开启网络时间同步true/flash
root@ubuntu-demo:~# timedatectl set-ntp true
root@ubuntu-demo:~# timedatectl statusLocal time: Thu 2023-03-16 14:53:46 CSTUniversal time: Thu 2023-03-16 06:53:46 UTCRTC time: Thu 2023-03-16 06:53:47    Time zone: Asia/Shanghai (CST, +0800)
System clock synchronized: yes                        NTP service: active                     RTC in local TZ: no

3.4开启本地时间同步 这个不需要配置,开启网络时间同步就够了

root@ubuntu-demo:~# timedatectl set-local-rtc yes
root@ubuntu-demo:~# timedatectl statusLocal time: Thu 2023-03-16 14:54:54 CSTUniversal time: Thu 2023-03-16 06:54:54 UTCRTC time: Thu 2023-03-16 14:54:54    Time zone: Asia/Shanghai (CST, +0800)
System clock synchronized: yes                        NTP service: active                     RTC in local TZ: yes                        Warning: The system is configured to read the RTC time in the local time zone.This mode cannot be fully supported. It will create various problemswith time zone changes and daylight saving time adjustments. The RTCtime is never updated, it relies on external facilities to maintain it.If at all possible, use RTC in UTC by calling'timedatectl set-local-rtc 0'.
root@ubuntu-demo:~# timedatectl set-local-rtc 0
root@ubuntu-demo:~# timedatectl statusLocal time: Thu 2023-03-16 14:55:23 CSTUniversal time: Thu 2023-03-16 06:55:23 UTCRTC time: Thu 2023-03-16 06:55:23    Time zone: Asia/Shanghai (CST, +0800)
System clock synchronized: yes                        NTP service: active                     RTC in local TZ: no

4.ubuntu 打开message日志

root@ubunt-demo:~# vim /etc/rsyslog.d/50-default.conf
#添加
*.info;mail.none;authpriv.none;cron.none        /var/log/messages
root@ubunt-demo:~# systemctl restart rsyslog.service
root@ubunt-demo:~# ll /var/log/messages
-rw-r----- 1 syslog adm 923 Feb 10 17:57 /var/log/messages

5 ubunt添加nginx的官方源

下载官方的key http://nginx.org/keys/nginx_signing.key

root@ubunt-demo:/tmp# rz -E
rz waiting to receive.
root@ubunt-demo:/tmp# sudo apt-key add nginx_signing.key
OKroot@ubunt-demo:~# vim  /etc/apt/sources.list
deb http://nginx.org/packages/ubuntu/ bionic  nginx
deb-src http://nginx.org/packages/ubuntu/ bionic nginxapt update

6 查看系统版本

root@ubunt-demo:~# lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 20.04.3 LTS
Release:    20.04
Codename:   focal

7 查看开机自启动的服务

root@ubuntu-demo:~# systemctl list-unit-files --type service --state enabled

8查看需要安装的服务版本,并指定版本安装

查看需要安装的服务版本

1、使用 madison 命令apt-cache madison <<package name>>
将列出所有来源的版本。如下输出所示:
apt-cache madison vimmadison 是一个 apt-cache 子命令,可以通过 man apt-cache 查询更多用法。2、使用 policy 命令
apt-cache policy <<package name>>
将列出所有来源的版本。信息会比上面详细一点,如下输出所示:apt-cache policy gdbpolicy 是一个 apt-cache 子命令,可以通过 man apt-cache 查询更多用法。3、使用 showpkg 命令apt-cache showpkg <<package name>>4、使用 install 命令apt-get install -s <<package-name>>
说明:这个命令只是模拟安装时会安装哪些软件列表,但不会例举出每个软件有多少个版本5、使用 aptitude 命令以上基本都是使用的 apt-cache 的子命令,下面介绍点别的,比如这个使用 aptitude 命令的。aptitude versions <<package name>>
参考:https://manpages.debian.org/unstable/aptitude/aptitude.8.en.html6、使用 apt-show-versions 命令apt-show-versions -a <<package name>>
说明:列举出所有版本,且能查看是否已经安装。还可以通过 apt-show-versions -u <<package name>> 来查询是否有升级版本。参考:http://manpages.ubuntu.com/manpages/trusty/man1/apt-show-versions.1p.html7、使用 whohas 命令whohas -d Debian,Ubuntu <<package name>> | tr -s ' ' '\t' | cut -f 1-3 | column -t
8、使用 rmadison 命令rmadison -u debian,ubuntu,bpo <<package name>> | cut -d "|" -f 1-3

指定版本安装

安装时指定版本则比较简单,只需要使用下面的命令即可:apt-get install <<package name>>=<<version>>需要注意的是,如果是使用 pip 来安装东西并且指定版本,则需要两个等号(apt-get 则只需要一个等号),比如:pip install <<package name>>==<<version>>

9安装软件报错

root@ubuntu-demo:/etc/apt# apt-get  install docker.io
E: Could not get lock /var/lib/dpkg/lock-frontend. It is held by process 5893 (unattended-upgr)
N: Be aware that removing the lock file is not a solution and may break your system.
E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), is another process using it?

处理 结束报错里面的进程

apt-get install docker.io

10 apt-get update 与apt-get upgrade

言之,update是更新可安装软件列表到当前运行ubuntu系统,upgrade是更新当前ubuntu系统已经安装了的软件到最新

11 查看某个文件(命令)属于哪个包

root@ubuntu-demo:~# apt install apt-file
root@ubuntu-demo:~# apt-file update
root@ubuntu-demo:~# which  tar
/usr/bin/tar#搜出来一堆 难道都是安装吗
root@ubuntu-demo:~#apt-file search /usr/bin/tar
argyll: /usr/bin/targen
python3-rtslib-fb: /usr/bin/targetctl
squashfs-tools-ng: /usr/bin/tar2sqfs
tar-split: /usr/bin/tar-split
tarantool: /usr/bin/tarantool
tarantool-common: /usr/bin/tarantoolctl
tarantool-lts: /usr/bin/tarantar
tarantool-lts: /usr/bin/tarantool_box
tarantool-lts-client: /usr/bin/tarantool
tardiff: /usr/bin/tardiff
tardy: /usr/bin/tardy
targetcli-fb: /usr/bin/targetcli
targetcli-fb: /usr/bin/targetclid
tarlz: /usr/bin/tarlz
tart: /usr/bin/tart

12 常用的APT命令参数


apt-cache search package 搜索包apt-cache show package 获取包的相关信息,如说明、大小、版本等sudo apt-get install package 安装包sudo apt-get install package - - reinstall 重新安装包sudo apt-get -f install 修复安装"-f = --fix-missing"sudo apt-get remove package 删除包sudo apt-get remove package - - purge 删除包,包括删除配置文件等sudo apt-get update 更新源sudo apt-get upgrade 更新已安装的包sudo apt-get dist-upgrade 升级系统sudo apt-get dselect-upgrade 使用 dselect 升级apt-cache depends package 了解使用依赖apt-cache rdepends package 是查看该包被哪些包依赖sudo apt-get build-dep package 安装相关的编译环境apt-get source package 下载该包的源代码sudo apt-get clean && sudo apt-get autoclean 清理无用的包sudo apt-get check 检查是否有损坏的依赖

13 设置中文

13.1 安装中文语言包

root@ubuntu-demo:~# sudo apt install language-pack-zh*

13.2 增加中文语言环境

root@ubuntu-demo:~# cat /etc/environment | tail -1
LANG="zh_CN.UTF-8"

13.3 重新设置本地配置,将语言设置为中文

sudo dpkg-reconfigure locales

选中后按空格,然后回车键即可

方向键选择

root@ubuntu-demo:~# sudo dpkg-reconfigure locales
Generating locales (this might take a while)...en_US.UTF-8... donezh_CN.UTF-8... donezh_HK.UTF-8... donezh_SG.UTF-8... donezh_TW.UTF-8... done
Generation complete.root@ubuntu-demo:~# locale -a
C
C.UTF-8
POSIX
en_US.utf8
zh_CN.utf8
zh_SG.utf8

14 修改主机名

一个主机名就是在网络上标记一个设备的标签名称。在同一个网络中,你不应该有两台或者更多机器拥有同样的主机名。

在 Ubuntu 中,你可以使用hostnamectl命令编辑系统主机名以及相关设置。这个工具识别三种不同的主机名:

static - 传统主机名。它存储在/etc/hostname文件中,并且可以被用户设置
pretty - 一个自由形态的 UTF8 主机名,用来代表用户。例如: Linuxize’s desktop。
transient - 由 kernel 维护的动态主机名。 在运行过程中,DHCP 或者 mDNS 服务器可以改变 transient 主机名。默认情况下,它和 static 主机名一模一样。

静态主机名被存储在/etc/hostname,并且 pretty 主机名被存储在/etc/machine-info文件
如果你在一个云实例上运行 Ubuntu,并且安装了cloud-init软件包,你也可以编辑/etc/cloud/cloud.cfg文件。这个软件包由云服务器厂商提供,通常默认被安装,并且它可以被用来处理云服务器实例的初始化。

root@ubuntu-demo:~# hostname
ubuntu-demo
root@ubuntu-demo:~# hostnamectl Static hostname: ubuntu-demoPretty hostname: ubuntu_demoIcon name: computer-vmChassis: vmMachine ID: 587eae0dc1b44cc09dcf6673d15a00f6Boot ID: 87bdda6441054244ab574fc2317b7e33Virtualization: oracleOperating System: Ubuntu 20.04.6 LTSKernel: Linux 5.4.0-148-genericArchitecture: x86-64

报错
Could not set property: Invalid static hostname ‘ubuntu_node1’
不能使用下划线 _
应该使用连字符 -

Ubuntu简要操作相关推荐

  1. Ubuntu 常用操作

    Ubuntu常用操作 外观操作 修改应用icon图标 终端美化 内存管理 内存查询 分区管理 日志清理 操作执行 自动执行多条命令 外观操作 修改应用icon图标 在/usr/share/applic ...

  2. Ubuntu科学操作笔记---kalrry

    Ubuntu科学操作笔记---kalrry 前言 一.分区 二.换源 三.安装软件 二.更换app商店 二.雷鸟邮箱改中文语言 二.安装deepin的wine环境 前言 Win配置记录 Mac配置记录 ...

  3. docker——Ubuntu镜像操作和apache web容器操作小实训

    文章目录 Ubuntu镜像操作 apache web容器操作 Ubuntu镜像操作 (1)拉取最新的Ubuntu官方镜像. (2)查看该镜像的详细信息. (3)查看该镜像的构建历史. (4)删除该镜像 ...

  4. ssd 安装linux 教程,在Ubuntu中操作SSD固态驱动器的安装步骤和优化技巧

    毫无疑问,SSD硬盘对我们计算机的重要性.好的SSD硬盘驱动器可以帮助我们节省大量计算机空间.一些朋友在网络上提问.需要在Ubuntu系统中安装使用SSD固态驱动器.优化时,我不知道如何设置.关于这个 ...

  5. ubuntu -- 常规操作 编译、删除

    Ubuntu – 常规操作 一.gcc的编译 命令: sudo su 转换成超级用户 (暂时没用过) vi + 文件名: vi hello.c 打开文件.编译 (右键粘贴代码) 按i :insert进 ...

  6. Ubuntu桌面操作系统综合贴

    2019独角兽企业重金招聘Python工程师标准>>> 本文原为发表在卡饭论坛的介绍ubuntu的帖子:http://bbs.kafan.cn/thread-1551594-1-1. ...

  7. VMware下Ubuntu联网操作

    操作环境 主机:Win7 虚拟机:VMware station 虚拟机里的系统:Ubuntu 环境上,不管什么系统,什么版本的虚拟机,使用上都是大同小异的,毕竟核心是不变的. VM虚拟机下linux系 ...

  8. Ubuntu远程操作Linux服务器GUI程序

    此文针对在Server端执行gui程序失败的情况 OS:Ubuntu 12.04(以下操作应该在其他版本的Ubuntu上也适用) 首先,检查你的Xserver,看是否有一个"-noliste ...

  9. ubuntu grub 操作

    系统开机时,按住 shift 进入 grub 1. 什么是 Grub GNU GRUB(GRand Unified Bootloader 简称"GRUB")是一个来自GNU项目的多 ...

最新文章

  1. 2020年信息系统项目管理师真题讲解:基础知识1/3
  2. mysql多表查询语句_mysql查询语句 和 多表关联查询 以及 子查询
  3. 转:并发与并行的区别
  4. 解决微信小程序新建项目没有样式问题,以及官方demo
  5. 决策树模型(ID3/C4.5/CART)原理和底层代码解读 学习笔记
  6. SVN遇到Can't convert string from 'UTF-8' to native encoding(转)
  7. Visual Studio 2012 Update 4 RC 启动调试失败解决方案
  8. mfc 子窗体 按钮不触发_实战经验:MFC非模态对话框的使用
  9. python的三种取整方式_python3.6 numpy 数组的多种取整方式
  10. 阿里云张献涛:如何修炼云计算的弹指神通
  11. python 复制到剪贴板_Python脚本将文本复制到剪贴板
  12. 一个优秀的硬件工程师要具备的能力
  13. 【mmdetection】对VOC格式的数据集进行测试
  14. 这样给宝宝起小名,好听不俗气
  15. go 字符转ASCII 字符转成数字
  16. 金蝶云苍穹集成,苍穹到eas审核反审核
  17. 计算机专业有那些?原来有这么这么多
  18. 若依框架免密登录(仅做参考)
  19. python 词表里的词不符合_一年级语文下册,第1~4单元生字笔顺组词表,家长:这也太全面了...
  20. Java集合源码系列(1)---- ArrayList详解

热门文章

  1. 使用Quick打包工具接入应用宝渠道包,支付时出现“请求参数错误(pfkey)”的错误
  2. 年底前端面试题总结(下)
  3. 芒果TV登陆爬虫练习
  4. 在eclipse中使用安卓模拟器GENYMOTION
  5. DeepWalk(深度游走)算法
  6. 面包商铺(可作毕设或作业)
  7. [20160225] 太空工程师入门 / LOL 10级 / 股票走势预测
  8. LinUx安装PSX模拟器,pSX(PS模拟器)
  9. 东南大学自动化考研经验
  10. java文件删除语句_JAVA/JSP删除文件语句问题~~!