本站地址:https://tenyon.cn

Linux

登录

立刻重启

shutdown -r now

登录管理员

su root

查看 ip

ip addr show

网络

修改 dphc

vi /etc/sysconfig/network-scripts/ifcfg -e +tap

重启网络

service network restart 172.16.176.143

查看网络 端口

netstat -an | more

防火墙

开启防火墙

systemctl start firewalld

防火墙状态

systemctl status firewalld

停止防火墙

systemctl stop firewalld.service

禁止防火墙开机启动

systemctl disable firewalld.service

SSH 服务

ps:_ssh 连接后可以在 ip1 下面连接 ip2 然后 exit 退出

启动 ssh 服务

systemctl start sshd.service

关闭 ssh 服务

systemctl stop sshd.service

重启 ssh 服务

systemctl enable sshd.service

开机启动 ssh 服务

systemctl enable sshd.service

授权

ps:-r 可读 4-w 可写 2-x 可执行 1 用二进制表示的 user group other 三组

完全公开

chown nobody:nobody	xxx.txt

完全公开文件夹

chown -R  nobody:nobody test

授权文件

chmod 777 bbb

授权文件夹

chmod -R 777 test

安装软件

解压缩文件

tar -xvf xxx.tar.gz

安装单个

rpm -ivh xxx.rpm

安装全部

rpm -ivh *.rpm force

安装 bin 包

./xxxxx.bin

其他

yum install docker
yum install nginx

性能

cpu性能

cat /proc/cpuinfo| grep "cpu"

cpu使用率

yum install epel-release   yum install htop
top

磁盘空间

df -h

网络

iftop

ip

yum install net-tools
ifconfig

查看所有进程/某个进程

ps -ef |grep xxx

进程信息放到txt中

>>重定向符号

ps -ef >>a.txt

仅仅查看

cat a.txt

数据库

创建

CREATE USER 'yovvis'@'localhost' IDENTIFIED BY 'yovvis666';

修改root密码

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '新密码';
FLUSH PRIVILEGES;

授权

mysql> grant all privileges on *.* to 'tenyon'@'%';
SHOW GRANTS FOR 'tenyon'@'%';

脱敏

-- 姓名

update userinfo SET username = rpad(substring(username, 1, 1 ), char_length(username), '*' ) where 1=1

-- 电话

update userinfo SET username = CONCAT(LEFT (username, 3 ), '****' ,RIGHT(username,4)) where 1=1

-- 单位

update ouinfo SET ouname = REPLACE (ouname, SUBSTRING(ouname,1,2),'**' ) WHERE ouname regexp '市'
-- 查看脱敏后的用户名(不修改原数据)
SELECT 
    username,
    IFNULL(
        CONCAT(
            SUBSTRING(username, 1, CHAR_LENGTH(username) - 1),
            '一'
        ), 
        username
    ) AS 脱敏后用户名
FROM 你的表名;

-- 直接修改表中数据(谨慎使用)
UPDATE 你的表名
SET username = IFNULL(
    CONCAT(
        SUBSTRING(username, 1, CHAR_LENGTH(username) - 1),
        '一'
    ), 
    username
)
WHERE username IS NOT NULL AND username != '';