本文最后更新于 2023年4月7日 14:14 可能会因为没有更新而失效。如已失效或需要修正,请留言
mysql 备份数据库
[[email protected]]# mysqldump -u root -p 要备份的数据库名 > 数据库名.sql
mysql 导入数据库
mysql -u root -p create database 要导入的数据库名; use 要导入的数据库名; set names utf8; source 要导入的数据库文件路径; quit;
修改mysql用户权限
grant 权限1,权限2 on *.* to 用户@"%" identified by "用户密码";
grant all on *.* to 用户@"localhost" identified by "用户密码";
grant all on test.* to 用户@"127.0.0.1" identified by "用户密码";
删除mysql用户
drop user 用户@"%";
查看mysql用户权限
show grants for 用户@"%";
查看mysql用户权限表
select * from mysql.user;
刷新mysql配置
flush privileges;
mysql 常用权限
表权限: 'Select', 'Insert', 'Update', 'Delete', 'Create', 'Drop', 'Grant', 'References', 'Index', 'Alter' 列权限: 'Select', 'Insert', 'Update', 'References' 过程权限: 'Execute', 'Alter Routine', 'Grant'
查看bbr 是否开启
[[email protected]]# lsmod | grep bbr
查看ip地址
[[email protected]]# ip address
查看路由
[[email protected]]# route
解、压缩命令
[[email protected]]# tar zcvf xxx.tar.gz 文件or文件夹 --exclude=排除的文件or文件夹 //压缩 [[email protected]]# tar zxvf xxx.tar.gz //解压
后台运行程序
[[email protected]]# nohup 命令 > /dev/null 2>&1 &
后台运行程序(screen)
[[email protected]]# screen -S 任意名称 [[email protected]]# 运行程序 [[email protected]]# Ctrl+a 以及 Ctrl+d (键盘快捷键执行,会保持当前会话的运行并退出当前会话) [[email protected]]# screen -ls (查看当前运行的screen会话列表) [[email protected]]# screen -r ID (进入对应的screen会话,ID可根据上一条命令查看)
运行程序时写入日志且实时显示日志
[[email protected]]# 程序 >> xxx.log & tail -f xxx.log
查看文件\文件夹大小
[[email protected]]# du -sh 文件or文件夹
ssh传输数据 传文件 (scp)
[[email protected]]# scp 传输的文件 对方用户@对方IP:对方路径
ssh传输数据 传文件 (scp)特定端口
[[email protected]]# scp -P 端口号 传输的文件 对方用户@对方IP:对方路径
显示当前网络连接 (端口、进程)
[[email protected]]# netstat -lntp
查看内存使用情况
[[email protected]]# free -m
查找 查询
[[email protected]]# find / -name '查询的字符' //“/” 是查询的路径 [[email protected]]# whereis 查询的字符 [[email protected]]# which 查询可执行文件
在文件夹所有文件内容中查找相关信息
[[email protected]]# grep -nr "查找的内容" 路径
显示输出行的指定部分
比如,想查看当前服务器IP,输入 curl -s myip.ipip.net ,可出来以下结果: 当前 IP:119.119.119.119 来自于:中国 但是我只需要显示IP地址的部分,故需要对结果进行裁剪: curl -s myip.ipip.net|cut -b 13-27 这样就只会显示IP地址,具体根据范围设置,更多请用 cut --help
查看运行中的程序
[[email protected]]# ps -ef [[email protected]]# ps -ef|grep 程序名
查看系统内核
[[email protected]]# uname -r
查看历史命令
[[email protected]]# history
设置history命令的保存数量且显示日期
[[email protected]]# echo $HISTSIZE //查看当前保存数量 [[email protected]]# vi /etc/profile 添加下面2行命令到文件末尾: HISTTIMEFORMAT='%F %T ' HISTSIZE="10000" [[email protected]]# source /etc/profile //强制更新 [[email protected]]# echo $HISTSIZE //查看效果
查看当前路径
[[email protected]]# pwd
强制删除文件/文件夹
[[email protected]]# rm -rf 文件/文件夹
清空文件内容
[[email protected]]# cat /dev/null > 文件
创建文件夹
[[email protected]]# mkdir 名称
列出文件/文件夹
[[email protected]]# ls -al
退出当前用户
[[email protected]]# exit
关机
[[email protected]]# shutdown -h now
[[email protected]]# halt
[[email protected]]# poweroff
重启
[[email protected]]# shutdown -r now
[[email protected]]# reboot
切换目录
[[email protected]]# cd 路径
[[email protected]]# cd ~
移动文件或修改文件名
[[email protected]]# mv 修改前的文件名 修改后的文件名
[[email protected]]# mv 需要移动的文件 /目的路径
复制
[[email protected]]# cp -r 文件/文件夹 路径
改变文件/文件夹权限
[[email protected]]# chmod -R 755 文件/文件夹
改变文件/文件夹所属者
[[email protected]]# chown -R www-data:www-data 文件/文件夹
显示系统时间
[[email protected]]# date
显示当前进程
[[email protected]]# top
杀死进程
[[email protected]]# kill 进程号
显示文件内容
[[email protected]]# cat 文件
关闭SELinux
vi /etc/selinux/config 设置: SELINUX=disabled 保存退出,重启系统