RHEL/centos/rocky/fedora/aliyun
使用dnf(yum,rpm)支持snap
ubuntu/debian/
使用snap(apt,deb)
系统相关
- cat /etc/os-release查看系统信息
- hostnamectl查看版本信息
- df -h磁盘空间使用情况
- free -h查看内存使用状况
- lscpucpu相关
- reboot重启
- halt关机
- clear CTRL+L清屏
- nohup frpc -c frpc.toml &后台启动- 软件版本
- ldd --version查看glibc版本
- git -v查看git版本
- ssh -V判断是否安装客户端- 目录文件操作
- cd ~进入root目录
- whereis redis-cli查看路径
- pwd当前路径
- ls- ls -l查看目录和详情
- mkdir a a1创建两个目录- mkdir -m 777 a带权限
- chmod 777 filename赋予权限- chmod -R 777 api/全部赋予权限
- mv dir1 dir2以动或重命名可以是文件或文件夹
- rm -rf *清空当前目录
- rm -rf dir1强制删除目录和内容,f是不提示
- cp –r test/ newtest复制全部内容包括子目录,复制单文件不需要r,目录时候必须要
- find /root/ -iname redis查找文件-iname不区分大小写
- grep -r "关键词" /路径路径下查找文件名
- ln -s file1 lnk1创建一个指向文件或目录的软链接- ln -s /root/gf /usr/bin软连接- 用户和组相关
- sudo以root权限执行命令
- passwd root修改root密码- passwd postgres修改密码
 ubuntu默认密码账号ubuntu| rockylinux 默认12345678端口23
- su -切换到root- su postgres切换用户postgres
- useradd postgres添加用户
- userdel postgres删除用户
- usermod -a -G groupname username添加用户到组
- groupadd postgres- groupdel postgres添加删除组
- w查看登陆用户
- id当前用户
- lastlog查看所有用户
- cat /etc/passwd查看所有用户路径- 进程端口相关
- ps aux查看全部进程
- ps -ef查看所有程序
- top动态进程
- ps -ef | grep weui查看某个应用进程
- lsof -i:4443查看某个端口进程
- kill 19999关闭pid端口进程
- pkill caddy关闭多个进程名称
- ss -tunlpa查看全部端口- 网络相关
- ifconfig查看网络
- ip a查看ip
- route -n查看路由
- pingping网址
- curl http://localhost
- wget -O file url下载- 分区
- dd if=/dev/zero of=/swap1 bs=1M count=2048创建交换分区
- mkswap /swap1创建
- swapon /swap1启用- 压缩解压
- tar -xzvf 1.tar.gzgz解压
- tar -czvf 1.tar.gz 1.cgz压缩文件夹或文件
- zip -r 1.zip /homezip文件压缩备份 后面是压缩某个文件夹绝对路径
- unzip 1.zip解压zip
- 7z a 1.7z ./html压缩支持多个文件夹 有些系统7za
- 7z x 1.7z解压当前目录- 7z x 1.7z -o./qq到指定qq目录- 防火墙
- ufw enable && ufw default deny启动防火墙
- ufw status列出所有
- ufw allow 9999- ufw allow 22/tcp允许端口
- ufw delete allow 9999删除端口
- ufw version- vi或vim操作配置
- ESC :q 退出 | :wq! 退出并保存| 按I键 进入输入模式
- echo $PATH类似win的path
- export CGO_ENABLED=1导入变量
- export CC=/usr/local/musl/bin/musl-gcc编译musl-gcc
- vi /etc/profile末尾加入- export PATH=$PATH:/root/bin多个用:分割
- source /etc/profile立即生效上面修改
- vi /etc/init.wsl自动启动文件
- vi /etc/ssh/sshd_config编辑此文件内容如下Port 22 PermitRootLogin yes- systemd
- systemctl list-unit-files --type=service --state=enabled查看开机启动项
- systemctl list-units --type=service --state=running显示当前活跃(运行中)的服务- 编译程序
- ./configure
- make && make install
dnf centos/rocky/阿里云 yum/rpm
- rpm -ivh package_name.rpmrpm安装
- dnf history list | grep Install列出最近安装软件
- dnf info golang前者简介查看信息后者详细信息
- dnf upgrade与- dnf update功能相同
- dnf install upx支持install,search,remove
- dnf list installed已安装软件
- dnf install epel-release -y安装扩展
- dnf clean all && dnf makecache生成缓存
- dnf install --nogpgcheck https://mirrors.rpmfusion.org/free/el/rpmfusion-free-release-$(rpm -E %rhel).noarch.rpm -y免费仓库
- sudo dnf makecache添加源后刷新
- dnf list --showduplicates nginx列出可用版本
- dnf install nginx-2:1.28.0-1.el10.ngx
- dnf install sqlite lua
- dnf install nodejs- node -v- npm -v- postgresql
- dnf install postgresql postgresql-server5432端口- sudo postgresql-setup --initdb初始化
 远程访问
 vi /var/lib/pgsql/data/pg_hba.conf 添加- host all all 0.0.0.0/0 scram-sha-256
 vi /var/lib/pgsql/data/postgresql.conf 配置文件- listen_addresses = '*' # 默认为 'localhost'远程- port = 5432端口修改- sudo -i -u postgres切换账号- psql
 systemctl start postgresql 启动
 systemctl restart postgresql重启
 systemctl enable postgresql 开机启动
 systemctl status postgresql 状态- mysql
- dnf install mysql8.4 mysql8.4-server- vi /etc/my.cnf.d/mysql-server.cnf配置- port = 3306注意权限不能修改,/etc/my.cnf也不能改权限,默认密码为空- bind-address = 0.0.0.0允许远程- mysql -u root -p -P 3307登陆自定义端口
 systemctl start mysqld 启动
 systemctl restart mysqld 重启
 sudo systemctl enable mysqld 创建开机启动- btop 7zip git wget openssh-server
- dnf install btop zip unzip 7zip git wget openssh-server openssh-clients
 systemctl start sshd 启动 stop 停止
 systemctl restart sshd 重启
 systemctl status sshd 状态
 systemctl enable sshd 设置开机 disable 取消
 systemctl is-enabled sshd 是否开机启动- nginx
- dnf install nginx
 systemctl start nginx
 systemctl stop nginx
 systemctl reload nginx
 systemctl restart nginx
 systemctl enable nginx 开机启动
 systemctl status nginx 状态
 curl http://localhost 测试- nginx -V查看模块- nginx -t查看配置- /etc/nginx/conf.d/配置文件 默认 root /usr/share/nginx/html- 禁止缓存 location ~* \.(js|css|png|jpg|gif|webp)$ { add_header Cache-Control no-store; } 防盗链 location ~* \.(gif|jpg|png)$ { valid_referers none blocked 192.168.0.1; if ($invalid_referer) { rewrite ^/ http://$host/logo.png; } } 显示目录 autoindex on; autoindex_exact_size off; autoindex_localtime on; 配置php listen 8000 ssl; server_name localhost; root /home/html; index index.html index.htm index.php; location ~ \.php$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } 配置ssl ssl_certificate /root/nginx/localhost.pem; ssl_certificate_key /root/nginx/localhostkey.pem; ssl_session_cache shared:SSL:1m; ssl_session_timeout 5m; ssl_ciphers HIGH:!aNULL:!MD5; ssl_prefer_server_ciphers on;- [nginx-stable] name=nginx stable repo baseurl=http://nginx.org/packages/centos/$releasever/$basearch/ gpgcheck=1 enabled=1 gpgkey=https://nginx.org/keys/nginx_signing.key [nginx-mainline] name=nginx mainline repo baseurl=http://nginx.org/packages/mainline/centos/$releasever/$basearch/ gpgcheck=1 enabled=0 gpgkey=https://nginx.org/keys/nginx_signing.key- 安装 GCC,make,binutils
- dnf install gcc gcc-c++ make binutils glibc-devel zlib-devel openssl-devel autoconf automake libtool cmake- snap
- dnf install snapd -y
- systemctl enable --now snapd.socket
- sudo ln -s /var/lib/snapd/snap /snap经典模式
- sudo systemctl start snapd开启
- sudo systemctl enable snapd开机启动项- snap ubuntu/Debian apt/deb
- apt install ./package_name.deb
- apt update && apt upgradeapt更新升级
- apt install upx fd-find zip unzip 7zip
- apt install openssh-server openssh-client sqlite3
- apt remove upx移除
- apt search upx搜索
- apt show upx显示细节
- snap install snap-store-proxy加速,一般不需要
- snap find qq# 搜索
- snap list# 查看已安装列表
- snap refresh# 更新所有包
- snap remove msedit# 卸载软件
- ssh
 systemctl enable ssh 设置开机 disable 取消
 systemctl is-enabled ssh 是否开机启动
 systemctl start ssh 启动 stop 停止
 systemctl restart ssh 重启
 systemctl status ssh 状态特殊安装 msedit go rustup
- snap install msedit
- snap install go --classic特殊安装golang- snap refresh go更新
- snap install rustup --classic安装rust- rustup install stable初始化- rustup update更新- redis
- snap install redis安装redis
 redis.cli -v 检测版本
 redis.cli 客户端 redis.cli -h 127.0.0.1 -p 6380
 snap start redis | snap stop redis | snap restart redis
 snap services redis
 ps -ef | grep redis-server 查看状态- msedit /var/snap/redis/common/etc/redis/redis.conf配置- /var/snap/redis/common/var/lib/redis/dump.rdb备份文件- 手动安装caddy安装到- /usr/local/bin- caddy validate --config /usr/local/bin/Caddyfile- useradd -r -s /sbin/nologin caddy创建用户- systemctl status caddy.service检测失败原因- systemctl daemon-reload重载systed- systemctl start caddy启动- systemctl restart caddy重新- systemctl status caddy状态- systemctl enable caddy开机启动- sudo chown -R caddy:caddy /home/caddy/设置权限
 vi /etc/systemd/system/caddy.service
[Unit]
Description=Caddy
Documentation=https://caddyserver.com/docs/
After=network.target network-online.target
Wants=network-online.target
[Service]
Type=notify
User=caddy
Group=caddy
ExecStart=/usr/local/bin/caddy run --environ --config /usr/local/bin/Caddyfile
ExecReload=/usr/local/bin/caddy reload --config /usr/local/bin/Caddyfile --force
TimeoutStopSec=5s
LimitNOFILE=1048576
LimitNPROC=512
PrivateTmp=true
ProtectSystem=full
AmbientCapabilities=CAP_NET_BIND_SERVICE
[Install]
WantedBy=multi-user.targetCaddyfile
http://127.0.0.1:9000 http://localhost:9000 {
        root * /home/rocky/html
        file_server browse
}树莓派3b+为例 rocky9.2
Raspberry Pi 3 Model B Plus Rev 1.3 1G内存16G存储
rocky rockylinux 默认账号密码
sudo rootfs-expand 安装完后分区
sudo passwd root 启用root
vi /etc/ssh/sshd_config
su -
nmcli radio wifi on  启用wifi
nmcli dev wifi list 扫描wifi
nmcli --ask dev wifi connect 3G
lshw查看硬件信息ubuntu24.04
- 修改软件源 /etc/apt/sources.list
deb https://mirrors.aliyun.com/ubuntu/ noble main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ noble main restricted universe multiverse
deb https://mirrors.aliyun.com/ubuntu/ noble-security main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ noble-security main restricted universe multiverse
deb https://mirrors.aliyun.com/ubuntu/ noble-updates main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ noble-updates main restricted universe multiverse
# deb https://mirrors.aliyun.com/ubuntu/ noble-proposed main restricted universe multiverse
# deb-src https://mirrors.aliyun.com/ubuntu/ noble-proposed main restricted universe multiverse
deb https://mirrors.aliyun.com/ubuntu/ noble-backports main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ noble-backports main restricted universe multiverse
作者:Yoby  创建时间:2024-12-04 18:18
最后编辑:Yoby 更新时间:2025-10-31 18:07
最后编辑:Yoby 更新时间:2025-10-31 18:07
