1. Establish the current state

lsb_release -a
uname -r
sudo apt update
apt list --upgradable

Package metadata refresh and package installation are separate operations. Review the upgrade list and understand whether kernel, network, SSH or web-server packages are involved.

2. Apply updates deliberately

sudo apt upgrade

For production systems, schedule maintenance, ensure backups exist and review service restart prompts. A kernel update may require a reboot before the running kernel changes.

test -f /var/run/reboot-required && echo "Reboot required"
who -b
uname -r
中文说明:软件包已更新不等于新内核已经运行。重启前应确认维护窗口、业务影响和恢复方案。

3. Review listening services and accounts

sudo ss -tulpn
getent passwd | awk -F: '$3==0 {print $1, $6, $7}'
getent group sudo
sudo last -a | head -20

Investigate unexpected listeners, extra UID 0 accounts, unnecessary privileged users and unusual login history. Some service accounts are expected; verify ownership before removal.

4. Review security logs

sudo journalctl -p warning..alert --since "24 hours ago"
sudo journalctl -u ssh --since "24 hours ago" --no-pager
sudo systemctl --failed

Correlate alerts with deployments and maintenance events. Avoid logging secrets, passwords, private keys or full authentication tokens.

5. Check file integrity and permissions

sudo find /etc -xdev -type f -perm -0002 -ls
sudo find / -xdev -type f -perm -4000 -ls 2>/dev/null

These commands identify world-writable files under /etc and setuid files on the root filesystem. Findings are not automatically vulnerabilities; compare with package defaults and documented exceptions.

6. Back up before risky changes

sudo tar --xattrs --acls -czf /root/etc-backup-$(date +%F).tar.gz /etc

This is a basic configuration archive, not a complete disaster-recovery backup. Copy backups off-host, encrypt sensitive archives and test restoration.

7. A practical weekly review

  • Review available security updates.
  • Check failed units and warning-level logs.
  • Review privileged accounts and SSH access.
  • Review listening ports and firewall policy.
  • Verify backup freshness and restore procedure.
  • Record changes and maintenance windows.

References & further reading

Commands are examples for a representative Ubuntu/Linux environment. Review paths, versions, access requirements and maintenance impact before applying them to production systems.