老爹
老爹
发布于 2026-02-26 / 11 阅读
0
0

常用命令

查看信息

cat /etc/redhat-release #查看版本

uname -m #查看架构

who -b #查看启动时间

netstat -ano #网络状态

egrep -i 'killed process' /var/log/messages #查看linux自杀了哪些东西

grep "Accepted" /var/log/secure #查看登录成功的日志

关闭安全模式

vi /etc/selinux/config

SELINUX=disabled

getenforce #查看结果

ssh

vi /etc/ssh/sshd_config

#允许root登录
PermitRootLogin yes
#允许密码登录
PasswordAuthentication yes
#允许公钥登录
PubkeyAuthentication yes

systemctl restart sshd

  • 公钥(*.pub 是公钥 无后缀的是私钥,登录时提供的是私钥)

ssh-keygen -t ed25519 -f {路径}/xiao_key -N "" -C "xiao" #生成密钥(在你自己的电脑)

ssh-copy-id -i {路径}/xiao_key.pub root@{ip} -p 22 #复制公钥至指定目标

vi ~/.ssh/authorized_keys # 或者手动配置公钥 效果同上 这文件里就是一行一个公钥

复制xiao_key.pub内容进去

反向隧道(废弃,现用frp)

#建立隧道

#-R: 指定反向隧道。

#14122:localhost:22: 将{ip}的14122连接映射到本地的22端口

#-i 密钥 创建隧道时不密码

#-fN: 让 SSH 在后台运行,并不执行远程命令(只建立隧道)。

ssh -fN -R 14122:localhost:22 root@{ip} -i {私钥}

#连接隧道

ssh -p 外网端口 内网用户名@外网ip

#关闭隧道

pkill -f 'ssh -fN -R 14122:localhost:22 root@{ip}'

ip

nmtui ##类型选manual

nmcli connection up

systemctl restart NetworkManager

时区

ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

查看内存

df -h

du -h --max-depth=1 #查看当前目录下的文件大小

查看cpu

lscpu #看看cpu啥样

uptime #看看开机时间和cpu过去1 5 15 分钟负载

uptime -s #显示系统最后一次启动的时间。

安装字体

C:/Users/Administrator/AppData/Local/Microsoft/Windows/Fonts/ #win字体目录

/usr/share/fonts/chinese #linux字体目录(新建文件夹)

fc-cache -fv #刷新缓存

fc-list #查看所有字体

fc-list :lang=zh #查看中文字体

对时

yum install -y chrony

vi /etc/chrony.conf

#外网对时
pool ntp.aliyun.com iburst
pool 210.72.145.44 iburst
pool s1b.time.edu.cn iburst
pool s1c.time.edu.cn iburst
#作为时间服务器允许内网对时
allow 172.19.46.0/24
#内网
server {外网时间服务器ip} iburst

chronyc tracking # 查看同步状态

chronyc sources -v # 查看时间源

sudo chronyc -a makestep # 手动强制同步(测试用)


评论