- sudo apt-get更新 : 简而言之,apt-get更新实际上不会安装新版本的软件。相反,它会更新软件包列表以进行需要升级的软件包的升级,以及刚刚进入存储库的新软件包。
- sudo apt-get升级 : 如果APT通过apt-get更新了解了这些新版本,则将获取计算机上现有软件包的新版本。必须首先执行更新,以便apt-get知道有新版本的软件包可用。
- 须藤apt-get dist-upgrade: 将完成由 apt-get升级,而且它还将智能处理依赖关系,因此它可能会删除过时的软件包或添加新的软件包。
注意:我们可以将命令与&& signs, such as:
- sudo apt-get更新&&须藤apt-get dist-upgrade
2.安装并启动SSH服务
- sudo apt-get install openssh-server
- sudo服务ssh启动
使用netstat命令验证:
-t:tcp
-u:udp
-l:听
-p:程序/ pid
-n:数字
[email protected]:~$ netstat -tulpn (Not all processes could be identified, non-owned process info will not be shown, you would have to be root to see it all.) Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN - tcp6 0 0 :::22 :::* LISTEN - udp 0 0 0.0.0.0:68 0.0.0.0:* - [email protected]:~$
3.允许Root登录并设置Root密码
设置root密码
4.配置DNS和IP
编辑DNS配置文件:
/etc/systemd/resolved.conf
找到“ DNS”部分,然后添加您的DNS服务器IP地址:
DNS= 1.1.1.1 8.8.4.4 192.168.2.1
5.配置apt源
此处已设置阿里云源码
6.更改时区
检查时区
修改时区
校验
注意:命令 ‘timedatectl’
7.修复损坏的Ubuntu,无需重新安装
$ sudo rm /var/lib/apt/lists/lock
$ sudo rm /var/lib/dpkg/lock
$ sudo rm /var/lib/dpkg/lock-frontend
$ sudo dpkg --configure -a
$ sudo apt clean
$ sudo apt更新--fix-missing
$ sudo apt install -f
$ sudo dpkg --configure -a
$ sudo apt upgrade
$ sudo apt dist-upgrade
最后一步,“ sudo重新启动”
8.检查Ubuntu版本/ CPU /发行信息
[email protected]:~# getconf LONG_BIT
64
[email protected]:~# lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 18.04.1 LTS
Release: 18.04
Codename: bionic
[email protected]:~# uname -a 的Linux wan 4.15.0-29-generic #31-Ubuntu SMP Tue Jul 17 13:11:22 UTC 2017 x86_64
[email protected]:~# cat /proc/cpuinfo
processor : 0
vendor_id : GenuineIntel
cpu family : 6
model : 142
model name : Intel(R) Core(TM) i5-4300U CPU @ 2.10GHz
stepping : 9
microcode : 0x4e
cpu MHz : 2712.050
cache size : 3072 KB
physical id : 0
siblings : 2
core id : 0
cpu cores : 2
apicid : 0
initial apicid : 0
fpu : yes
fpu_exception : yes
cpuid level : 22
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon nopl xtopology tsc_reliable nonstop_tsc cpuid pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch cpuid_fault invpcid_single pti fsgsbase tsc_adjust bmi1 avx2 smep bmi2 invpcid mpx rdseed adx smap clflushopt xsaveopt xsavec xsaves arat
bugs : cpu_meltdown spectre_v1 spectre_v2 spec_store_bypass
bogomips : 5424.10
clflush size : 64
cache_alignment : 64
address sizes : 43 bits physical, 48 bits virtual
power management:
processor : 1
vendor_id : GenuineIntel
cpu family : 6
model : 142
model name : Intel(R) Core(TM) i5-4300U CPU @ 2.10GHz
stepping : 9
microcode : 0x4e
cpu MHz : 2712.050
cache size : 3072 KB
physical id : 0
siblings : 2
core id : 1
cpu cores : 2
apicid : 1
initial apicid : 1
fpu : yes
fpu_exception : yes
cpuid level : 22
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon nopl xtopology tsc_reliable nonstop_tsc cpuid pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch cpuid_fault invpcid_single pti fsgsbase tsc_adjust bmi1 avx2 smep bmi2 invpcid mpx rdseed adx smap clflushopt xsaveopt xsavec xsaves arat
bugs : cpu_meltdown spectre_v1 spectre_v2 spec_store_bypass
bogomips : 5424.10
clflush size : 64
cache_alignment : 64
address sizes : 43 bits physical, 48 bits virtual
power management:
9.在Ubuntu上安装和配置Samba服务器
9.1安装Samba
[email protected]:~# apt-get install samba
9.2更改配置文件
[email protected]:~# vi /etc/samba/smb.conf
在smb.conf的末尾附加以下配置
[share]
path = /Deepinfar
available=yes
browseable = yes
public = yes
writeable = yes
guest ok = no
9.3将root用户添加到Samba用户列表
[email protected]:~# smbpasswd -a root
9.4重新启动Samba服务并从Windows测试
[email protected]:~# smbd start
在Windows中,您可以访问以下位置的共享文件夹 \\ 192.168.2.102 \ share \ 使用root用户名和密码。
10.禁用 apt-daily.service和apt-daily-upgrade.service
我的一个云VM的CPU间歇性过高,导致停机问题。 从syslog的显示来看,恰恰是在时间上,每日apt下载活动导致系统CPU容量过高和系统服务崩溃。
[email protected]:/var/log$more /var/log/syslog
Aug 30 17:39:08 ubuntu18niginxmariadb2 systemd[1]: Started Clean php session files. Aug 30 17:53:27 ubuntu18niginxmariadb2 systemd[1]: Starting Daily apt download activities... Aug 30 18:06:08 ubuntu18niginxmariadb2 mysqld[1321]: 2019-08-30 18:05:52 20017 [Warning] Aborted connection 20017 to db: 'wp_db' user: 'wp_db_user' host: 'localhost' (Got timeout reading communication packets) Aug 30 18:07:34 ubuntu18niginxmariadb2 mysqld[1321]: 2019-08-30 18:07:10 20015 [Warning] Aborted connection 20015 to db: 'wp_db' user: 'wp_db_user' host: 'localhost' (Got timeout reading communication packets) Aug 30 18:13:58 ubuntu18niginxmariadb2 systemd-networkd[687]: ens4: Could not set DHCPv4 address: Connection timed out Aug 30 18:28:14 ubuntu18niginxmariadb2 systemd-networkd[687]: ens4: Failed Aug 30 18:46:47 ubuntu18niginxmariadb2 mysqld[1321]: 2019-08-30 18:19:37 20014 [Warning] Aborted connection 20014 to db: 'wp_db' user: 'wp_db_user' host: 'localhost' (Got timeout reading communication packets) Aug 30 19:01:31 ubuntu18niginxmariadb2 mysqld[1321]: 2019-08-30 18:21:29 20016 [Warning] Aborted connection 20016 to db: 'wp_db' user: 'wp_db_user' host: 'localhost' (Got timeout reading communication packets) Aug 30 19:25:22 ubuntu18niginxmariadb2 kernel: [168290.564611] ip invoked oom-killer: gfp_mask=0x14200ca(GFP_HIGHUSER_MOVABLE), nodemask=(null), order=0, oom_score_adj=0 Aug 30 19:25:22 ubuntu18niginxmariadb2 kernel: [168290.564614] ip cpuset=/ mems_allowed=0 Aug 30 19:25:22 ubuntu18niginxmariadb2 kernel: [168290.564626] CPU: 0 PID: 22356 Comm: ip Not tainted 4.15.0-1040-gcp #42-Ubuntu Aug 30 19:25:22 ubuntu18niginxmariadb2 kernel: [168290.564627] Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
根据systemctl的输出,我们可以找到两个相关的服务,apt-daily-upgrade.timer和apt-daily.timer
[email protected]:/var/log$ systemctl
.....
.....
timers.target loaded active active Timers apt-daily-upgrade.timer loaded active waiting Daily apt upgrade and clea apt-daily.timer loaded active waiting Daily apt download activit fstrim.timer loaded active waiting Discard unused blocks 上 ce motd-news.timer loaded active waiting Message of the Day phpsessionclean.timer loaded active waiting Clean PHP session files ev systemd-tmpfiles-clean.timer loaded active waiting Daily Cleanup of Temporary LOAD = Reflects whether the unit definition was properly loaded. ACTIVE = The high-level unit activation state, i.e. generalization of SUB. SUB = The low-level unit activation state, values depend 上 unit type. 176 loaded units listed. Pass --all to see loaded but inactive units, too. To show all installed unit files use 'systemctl list-unit-files'.
[email protected]:/var/log$ systemctl | grep timer timers.target loaded active active Timers apt-daily-upgrade.timer loaded active waiting Daily apt upgrade and clean activities apt-daily.timer loaded active waiting Daily apt download activities fstrim.timer loaded active waiting Discard unused blocks 上 ce a week motd-news.timer loaded active waiting Message of the Day phpsessionclean.timer loaded active waiting Clean PHP session files every 30 mins systemd-tmpfiles-clean.timer loaded active waiting Daily Cleanup of Temporary Directories [email protected]:/var/log$
我确实知道这两项服务可确保我的Ubuntu软件包保持更新和安全。但是我更关心系统可靠性。在这种情况下,我更希望禁用这两项服务,并且我将在适当的时候使用命令“sudo apt更新& sudo apt -y upgrade ”。
这是禁用这两个计时器和服务的四个命令。
sudo systemctl disable apt-daily.service
sudo systemctl disable apt-daily.timer
sudo systemctl disable apt-daily-upgrade.timer
sudo systemctl disable apt-daily-upgrade.service
sudo systemctl mask apt-daily.service
sudo systemctl daemon-reload
[email protected]:/var/log$ sudo systemctl disable apt-daily.service
[email protected]:/var/log$ sudo systemctl disable apt-daily.timer
Removed /etc/systemd/system/timers.target.wants/apt-daily.timer.
[email protected]:/var/log$
[email protected]:/var/log$ sudo systemctl disable apt-daily-upgrade.timer
Removed /etc/systemd/system/timers.target.wants/apt-daily-upgrade.timer.
[email protected]:/var/log$ sudo systemctl disable apt-daily-upgrade.service
[email protected]:/var/log$
[email protected]:~$ sudo systemctl mask apt-daily.service Created symlink /etc/systemd/system/apt-daily.service → /dev/null. [email protected]:~$ sudo systemctl daemon-reload [email protected]:~$ sudo systemctl status apt-daily.service ● apt-daily.service Loaded: masked (/dev/null; bad) Active: inactive (dead) [email protected]:~$