说明:

本文所列脚本、命令等,如无特殊标注,均为Ubuntu、Debian系统。Centos和Alpine系统命令会有所不同。

一、常用命令

1.vps登录后第一件事,更新源:

apt update -y && apt upgrade -y

2.安装常用软件,如wget、curl,有些精简的系统过于精简。

apt install -y sudo htop bash cron vnstat vim nano net-tools curl wget ufw iptables

apt install 是安装命令,缺啥自己安装。

3.有时候当内存不够时,会开启swap,用硬盘扩充部分内存(lxc小鸡不行)

wget https://www.moerats.com/usr/shell/swap.sh && bash swap.sh

4.查看内存使用情况

free -h

5.查看硬盘使用情况

df -h

6.查看ip

curl -4 ifconfig.me

curl -6 ifconfig.me

curl ipinfo.io

curl ip.sb

7.更改密码

passwd

8.查看系统架构

dpkg --print-architecture

9.查看系统版本

lsb_release -a

10.换CN源-脚本🟢当你的vps为国内鸡时,需要换为阿里源或清华源

bash <(curl -sSL https://linuxmirrors.cn/main.sh)

11..查看虚拟化KVM还是LXC

systemd-detect-virt

12.查看当前时间和日期

date

13.查看当前时区

timedatectl

14.调整时区为+8

sudo timedatectl set-timezone Asia/Shanghai